Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProviderStatusBanner.test.tsx

66 lines2.1 KB

1import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
2import { renderToStaticMarkup } from "react-dom/server";
3import { describe, expect, it } from "vite-plus/test";
4​
5import {
6 getProviderStatusBannerKey,
7 ProviderStatusBanner,
8 shouldShowProviderStatusBanner,
9} from "./ProviderStatusBanner";
10​
11function warningProvider(): ServerProvider {
12 return {
13 instanceId: ProviderInstanceId.make("codex"),
14 driver: ProviderDriverKind.make("codex"),
15 displayName: "Codex",
16 enabled: true,
17 installed: true,
18 version: "1.0.0",
19 status: "warning",
20 auth: { status: "authenticated" },
21 checkedAt: "2026-07-23T12:00:00.000Z",
22 message: "Provider is temporarily degraded.",
23 models: [],
24 slashCommands: [],
25 skills: [],
26 };
28​
29describe("ProviderStatusBanner", () => {
30 it("stays hidden after its current warning is dismissed", () => {
31 const status = warningProvider();
32​
33 expect(shouldShowProviderStatusBanner(status, null)).toBe(true);
34 expect(shouldShowProviderStatusBanner(status, getProviderStatusBannerKey(status))).toBe(false);
35 });
36​
37 it("renders an accessible dismiss control for provider warnings", () => {
38 const markup = renderToStaticMarkup(
39 <ProviderStatusBanner status={warningProvider()} onDismiss={() => {}} />,
40 );
41​
42 expect(markup).toContain('role="alert"');
43 expect(markup).toContain('aria-label="Dismiss Codex provider warning"');
44 expect(markup).toContain("absolute top-2 right-2");
45 });
46​
47 it("renders on a glass surface so the timeline never reads through the banner", () => {
48 const markup = renderToStaticMarkup(
49 <ProviderStatusBanner status={warningProvider()} onDismiss={() => {}} />,
50 );
51​
52 expect(markup).toContain("alert-glass");
53 expect(markup).toContain('data-variant="warning"');
54 });
55​
56 it("labels error dismiss controls with the correct severity", () => {
57 const markup = renderToStaticMarkup(
58 <ProviderStatusBanner
59 status={{ ...warningProvider(), status: "error" }}
60 onDismiss={() => {}}
61 />,
62 );
63​
64 expect(markup).toContain('aria-label="Dismiss Codex provider error"');
65 });
66});