@@ -94,7 +94,8 @@ test('workspaces stay unavailable without a collaboration endpoint', async ({ pa
9494
9595 await expect ( page . locator ( 'a[href="/app/workspaces"]' ) ) . toHaveCount ( 0 ) ;
9696 await page . goto ( '/app/workspaces' , { waitUntil : 'domcontentloaded' } ) ;
97- await expect ( page . getByRole ( 'heading' , { name : '404' } ) ) . toBeVisible ( ) ;
97+ await expect ( page . getByText ( '404' , { exact : true } ) ) . toBeVisible ( ) ;
98+ await expect ( page . getByRole ( 'heading' , { level : 1 , name : 'Page not found' } ) ) . toBeVisible ( ) ;
9899} ) ;
99100
100101test ( 'a delayed public route keeps the main landmark' , async ( { page } ) => {
@@ -177,7 +178,9 @@ test('a failed route chunk recovers after the offered reload', async ({ page })
177178 let attempts = 0 ;
178179 await page . route ( '**/src/pages/AttackPage.tsx*' , async ( route ) => {
179180 attempts += 1 ;
180- if ( attempts === 1 ) {
181+ // The first failure reloads automatically. Fail that retry too, so the
182+ // boundary offers its manual Reload action instead of recovering first.
183+ if ( attempts <= 2 ) {
181184 await route . fulfill ( { status : 503 , contentType : 'text/plain' , body : 'chunk unavailable' } ) ;
182185 return ;
183186 }
@@ -190,8 +193,9 @@ test('a failed route chunk recovers after the offered reload', async ({ page })
190193 await homeToolLink ( page , 'attack' ) . click ( ) ;
191194
192195 await expect ( page . getByRole ( 'heading' , { name : 'Unable to load this page' } ) ) . toBeVisible ( ) ;
196+ expect ( attempts ) . toBe ( 2 ) ;
193197 await page . getByRole ( 'button' , { name : 'Reload' } ) . click ( ) ;
194- await expect . poll ( ( ) => attempts ) . toBe ( 2 ) ;
198+ await expect . poll ( ( ) => attempts ) . toBe ( 3 ) ;
195199 await waitForContent ( page , attackContent ) ;
196200 await expect ( page . getByRole ( 'banner' ) ) . toBeVisible ( ) ;
197201} ) ;
@@ -365,14 +369,23 @@ test('subscription reads stay cached across sibling tool routes', async ({ page
365369 await route . fulfill ( { json : { announcements : [ ] } } ) ;
366370 return ;
367371 }
372+ if ( url . pathname . endsWith ( '/rest/v1/rpc/ai_usage_today' ) ) {
373+ subscriptionRequests . push ( 'ai_usage_today' ) ;
374+ await route . fulfill ( { json : 0 } ) ;
375+ return ;
376+ }
368377 if ( url . pathname . includes ( '/rest/v1/' ) ) {
369378 const select = url . searchParams . get ( 'select' ) ?? '' ;
370379 if ( url . pathname . endsWith ( '/user_settings' ) && select . includes ( 'subscription_tier' ) ) {
371380 subscriptionRequests . push ( 'user_settings' ) ;
372381 } else if ( url . pathname . endsWith ( '/subscriptions' ) ) {
373382 subscriptionRequests . push ( 'subscriptions' ) ;
374- } else if ( url . pathname . endsWith ( '/ai_requests' ) ) {
375- subscriptionRequests . push ( 'ai_requests' ) ;
383+ }
384+ // An empty single-row read is a PostgREST error, not a truthy array.
385+ // Otherwise settings hydration treats [] as an account and reads billing.
386+ if ( ( route . request ( ) . headers ( ) . accept ?? '' ) . includes ( 'vnd.pgrst.object' ) ) {
387+ await route . fulfill ( { status : 406 , json : { code : 'PGRST116' , message : 'No rows returned' } } ) ;
388+ return ;
376389 }
377390 await route . fulfill ( {
378391 status : 200 ,
@@ -387,13 +400,13 @@ test('subscription reads stay cached across sibling tool routes', async ({ page
387400
388401 await page . goto ( '/app/generate' ) ;
389402 await waitForContent ( page , { selector : 'main h1' , text : 'Generate' } ) ;
390- await expect . poll ( ( ) => subscriptionRequests . filter ( ( name ) => name === 'ai_requests ' ) . length ) . toBe ( 1 ) ;
403+ await expect . poll ( ( ) => subscriptionRequests . filter ( ( name ) => name === 'ai_usage_today ' ) . length ) . toBe ( 1 ) ;
391404
392405 await openHome ( page ) ;
393406 await homeToolLink ( page , 'attack' ) . click ( ) ;
394407 await waitForContent ( page , attackContent ) ;
395408 // eslint-disable-next-line no-restricted-properties -- observation window: no extra subscription request may follow.
396409 await page . waitForTimeout ( 100 ) ;
397410
398- expect ( subscriptionRequests ) . toEqual ( [ 'user_settings' , 'ai_requests ' ] ) ;
411+ expect ( subscriptionRequests ) . toEqual ( [ 'user_settings' , 'ai_usage_today ' ] ) ;
399412} ) ;
0 commit comments