From 19a01062f0f066b7748c5bfdc65dc41bf42e3a98 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 19 Jan 2026 22:08:23 -0500 Subject: [PATCH] Add toast service DOM test --- tests/e2e/toast-service.spec.ts | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/e2e/toast-service.spec.ts diff --git a/tests/e2e/toast-service.spec.ts b/tests/e2e/toast-service.spec.ts new file mode 100644 index 00000000..9d7ad051 --- /dev/null +++ b/tests/e2e/toast-service.spec.ts @@ -0,0 +1,37 @@ +import { expect, test } from "@playwright/test"; + +test.describe("toast service in full DOM", () => { + test("renders, expires, and dismisses toasts", async ({ page }) => { + await page.emulateMedia({ reducedMotion: "reduce" }); + await page.goto("/docs/kitchen-sink.html", { waitUntil: "networkidle" }); + + await page.addScriptTag({ + type: "module", + content: ` + import { createBeaconToast } from "/torrent/ui/toastService.js"; + window.__toast = createBeaconToast(document); + `, + }); + + await page.evaluate(() => { + window.__toast?.success("Sticky toast", { sticky: true }); + window.__toast?.info("Transient toast", { duration: 800 }); + }); + + const container = page.locator("#beacon-toast-container"); + await expect(container).toBeVisible(); + + const toastNodes = container.locator("div[role='status']"); + expect(await toastNodes.count()).toBeGreaterThanOrEqual(2); + + await page.waitForTimeout(900); + + await expect(container.locator("div[role='status']", { hasText: "Transient toast" })) + .toHaveCount(0); + await expect(container.locator("div[role='status']", { hasText: "Sticky toast" })) + .toHaveCount(1); + + await container.locator("button.notification-dismiss").first().click(); + await expect(container.locator("div[role='status']")).toHaveCount(0); + }); +});