mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
Merge remote-tracking branch 'origin/main' into chore/sync-with-main-5-3
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
import AxeBuilder from '@axe-core/playwright';
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('tab-button: a11y', () => {
|
||||
test('should not have any axe violations', async ({ page }) => {
|
||||
await page.goto('/src/components/tab-button/test/a11y');
|
||||
configs().forEach(({ title, config }) => {
|
||||
test.describe(title('tab-button: a11y'), () => {
|
||||
test('should not have any axe violations', async ({ page }) => {
|
||||
await page.goto('/src/components/tab-button/test/a11y', config);
|
||||
|
||||
// TODO FW-3604
|
||||
const results = await new AxeBuilder({ page }).disableRules('color-contrast').analyze();
|
||||
expect(results.violations).toEqual([]);
|
||||
// TODO FW-3604
|
||||
const results = await new AxeBuilder({ page }).disableRules('color-contrast').analyze();
|
||||
expect(results.violations).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,85 +1,96 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('tab-button: basic', () => {
|
||||
test('should render tab button with label', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-label>Recents</ion-label>
|
||||
</ion-tab-button>
|
||||
configs().forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('tab-button: basic'), () => {
|
||||
test('should render tab button with label', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-label>Recents</ion-label>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-badge>23</ion-badge>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-badge>23</ion-badge>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3">
|
||||
<ion-label>Settings</ion-label>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="3">
|
||||
<ion-label>Settings</ion-label>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-label-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-label`));
|
||||
});
|
||||
|
||||
test('should render tab button with badges', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-badge color="danger"></ion-badge>
|
||||
</ion-tab-button>
|
||||
test('should render tab button with badges', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-badge color="danger"></ion-badge>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2">
|
||||
<ion-icon name="musical-note"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2">
|
||||
<ion-icon name="musical-note"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3">
|
||||
<ion-icon name="today"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="3">
|
||||
<ion-icon name="today"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="4">
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<ion-badge color="danger">47</ion-badge>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="4">
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<ion-badge color="danger">47</ion-badge>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-badge-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-badge`));
|
||||
});
|
||||
|
||||
test('should render tab button with icons', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-badge color="danger"></ion-badge>
|
||||
</ion-tab-button>
|
||||
test('should render tab button with icons', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-badge color="danger"></ion-badge>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2">
|
||||
<ion-icon name="musical-note"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2">
|
||||
<ion-icon name="musical-note"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3">
|
||||
<ion-icon name="today"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="3">
|
||||
<ion-icon name="today"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="4">
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<ion-badge color="danger">47</ion-badge>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="4">
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<ion-badge color="danger">47</ion-badge>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-badge-${page.getSnapshotSettings()}.png`);
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-badge`));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,133 +1,150 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('tab-button: basic', () => {
|
||||
test('should render tab button with icons left of text', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar color="light" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-start">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
<ion-badge color="danger">12</ion-badge>
|
||||
</ion-tab-button>
|
||||
configs().forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('tab-button: basic'), () => {
|
||||
test('should render tab button with icons left of text', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar color="light" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-start">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
<ion-badge color="danger">12</ion-badge>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2" layout="icon-start">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2" layout="icon-start">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3" layout="icon-start">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="3" layout="icon-start">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-icon-left-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-icon-left`));
|
||||
});
|
||||
|
||||
test('should render tab button with icons right of text', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar color="danger" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-end">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
</ion-tab-button>
|
||||
test('should render tab button with icons right of text', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar color="danger" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-end">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2" layout="icon-end">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-badge color="dark">33</ion-badge>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2" layout="icon-end">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-badge color="dark">33</ion-badge>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3" layout="icon-end">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="3" layout="icon-end">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-icon-right-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-icon-right`));
|
||||
});
|
||||
|
||||
test('should render tab button with icons below text', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar color="dark" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-bottom">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
</ion-tab-button>
|
||||
test('should render tab button with icons below text', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar color="dark" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-bottom">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2">
|
||||
<ion-badge>16</ion-badge>
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2">
|
||||
<ion-badge>16</ion-badge>
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3" layout="icon-bottom">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="3" layout="icon-bottom">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-icon-below-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-icon-below`));
|
||||
});
|
||||
|
||||
test('should render tab button with icons on top of text', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar color="secondary" selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-label>Location</ion-label>
|
||||
<ion-icon name="navigate"></ion-icon>
|
||||
</ion-tab-button>
|
||||
test('should render tab button with icons on top of text', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar color="secondary" selected-tab="1">
|
||||
<ion-tab-button tab="1">
|
||||
<ion-label>Location</ion-label>
|
||||
<ion-icon name="navigate"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2">
|
||||
<ion-badge color="danger">44</ion-badge>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2">
|
||||
<ion-badge color="danger">44</ion-badge>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3">
|
||||
<ion-label>Radio</ion-label>
|
||||
<ion-icon name="musical-notes"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="3">
|
||||
<ion-label>Radio</ion-label>
|
||||
<ion-icon name="musical-notes"></ion-icon>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-icon-top-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-icon-top`));
|
||||
});
|
||||
|
||||
test('should render tab button with no icons', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tab-bar color="primary" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-hide">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
</ion-tab-button>
|
||||
test('should render tab button with no icons', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tab-bar color="primary" selected-tab="1">
|
||||
<ion-tab-button tab="1" layout="icon-hide">
|
||||
<ion-label>Recents</ion-label>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="2" layout="icon-hide">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
<ion-tab-button tab="2" layout="icon-hide">
|
||||
<ion-label>Favorites</ion-label>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
</ion-tab-button>
|
||||
|
||||
<ion-tab-button tab="3" layout="icon-hide">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
<ion-badge color="danger">2</ion-badge>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`);
|
||||
<ion-tab-button tab="3" layout="icon-hide">
|
||||
<ion-label>Settings</ion-label>
|
||||
<ion-icon name="settings"></ion-icon>
|
||||
<ion-badge color="danger">2</ion-badge>
|
||||
</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
const tabBar = page.locator('ion-tab-bar');
|
||||
|
||||
await expect(tabBar).toHaveScreenshot(`tab-button-no-icon-${page.getSnapshotSettings()}.png`);
|
||||
await expect(tabBar).toHaveScreenshot(screenshot(`tab-button-no-icon`));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user