1- import { EnvironmentId , ThreadId } from "@t3tools/contracts" ;
1+ import { EnvironmentId , ThreadId , type AuthEnvironmentScope } from "@t3tools/contracts" ;
22import { renderToStaticMarkup } from "react-dom/server" ;
33import { beforeEach , describe , expect , it , vi } from "vite-plus/test" ;
44
@@ -20,10 +20,19 @@ vi.mock("../assets/assetUrls", () => ({
2020vi . mock ( "../hooks/useTheme" , ( ) => ( { useTheme : ( ) => ( { resolvedTheme : "dark" } ) } ) ) ;
2121vi . mock ( "../state/use-atom-query-runner" , ( ) => ( { useAtomQueryRunner : ( ) => vi . fn ( ) } ) ) ;
2222vi . 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+ } ) ;
2736vi . mock ( "../state/entities" , ( ) => ( {
2837 readThreadShell : ( ) => null ,
2938 useProjects : ( ) => [ ] ,
0 commit comments