test(fab, fab-button): migrate to generators (#27308)
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. --> - Fab and fab button tests are using legacy syntax ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Fab and fab button tests use generator syntax ## 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,16 +0,0 @@
|
|||||||
import { expect } from '@playwright/test';
|
|
||||||
import { test } from '@utils/test/playwright';
|
|
||||||
|
|
||||||
test.describe('fab-button: aria attributes', () => {
|
|
||||||
test('should inherit aria attributes to inner button', async ({ page, skip }) => {
|
|
||||||
skip.rtl();
|
|
||||||
skip.mode('ios');
|
|
||||||
|
|
||||||
await page.setContent(`
|
|
||||||
<ion-fab-button aria-label="Hello World">My Button</ion-fab-button>
|
|
||||||
`);
|
|
||||||
|
|
||||||
const nativeButton = page.locator('ion-fab-button button');
|
|
||||||
await expect(nativeButton).toHaveAttribute('aria-label', 'Hello World');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
18
core/src/components/fab-button/test/a11y/fab-button.e2e.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { expect } from '@playwright/test';
|
||||||
|
import { configs, test } from '@utils/test/playwright';
|
||||||
|
|
||||||
|
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||||
|
test.describe(title('fab-button: aria attributes'), () => {
|
||||||
|
test('should inherit aria attributes to inner button', async ({ page }) => {
|
||||||
|
await page.setContent(
|
||||||
|
`
|
||||||
|
<ion-fab-button aria-label="Hello World">My Button</ion-fab-button>
|
||||||
|
`,
|
||||||
|
config
|
||||||
|
);
|
||||||
|
|
||||||
|
const nativeButton = page.locator('ion-fab-button button');
|
||||||
|
await expect(nativeButton).toHaveAttribute('aria-label', 'Hello World');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,72 +0,0 @@
|
|||||||
import { expect } from '@playwright/test';
|
|
||||||
import { test } from '@utils/test/playwright';
|
|
||||||
|
|
||||||
test.describe('fab: basic (visual checks)', () => {
|
|
||||||
test.beforeEach(async ({ page }) => {
|
|
||||||
await page.goto(`/src/components/fab/test/basic`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not have visual regressions', async ({ page }) => {
|
|
||||||
await page.setIonViewport();
|
|
||||||
|
|
||||||
await expect(page).toHaveScreenshot(`fab-basic-${page.getSnapshotSettings()}.png`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not have visual regressions when open', async ({ page }) => {
|
|
||||||
// this fab has multiple buttons on each side, so it covers all the bases
|
|
||||||
const fab = page.locator('#fab5');
|
|
||||||
|
|
||||||
await fab.click();
|
|
||||||
await page.waitForChanges();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* fab.screenshot doesn't work since ion-fab's bounding box only covers the
|
|
||||||
* central button. This viewport size crops extra white space while also
|
|
||||||
* containing all the buttons in the open fab.
|
|
||||||
*/
|
|
||||||
await page.setViewportSize({
|
|
||||||
width: 320,
|
|
||||||
height: 415,
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(page).toHaveScreenshot(`fab-open-${page.getSnapshotSettings()}.png`, { animations: 'disabled' });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test.describe('fab: basic (functionality checks)', () => {
|
|
||||||
test.beforeEach(async ({ page, skip }) => {
|
|
||||||
skip.rtl();
|
|
||||||
skip.mode('ios');
|
|
||||||
|
|
||||||
await page.goto(`/src/components/fab/test/basic`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should toggle active state when clicked', async ({ page }) => {
|
|
||||||
const fab = page.locator('#fab1');
|
|
||||||
const fabList = fab.locator('ion-fab-list');
|
|
||||||
|
|
||||||
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
|
||||||
|
|
||||||
// open fab
|
|
||||||
await fab.click();
|
|
||||||
await page.waitForChanges();
|
|
||||||
await expect(fabList).toHaveClass(/fab-list-active/);
|
|
||||||
|
|
||||||
// close fab
|
|
||||||
await fab.click();
|
|
||||||
await page.waitForChanges();
|
|
||||||
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not open when disabled', async ({ page }) => {
|
|
||||||
const fab = page.locator('#fab2');
|
|
||||||
const fabList = fab.locator('ion-fab-list');
|
|
||||||
|
|
||||||
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
|
||||||
|
|
||||||
// attempt to open fab
|
|
||||||
await fab.click();
|
|
||||||
await page.waitForChanges();
|
|
||||||
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
77
core/src/components/fab/test/basic/fab.e2e.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import { expect } from '@playwright/test';
|
||||||
|
import { configs, test } from '@utils/test/playwright';
|
||||||
|
|
||||||
|
configs().forEach(({ title, screenshot, config }) => {
|
||||||
|
test.describe(title('fab: basic (visual checks)'), () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto(`/src/components/fab/test/basic`, config);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not have visual regressions', async ({ page }) => {
|
||||||
|
await page.setIonViewport();
|
||||||
|
|
||||||
|
await expect(page).toHaveScreenshot(screenshot(`fab-basic`));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not have visual regressions when open', async ({ page }) => {
|
||||||
|
// this fab has multiple buttons on each side, so it covers all the bases
|
||||||
|
const fab = page.locator('#fab5');
|
||||||
|
|
||||||
|
await fab.click();
|
||||||
|
await page.waitForChanges();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fab.screenshot doesn't work since ion-fab's bounding box only covers the
|
||||||
|
* central button. This viewport size crops extra white space while also
|
||||||
|
* containing all the buttons in the open fab.
|
||||||
|
*/
|
||||||
|
await page.setViewportSize({
|
||||||
|
width: 320,
|
||||||
|
height: 415,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page).toHaveScreenshot(screenshot(`fab-open`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This behavior does not vary
|
||||||
|
* across modes/directions.
|
||||||
|
*/
|
||||||
|
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||||
|
test.describe(title('fab: basic (functionality checks)'), () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto(`/src/components/fab/test/basic`, config);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should toggle active state when clicked', async ({ page }) => {
|
||||||
|
const fab = page.locator('#fab1');
|
||||||
|
const fabList = fab.locator('ion-fab-list');
|
||||||
|
|
||||||
|
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
||||||
|
|
||||||
|
// open fab
|
||||||
|
await fab.click();
|
||||||
|
await page.waitForChanges();
|
||||||
|
await expect(fabList).toHaveClass(/fab-list-active/);
|
||||||
|
|
||||||
|
// close fab
|
||||||
|
await fab.click();
|
||||||
|
await page.waitForChanges();
|
||||||
|
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not open when disabled', async ({ page }) => {
|
||||||
|
const fab = page.locator('#fab2');
|
||||||
|
const fabList = fab.locator('ion-fab-list');
|
||||||
|
|
||||||
|
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
||||||
|
|
||||||
|
// attempt to open fab
|
||||||
|
await fab.click();
|
||||||
|
await page.waitForChanges();
|
||||||
|
await expect(fabList).not.toHaveClass(/fab-list-active/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@ -1,11 +0,0 @@
|
|||||||
import { expect } from '@playwright/test';
|
|
||||||
import { test } from '@utils/test/playwright';
|
|
||||||
|
|
||||||
test('should not have visual regressions', async ({ page, skip }) => {
|
|
||||||
skip.rtl();
|
|
||||||
await page.goto(`/src/components/fab/test/states`);
|
|
||||||
|
|
||||||
await page.setIonViewport();
|
|
||||||
|
|
||||||
await expect(page).toHaveScreenshot(`fab-states-${page.getSnapshotSettings()}.png`);
|
|
||||||
});
|
|
||||||
14
core/src/components/fab/test/states/fab.e2e.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { expect } from '@playwright/test';
|
||||||
|
import { configs, test } from '@utils/test/playwright';
|
||||||
|
|
||||||
|
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||||
|
test.describe(title('fab: states'), () => {
|
||||||
|
test('should not have visual regressions', async ({ page }) => {
|
||||||
|
await page.goto(`/src/components/fab/test/states`, config);
|
||||||
|
|
||||||
|
await page.setIonViewport();
|
||||||
|
|
||||||
|
await expect(page).toHaveScreenshot(screenshot(`fab-states`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
@ -1,24 +0,0 @@
|
|||||||
import { expect } from '@playwright/test';
|
|
||||||
import { test } from '@utils/test/playwright';
|
|
||||||
|
|
||||||
test('should not have visual regressions', async ({ page, skip }) => {
|
|
||||||
skip.rtl();
|
|
||||||
skip.mode('md', 'Translucency is only available on ios mode');
|
|
||||||
await page.goto(`/src/components/fab/test/translucent`);
|
|
||||||
|
|
||||||
const fab = page.locator('#fab5');
|
|
||||||
await fab.click();
|
|
||||||
await page.waitForChanges();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* fab.screenshot doesn't work since ion-fab's bounding box only covers the
|
|
||||||
* central button. This viewport size crops extra white space while also
|
|
||||||
* containing all the buttons in the open fab.
|
|
||||||
*/
|
|
||||||
await page.setViewportSize({
|
|
||||||
width: 235,
|
|
||||||
height: 310,
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(page).toHaveScreenshot(`fab-translucent-${page.getSnapshotSettings()}.png`, { animations: 'disabled' });
|
|
||||||
});
|
|
||||||
29
core/src/components/fab/test/translucent/fab.e2e.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { expect } from '@playwright/test';
|
||||||
|
import { configs, test } from '@utils/test/playwright';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translucency is only available on ios mode
|
||||||
|
*/
|
||||||
|
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||||
|
test.describe(title('fab: translucent'), () => {
|
||||||
|
test('should not have visual regressions', async ({ page }) => {
|
||||||
|
await page.goto(`/src/components/fab/test/translucent`, config);
|
||||||
|
|
||||||
|
const fab = page.locator('#fab5');
|
||||||
|
await fab.click();
|
||||||
|
await page.waitForChanges();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fab.screenshot doesn't work since ion-fab's bounding box only covers the
|
||||||
|
* central button. This viewport size crops extra white space while also
|
||||||
|
* containing all the buttons in the open fab.
|
||||||
|
*/
|
||||||
|
await page.setViewportSize({
|
||||||
|
width: 235,
|
||||||
|
height: 310,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(page).toHaveScreenshot(screenshot(`fab-translucent`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |