Skip to content

Commit c93d49b

Browse files
test(web): provide grants in legacy Markdown fixtures
1 parent 703bd63 commit c93d49b

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎apps/web/src/components/ChatMarkdown.test.tsx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EnvironmentId } from "@t3tools/contracts";
1+
import { EnvironmentId, type AuthEnvironmentScope } from "@t3tools/contracts";
22
import { act, type ComponentProps, type ReactNode } from "react";
33
import { renderToStaticMarkup } from "react-dom/server";
44
import { create, type ReactTestRenderer } from "react-test-renderer";
@@ -35,10 +35,19 @@ vi.mock("./ui/tooltip", async () => {
3535
});
3636
vi.mock("../state/use-atom-query-runner", () => ({ useAtomQueryRunner: () => vi.fn() }));
3737
vi.mock("../state/use-atom-command", () => ({ useAtomCommand: () => vi.fn() }));
38-
vi.mock("../state/session", async (importOriginal) => ({
39-
...(await importOriginal<typeof import("../state/session")>()),
40-
usePreparedConnection: () => ({ _tag: "Loading" }),
41-
}));
38+
vi.mock("../state/session", async (importOriginal) => {
39+
const actual = await importOriginal<typeof import("../state/session")>();
40+
const { AuthStandardClientScopes } = await import("@t3tools/contracts");
41+
const grantedScopes = new Set<AuthEnvironmentScope>(AuthStandardClientScopes);
42+
const hasScope = (environmentId: EnvironmentId | null, scope: AuthEnvironmentScope) =>
43+
environmentId !== null && grantedScopes.has(scope);
44+
return {
45+
...actual,
46+
useEnvironmentScope: hasScope,
47+
readEnvironmentScope: hasScope,
48+
usePreparedConnection: () => ({ _tag: "Loading" }),
49+
};
50+
});
4251
vi.mock("../state/entities", () => ({
4352
readThreadShell: () => null,
4453
useProjects: () => [],

‎apps/web/src/components/ChatMarkdown.workspace-images.test.tsx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
1+
import { EnvironmentId, ThreadId, type AuthEnvironmentScope } from "@t3tools/contracts";
22
import { renderToStaticMarkup } from "react-dom/server";
33
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
44

@@ -20,10 +20,19 @@ vi.mock("../assets/assetUrls", () => ({
2020
vi.mock("../hooks/useTheme", () => ({ useTheme: () => ({ resolvedTheme: "dark" }) }));
2121
vi.mock("../state/use-atom-query-runner", () => ({ useAtomQueryRunner: () => vi.fn() }));
2222
vi.mock("../state/use-atom-command", () => ({ useAtomCommand: () => vi.fn() }));
23-
vi.mock("../state/session", async (importOriginal) => ({
24-
...(await importOriginal<typeof import("../state/session")>()),
25-
usePreparedConnection: () => ({ _tag: "Loading" }),
26-
}));
23+
vi.mock("../state/session", async (importOriginal) => {
24+
const actual = await importOriginal<typeof import("../state/session")>();
25+
const { AuthStandardClientScopes } = await import("@t3tools/contracts");
26+
const grantedScopes = new Set<AuthEnvironmentScope>(AuthStandardClientScopes);
27+
const hasScope = (environmentId: EnvironmentId | null, scope: AuthEnvironmentScope) =>
28+
environmentId !== null && grantedScopes.has(scope);
29+
return {
30+
...actual,
31+
useEnvironmentScope: hasScope,
32+
readEnvironmentScope: hasScope,
33+
usePreparedConnection: () => ({ _tag: "Loading" }),
34+
};
35+
});
2736
vi.mock("../state/entities", () => ({
2837
readThreadShell: () => null,
2938
useProjects: () => [],

0 commit comments

Comments
 (0)