mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
test(toast): clean up tests (#27435)
Issue number: N/A --------- <!-- 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. --> There are several redundant tests I missed during my generator pass. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. -->ec529cfe12- The isOpen tests are testing that you can open/close the modal by triggering the `isOpen` property. I combined the two tests into 1 test since they are doing the same thing: Checking that the modal opens when `isOpen` is `true` and closes when `isOpen` is false. This also avoids the 500ms timeout of the 2nd test which should speed up execution.3771d8e5b2- Removed the "standalone" screenshot in favor of just checking that the overlay is visible. Rendering of the contents of the overlay are not dependent on `ion-app` being present. ## 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. -->
This commit is contained in:
@ -6,29 +6,20 @@ import { configs, test } from '@utils/test/playwright';
|
|||||||
*/
|
*/
|
||||||
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||||
test.describe(title('toast: isOpen'), () => {
|
test.describe(title('toast: isOpen'), () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test('should open and close the toast', async ({ page }) => {
|
||||||
await page.goto('/src/components/toast/test/is-open', config);
|
await page.goto('/src/components/toast/test/is-open', config);
|
||||||
});
|
|
||||||
|
|
||||||
test('should open the toast', async ({ page }) => {
|
|
||||||
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
|
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
|
||||||
|
const ionToastDidDismiss = await page.spyOnEvent('ionToastDidDismiss');
|
||||||
|
|
||||||
const toast = page.locator('ion-toast');
|
const toast = page.locator('ion-toast');
|
||||||
|
|
||||||
await page.click('#default');
|
await page.click('#default');
|
||||||
|
|
||||||
await ionToastDidPresent.next();
|
await ionToastDidPresent.next();
|
||||||
await expect(toast).toBeVisible();
|
await expect(toast).toBeVisible();
|
||||||
});
|
|
||||||
|
|
||||||
test('should open the toast then close after a timeout', async ({ page }) => {
|
await toast.evaluate((el: HTMLIonToastElement) => (el.isOpen = false));
|
||||||
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
|
|
||||||
const ionToastDidDismiss = await page.spyOnEvent('ionToastDidDismiss');
|
|
||||||
const toast = page.locator('ion-toast');
|
|
||||||
|
|
||||||
await page.click('#timeout');
|
|
||||||
|
|
||||||
await ionToastDidPresent.next();
|
|
||||||
await expect(toast).toBeVisible();
|
|
||||||
|
|
||||||
await ionToastDidDismiss.next();
|
await ionToastDidDismiss.next();
|
||||||
await expect(toast).toBeHidden();
|
await expect(toast).toBeHidden();
|
||||||
|
|||||||
@ -2,22 +2,21 @@ import { expect } from '@playwright/test';
|
|||||||
import { configs, test } from '@utils/test/playwright';
|
import { configs, test } from '@utils/test/playwright';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test does not check LTR vs RTL layouts
|
* This behavior does not vary across modes/directions.
|
||||||
*/
|
*/
|
||||||
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||||
test.describe(title('toast: standalone'), () => {
|
test.describe(title('toast: standalone'), () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test('should open overlay without ion-app', async ({ page }) => {
|
||||||
await page.goto(`/src/components/toast/test/standalone`, config);
|
await page.goto(`/src/components/toast/test/standalone`, config);
|
||||||
});
|
|
||||||
test('should not have visual regressions', async ({ page }) => {
|
|
||||||
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
|
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
|
||||||
|
const toast = page.locator('ion-toast');
|
||||||
|
|
||||||
const basicButton = page.locator('#basic-toast');
|
const basicButton = page.locator('#basic-toast');
|
||||||
await basicButton.click();
|
await basicButton.click();
|
||||||
|
|
||||||
await ionToastDidPresent.next();
|
await ionToastDidPresent.next();
|
||||||
|
await expect(toast).toBeVisible();
|
||||||
await expect(page).toHaveScreenshot(screenshot(`toast-standalone`));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Reference in New Issue
Block a user