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