@@ -65,19 +65,26 @@ function appDefaultProfileName(permissions: unknown): string | undefined {
6565 return undefined ;
6666}
6767
68+ // The first createStandaloneStack call cold-loads heavy deps (objectql,
69+ // metadata, driver-memory) via dynamic import — on a cold CI worker that can
70+ // exceed vitest's default 5s test timeout. Do the one-time boot in beforeAll
71+ // (with a generous timeout) and have the assertion cases read the result.
72+ const BOOT_TIMEOUT = 60_000 ;
73+
6874describe ( 'createStandaloneStack — surfaces app RBAC from the artifact (ADR-0056 D7)' , ( ) => {
6975 let dir : string ;
7076 let artifactPath : string ;
77+ let result : Awaited < ReturnType < typeof createStandaloneStack > > ;
7178
72- beforeAll ( ( ) => {
79+ beforeAll ( async ( ) => {
7380 dir = mkdtempSync ( join ( tmpdir ( ) , 'os-standalone-rbac-' ) ) ;
7481 artifactPath = join ( dir , 'objectstack.json' ) ;
7582 writeFileSync ( artifactPath , JSON . stringify ( ARTIFACT ) , 'utf-8' ) ;
76- } ) ;
83+ result = await createStandaloneStack ( { artifactPath, databaseUrl : 'memory://standalone-rbac' } ) ;
84+ } , BOOT_TIMEOUT ) ;
7785 afterAll ( ( ) => { try { rmSync ( dir , { recursive : true , force : true } ) ; } catch { /* noop */ } } ) ;
7886
79- it ( 'surfaces permissions[] (with isDefault profile + readScope) at the top level' , async ( ) => {
80- const result = await createStandaloneStack ( { artifactPath, databaseUrl : 'memory://standalone-rbac' } ) ;
87+ it ( 'surfaces permissions[] (with isDefault profile + readScope) at the top level' , ( ) => {
8188 expect ( Array . isArray ( result . permissions ) ) . toBe ( true ) ;
8289 expect ( result . permissions ! . map ( ( p : any ) => p . name ) . sort ( ) ) . toEqual ( [ 'app_contributor' , 'app_member_default' ] ) ;
8390 const def = result . permissions ! . find ( ( p : any ) => p . name === 'app_member_default' ) ;
@@ -86,34 +93,31 @@ describe('createStandaloneStack — surfaces app RBAC from the artifact (ADR-005
8693 expect ( def . objects . note . readScope ) . toBe ( 'unit_and_below' ) ;
8794 } ) ;
8895
89- it ( 'surfaces roles[] at the top level' , async ( ) => {
90- const result = await createStandaloneStack ( { artifactPath, databaseUrl : 'memory://standalone-rbac' } ) ;
96+ it ( 'surfaces roles[] at the top level' , ( ) => {
9197 expect ( Array . isArray ( result . roles ) ) . toBe ( true ) ;
9298 expect ( result . roles ! . map ( ( r : any ) => r . name ) . sort ( ) ) . toEqual ( [ 'contributor' , 'manager' ] ) ;
9399 } ) ;
94100
95- it ( 'still surfaces objects/requires/manifest (no regression)' , async ( ) => {
96- const result = await createStandaloneStack ( { artifactPath, databaseUrl : 'memory://standalone-rbac' } ) ;
101+ it ( 'still surfaces objects/requires/manifest (no regression)' , ( ) => {
97102 expect ( result . requires ) . toEqual ( [ 'auth' ] ) ;
98103 expect ( result . objects ! . map ( ( o : any ) => o . name ) ) . toEqual ( [ 'note' ] ) ;
99104 expect ( result . manifest ?. id ) . toBe ( 'com.test.scope-app' ) ;
100105 } ) ;
101106
102- it ( 'the surfaced config drives appDefaultProfileName → the app profile (the exact CLI wiring)' , async ( ) => {
107+ it ( 'the surfaced config drives appDefaultProfileName → the app profile (the exact CLI wiring)' , ( ) => {
103108 // Reproduce serve.ts: `config = { ...originalConfig, ...standaloneStack }`,
104109 // then `appDefaultProfileName(config.permissions)` → SecurityPlugin fallback.
105- const standaloneStack = await createStandaloneStack ( { artifactPath, databaseUrl : 'memory://standalone-rbac' } ) ;
106- const config : any = { ...{ } , ...standaloneStack } ;
110+ const config : any = { ...{ } , ...result } ;
107111 expect ( appDefaultProfileName ( config . permissions ) ) . toBe ( 'app_member_default' ) ;
108112 } ) ;
109113
110114 it ( 'createDefaultHostConfig (the actual serve artifact-fallback) surfaces the same' , async ( ) => {
111- const result = await createDefaultHostConfig ( {
115+ const r = await createDefaultHostConfig ( {
112116 requireArtifact : true ,
113117 artifactPath,
114118 databaseUrl : 'memory://standalone-rbac' ,
115119 } ) ;
116- expect ( appDefaultProfileName ( result . permissions ) ) . toBe ( 'app_member_default' ) ;
117- expect ( result . roles ! . map ( ( r : any ) => r . name ) . sort ( ) ) . toEqual ( [ 'contributor' , 'manager' ] ) ;
118- } ) ;
120+ expect ( appDefaultProfileName ( r . permissions ) ) . toBe ( 'app_member_default' ) ;
121+ expect ( r . roles ! . map ( ( x : any ) => x . name ) . sort ( ) ) . toEqual ( [ 'contributor' , 'manager' ] ) ;
122+ } , BOOT_TIMEOUT ) ;
119123} ) ;
0 commit comments