test(e2e): preserve toast coverage with CSS hiding

This commit is contained in:
Mohamed Boudra
2026-10-21 10:36:35 +02:00
parent 8342a95367
commit c0d6f34061
+14 -14
View File
@@ -1,5 +1,5 @@
import { metroTest as test, expect } from "../support/fixtures";
import { installDeveloperToastDismissal } from "../support/developer-ui.mjs";
import { hideDeveloperToasts } from "../support/developer-ui.mjs";
import type { Page } from "@playwright/test";
async function showTransientDeveloperToast(page: Page, shadow: boolean) {
@@ -15,38 +15,38 @@ async function showTransientDeveloperToast(page: Page, shadow: boolean) {
}, shadow);
}
async function openTransientDeveloperToast(page: Page) {
async function openHiddenDeveloperToast(page: Page) {
await page.setContent("<button>Continue</button>");
await showTransientDeveloperToast(page, false);
await installDeveloperToastDismissal(page);
await hideDeveloperToasts(page);
}
async function navigateWithDeveloperToastDismissal(page: Page) {
await installDeveloperToastDismissal(page);
async function navigateWithHiddenDeveloperToasts(page: Page) {
await hideDeveloperToasts(page);
await page.goto("data:text/html,<button>Continue</button>");
await showTransientDeveloperToast(page, true);
}
async function inspectLayoutWhileToastDisappears(page: Page) {
async function inspectLayoutWithHiddenToast(page: Page) {
const action = page.getByRole("button", { name: "Continue", exact: true });
const boxes = await Promise.all(Array.from({ length: 4 }, () => action.boundingBox()));
for (const box of boxes) expect(box).not.toBeNull();
await expect(page.locator("#error-toast").getByRole("button")).toHaveCount(0);
await expect(page.locator("#error-toast")).toBeHidden();
await action.click();
}
test("a disappearing developer toast does not stall concurrent layout checks", async ({ page }) => {
test("a hidden developer toast does not stall concurrent layout checks", async ({ page }) => {
test.setTimeout(10000);
await openTransientDeveloperToast(page);
await inspectLayoutWhileToastDisappears(page);
await openHiddenDeveloperToast(page);
await inspectLayoutWithHiddenToast(page);
});
test("developer toast dismissal survives navigation and observes Expo shadow-root updates", async ({
test("developer toast hiding survives navigation and Expo shadow-root updates", async ({
page,
}) => {
test.setTimeout(10000);
await navigateWithDeveloperToastDismissal(page);
await inspectLayoutWhileToastDisappears(page);
await navigateWithHiddenDeveloperToasts(page);
await inspectLayoutWithHiddenToast(page);
await page.evaluate(() => {
const root = document.getElementById("error-toast")!.shadowRoot!;
const replacement = document.createElement("button");
@@ -54,5 +54,5 @@ test("developer toast dismissal survives navigation and observes Expo shadow-roo
replacement.addEventListener("click", () => replacement.remove());
root.append(replacement);
});
await inspectLayoutWhileToastDisappears(page);
await inspectLayoutWithHiddenToast(page);
});