Open History to see the last commit
1import { InfoIcon } from "lucide-react";
2import { expect, it, vi } from "vite-plus/test";
3import { userEvent } from "vite-plus/test/browser";
4
5import { render } from "../../../test/render";
6import { ComposerBannerStack, type ComposerBannerStackItem } from "./ComposerBannerStack";
7
8it("commits a dismissal when the thread switches during the exit transition", async () => {
9 const onDismiss = vi.fn();
10 const item: ComposerBannerStackItem = {
11 id: "notice",
12 variant: "info",
13 icon: <InfoIcon />,
14 title: "Thread A notice",
15 dismissLabel: "Dismiss notice",
16 onDismiss,
17 };
18 await using screen = await render(<ComposerBannerStack key="thread-a" items={[item]} />);
19
20 await userEvent.click(screen.getByRole("button", { name: "Dismiss notice" }));
21 // The composer keys the stack by thread, so switching threads remounts it mid-exit.
22 await screen.rerender(<ComposerBannerStack key="thread-b" items={[]} />);
23
24 await vi.waitFor(() => expect(onDismiss).toHaveBeenCalledTimes(1));
25});