The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import { page } from "vite-plus/test/browser"; |
| 3 | |
| 4 | import { render } from "../../../test/render"; |
| 5 | import { AnchoredToastProvider, ToastProvider, toastManager } from "./toast"; |
| 6 | |
| 7 | describe("toastManager", () => { |
| 8 | it("shows a toast added before any provider mounted", async () => { |
| 9 | toastManager.add({ type: "info", title: "Raised before the first render" }); |
| 10 | |
| 11 | await using _screen = await render(<ToastProvider>{null}</ToastProvider>); |
| 12 | |
| 13 | await expect.element(page.getByText("Raised before the first render")).toBeVisible(); |
| 14 | }); |
| 15 | |
| 16 | it("exposes one Notifications landmark when both toast providers mount", async () => { |
| 17 | await using _screen = await render( |
| 18 | <ToastProvider> |
| 19 | <AnchoredToastProvider>{null}</AnchoredToastProvider> |
| 20 | </ToastProvider>, |
| 21 | ); |
| 22 | |
| 23 | const notifications = page.getByRole("region", { name: "Notifications" }); |
| 24 | await expect.element(notifications.first()).toBeInTheDocument(); |
| 25 | expect( |
| 26 | notifications.elements(), |
| 27 | "only the corner toast viewport should be a Notifications landmark", |
| 28 | ).toHaveLength(1); |
| 29 | await expect.element(notifications).toHaveAttribute("data-slot", "toast-viewport"); |
| 30 | |
| 31 | const anchoredViewport = document.querySelector("[data-slot=toast-viewport-anchored]"); |
| 32 | expect(anchoredViewport).toHaveAttribute("aria-live", "polite"); |
| 33 | }); |
| 34 | }); |