Skip to content

Commit eba4c7f

Browse files
authored
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. --> ec529cf - 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. 3771d8e - 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. -->
1 parent 0e13b5b commit eba4c7f

8 files changed

+10
-20
lines changed

core/src/components/toast/test/is-open/toast.e2e.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,20 @@ import { configs, test } from '@utils/test/playwright';
66
*/
77
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
88
test.describe(title('toast: isOpen'), () => {
9-
test.beforeEach(async ({ page }) => {
9+
test('should open and close the toast', async ({ page }) => {
1010
await page.goto('/src/components/toast/test/is-open', config);
11-
});
1211

13-
test('should open the toast', async ({ page }) => {
1412
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
13+
const ionToastDidDismiss = await page.spyOnEvent('ionToastDidDismiss');
14+
1515
const toast = page.locator('ion-toast');
1616

1717
await page.click('#default');
1818

1919
await ionToastDidPresent.next();
2020
await expect(toast).toBeVisible();
21-
});
2221

23-
test('should open the toast then close after a timeout', async ({ page }) => {
24-
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
25-
const ionToastDidDismiss = await page.spyOnEvent('ionToastDidDismiss');
26-
const toast = page.locator('ion-toast');
27-
28-
await page.click('#timeout');
29-
30-
await ionToastDidPresent.next();
31-
await expect(toast).toBeVisible();
22+
await toast.evaluate((el: HTMLIonToastElement) => (el.isOpen = false));
3223

3324
await ionToastDidDismiss.next();
3425
await expect(toast).toBeHidden();

core/src/components/toast/test/standalone/toast.e2e.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

44
/**
5-
* This test does not check LTR vs RTL layouts
5+
* This behavior does not vary across modes/directions.
66
*/
7-
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
7+
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
88
test.describe(title('toast: standalone'), () => {
9-
test.beforeEach(async ({ page }) => {
9+
test('should open overlay without ion-app', async ({ page }) => {
1010
await page.goto(`/src/components/toast/test/standalone`, config);
11-
});
12-
test('should not have visual regressions', async ({ page }) => {
11+
1312
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent');
13+
const toast = page.locator('ion-toast');
1414

1515
const basicButton = page.locator('#basic-toast');
1616
await basicButton.click();
1717

1818
await ionToastDidPresent.next();
19-
20-
await expect(page).toHaveScreenshot(screenshot(`toast-standalone`));
19+
await expect(toast).toBeVisible();
2120
});
2221
});
2322
});

0 commit comments

Comments
 (0)