Add toast service DOM test

This commit is contained in:
thePR0M3TH3AN committed 2026-01-19 22:08:23 -05:00
1 parent eee749acfa
commit 19a01062f0
1 file changed
+37
+37
View File
@@ -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);
});
});