@@ -47,7 +47,7 @@ import '@objectstack/lint';
4747import '@testing-library/jest-dom/vitest' ;
4848import { describe , it , expect , vi , beforeEach } from 'vitest' ;
4949import React from 'react' ;
50- import { render , screen } from '@testing-library/react' ;
50+ import { act , render , screen } from '@testing-library/react' ;
5151import { MemoryRouter , Routes , Route , Navigate , useLocation } from 'react-router-dom' ;
5252
5353vi . mock ( '@object-ui/plugin-designer' , async ( importOriginal ) => ( {
@@ -85,11 +85,14 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
8585
8686/** The verdict AND its resolution — the axis this suite exists for. */
8787const viewer = vi . hoisted ( ( ) => ( { isAdmin : false , isResolved : true } ) ) ;
88+ // One function for every render, as `AuthProvider`'s `useCallback` gives
89+ // (objectstack#35981: the chrome waits for its answer, asked once).
90+ const getAuthConfig = vi . hoisted ( ( ) => async ( ) => ( { features : { } } ) ) ;
8891vi . mock ( '@object-ui/auth' , async ( importOriginal ) => ( {
8992 ...( await importOriginal < Record < string , unknown > > ( ) ) ,
9093 useAuth : ( ) => ( {
9194 user : { id : 'u_owner' , name : 'Owner' , email : 'owner@example.com' , role : 'user' } ,
92- getAuthConfig : async ( ) => ( { features : { } } ) ,
95+ getAuthConfig,
9396 activeOrganization : { id : 'org_1' , name : 'Acme' } ,
9497 } ) ,
9598 useWorkspaceAdminStatus : ( ) => ( { isAdmin : viewer . isAdmin , isResolved : viewer . isResolved } ) ,
@@ -242,13 +245,15 @@ describe('AppContent holds every admin-dependent decision until the verdict land
242245 // The cost boundary: resolution gates the surface, it does not delay a
243246 // viewer whose verdict is already in hand. objectstack#35981 — the chrome
244247 // also waits for the deployment flags (`/auth/config`), which its
245- // navigation gates read; the mock answers them at once, so the only wait
246- // left is that answer's promise, never the admin verdict.
248+ // navigation gates read; the mock answers them at once, so the one wait
249+ // admitted is that answer's promise: a single flush, then the chrome must
250+ // be there.
247251 metadataApps = [ { name : 'crm' , label : 'CRM' , navigation : [ ] } ] ;
248252 viewer . isAdmin = true ;
249253 viewer . isResolved = true ;
250254 renderConsoleAt ( '/apps/crm' ) ;
255+ await act ( async ( ) => { } ) ;
251256
252- expect ( await screen . findByTestId ( 'console-layout' ) ) . toHaveAttribute ( 'data-active-app' , 'crm' ) ;
257+ expect ( screen . getByTestId ( 'console-layout' ) ) . toHaveAttribute ( 'data-active-app' , 'crm' ) ;
253258 } ) ;
254259} ) ;
0 commit comments