mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-30 01:12:39 +00:00
Add toast service DOM test
This commit is contained in:
1 parent
eee749acfa
commit
19a01062f0
1 file changed
+37
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user