test(e2e): hide the developer error toast instead of clicking it away

The locator handler that dismissed #error-toast could match a toast that closed before its
click, then wait on it until the test timed out (agent-timeline-resume.spec.ts:45 failed every
attempt on this branch). Hiding the toast with CSS keeps it off app actions with no race.
This commit is contained in:
Mohamed Boudra
2026-10-20 09:28:42 +02:00
parent 81ee20162f
commit aaca23af13
2 changed files with 9 additions and 8 deletions
+7 -6
View File
@@ -1,10 +1,11 @@
/** @param {import('@playwright/test').Page} page */
export async function installDeveloperToastDismissal(page) {
export async function hideDeveloperToasts(page) {
// Developer chrome must not cover app actions or move the test's pointer/focus.
// Console errors remain in the runner's logs.
const dismiss = page.locator("#error-toast").getByRole("button", { name: "", exact: true });
await page.addLocatorHandler(dismiss, () => dismiss.dispatchEvent("click"), {
// A new logged error can replace the toast before the old one disappears.
noWaitAfter: true,
// Console errors remain in the runner's logs. Hiding the toast, instead of clicking it away,
// leaves no race with a toast that closes or is replaced between matching and clicking.
await page.addInitScript(() => {
const style = document.createElement("style");
style.textContent = "#error-toast { display: none !important; }";
document.addEventListener("DOMContentLoaded", () => document.head.append(style));
});
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { test as base, expect, type Page } from "@playwright/test";
import { installDeveloperToastDismissal } from "./developer-ui.mjs";
import { hideDeveloperToasts } from "./developer-ui.mjs";
import { startOutdatedDaemon, type OutdatedDaemon } from "./helpers/daemon-update";
import { startE2EWorker } from "./helpers/e2e-worker";
import { getE2EDaemonPort } from "./helpers/daemon-port";
@@ -131,7 +131,7 @@ const test = daemonTest.extend<{
await ws.close({ code: 1008, reason: "Blocked connection to localhost:6767 during e2e." });
});
await installDeveloperToastDismissal(page);
await hideDeveloperToasts(page);
const entries: string[] = [];