test(tabs, tab-bar, tab-button): migrate to generators (#27356)
Issue number: N/A
---------
<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->
<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->
<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->
<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
Tabs, tab bar, and tab button are using legacy syntax
## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->
- Tabs, tab bar, and tab button are using modern syntax
962754d094
- A translucent screenshot test was written in `tab-bar/test/basic` but
it is already being tested in `tab-bar/test/translucent`, so I deleted
the duplicate test/screenshots.
## Does this introduce a breaking change?
- [ ] Yes
- [x] No
<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->
## Other information
<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@ -1,38 +0,0 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('tabs: basic', () => {
|
||||
test('should show correct tab when clicking the tab button', async ({ page, skip }) => {
|
||||
skip.rtl();
|
||||
skip.mode('ios');
|
||||
await page.goto('/src/components/tabs/test/basic');
|
||||
|
||||
const tabOne = page.locator('ion-tab[tab="tab-one"]');
|
||||
const tabTwo = page.locator('ion-tab[tab="schedule"]');
|
||||
|
||||
// The tab button for tab 3 is disabled so this is never visible
|
||||
const tabThree = page.locator('ion-tab[tab="tab-three"]');
|
||||
|
||||
// Tab Four renders a nested web component
|
||||
const tabFour = page.locator('ion-tab[tab="tab-four"] page-one');
|
||||
|
||||
await expect(tabOne).toBeVisible();
|
||||
await expect(tabTwo).toBeHidden();
|
||||
await expect(tabThree).toBeHidden();
|
||||
await expect(tabFour).toBeHidden();
|
||||
|
||||
await page.click('ion-tab-button[tab="schedule"]');
|
||||
|
||||
await expect(tabOne).toBeHidden();
|
||||
await expect(tabTwo).toBeVisible();
|
||||
await expect(tabThree).toBeHidden();
|
||||
await expect(tabFour).toBeHidden();
|
||||
|
||||
await page.click('ion-tab-button[tab="tab-four"]');
|
||||
|
||||
await expect(tabOne).toBeHidden();
|
||||
await expect(tabTwo).toBeHidden();
|
||||
await expect(tabThree).toBeHidden();
|
||||
await expect(tabFour).toBeVisible();
|
||||
});
|
||||
});
|
||||
38
core/src/components/tabs/test/basic/tabs.e2e.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||
test.describe(title('tabs: basic'), () => {
|
||||
test('should show correct tab when clicking the tab button', async ({ page }) => {
|
||||
await page.goto('/src/components/tabs/test/basic', config);
|
||||
|
||||
const tabOne = page.locator('ion-tab[tab="tab-one"]');
|
||||
const tabTwo = page.locator('ion-tab[tab="schedule"]');
|
||||
|
||||
// The tab button for tab 3 is disabled so this is never visible
|
||||
const tabThree = page.locator('ion-tab[tab="tab-three"]');
|
||||
|
||||
// Tab Four renders a nested web component
|
||||
const tabFour = page.locator('ion-tab[tab="tab-four"] page-one');
|
||||
|
||||
await expect(tabOne).toBeVisible();
|
||||
await expect(tabTwo).toBeHidden();
|
||||
await expect(tabThree).toBeHidden();
|
||||
await expect(tabFour).toBeHidden();
|
||||
|
||||
await page.click('ion-tab-button[tab="schedule"]');
|
||||
|
||||
await expect(tabOne).toBeHidden();
|
||||
await expect(tabTwo).toBeVisible();
|
||||
await expect(tabThree).toBeHidden();
|
||||
await expect(tabFour).toBeHidden();
|
||||
|
||||
await page.click('ion-tab-button[tab="tab-four"]');
|
||||
|
||||
await expect(tabOne).toBeHidden();
|
||||
await expect(tabTwo).toBeHidden();
|
||||
await expect(tabThree).toBeHidden();
|
||||
await expect(tabFour).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,40 +0,0 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('tabs: placement', () => {
|
||||
test.beforeEach(async ({ page, skip }) => {
|
||||
skip.rtl();
|
||||
skip.mode('ios');
|
||||
|
||||
await page.setViewportSize({
|
||||
width: 300,
|
||||
height: 200,
|
||||
});
|
||||
});
|
||||
test('should show tab bar at the top of tabs', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tabs>
|
||||
<ion-tab tab="one">My Content</ion-tab>
|
||||
<ion-tab-bar slot="top">
|
||||
<ion-tab-button tab="one">One</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
</ion-tabs>
|
||||
`);
|
||||
|
||||
const tabs = page.locator('ion-tabs');
|
||||
await expect(tabs).toHaveScreenshot(`tabs-tab-bar-top-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
test('should show tab bar at the bottom of tabs', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-tabs>
|
||||
<ion-tab tab="one">My Content</ion-tab>
|
||||
<ion-tab-bar slot="bottom">
|
||||
<ion-tab-button tab="one">One</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
</ion-tabs>
|
||||
`);
|
||||
|
||||
const tabs = page.locator('ion-tabs');
|
||||
await expect(tabs).toHaveScreenshot(`tabs-tab-bar-bottom-${page.getSnapshotSettings()}.png`);
|
||||
});
|
||||
});
|
||||
45
core/src/components/tabs/test/placements/tabs.e2e.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('tabs: placement'), () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.setViewportSize({
|
||||
width: 300,
|
||||
height: 200,
|
||||
});
|
||||
});
|
||||
test('should show tab bar at the top of tabs', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tabs>
|
||||
<ion-tab tab="one">My Content</ion-tab>
|
||||
<ion-tab-bar slot="top">
|
||||
<ion-tab-button tab="one">One</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
</ion-tabs>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabs = page.locator('ion-tabs');
|
||||
await expect(tabs).toHaveScreenshot(screenshot(`tabs-tab-bar-top`));
|
||||
});
|
||||
test('should show tab bar at the bottom of tabs', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-tabs>
|
||||
<ion-tab tab="one">My Content</ion-tab>
|
||||
<ion-tab-bar slot="bottom">
|
||||
<ion-tab-button tab="one">One</ion-tab-button>
|
||||
</ion-tab-bar>
|
||||
</ion-tabs>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const tabs = page.locator('ion-tabs');
|
||||
await expect(tabs).toHaveScreenshot(screenshot(`tabs-tab-bar-bottom`));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |