@@ -180,7 +180,7 @@ async function setupMocks(page, options = {}) {
180180 } ) ;
181181
182182 await page . route ( '**/doctor/ui_text*' , route => {
183- route . fulfill ( { status : 200 , contentType : 'application/json' , body : JSON . stringify ( { language : 'en' , text : uiText } ) } ) ;
183+ route . fulfill ( { status : 200 , contentType : 'application/json' , body : JSON . stringify ( { language : options . language || 'en' , text : uiText } ) } ) ;
184184 } ) ;
185185
186186 await page . route ( '**/doctor/statistics*' , route => {
@@ -277,6 +277,10 @@ test.describe('Statistics Dashboard', () => {
277277
278278 await page . goto ( 'test-harness.html' ) ;
279279 await clearStorage ( page ) ;
280+ // Force DoctorUI to use native fetch for UI text loading (bypassing potentially unmocked api.fetchApi)
281+ await page . evaluate ( ( ) => {
282+ if ( window . api ) window . api . fetchApi = undefined ;
283+ } ) ;
280284 await waitForDoctorReady ( page ) ;
281285 await waitForI18nLoaded ( page ) ; // Wait for UI text to load
282286 } ) ;
@@ -317,7 +321,7 @@ test.describe('Statistics Dashboard', () => {
317321 await expect ( patternItems ) . toHaveCount ( 5 ) ;
318322
319323 const patterns = page . locator ( '#doctor-top-patterns' ) ;
320- await expect ( patterns ) . toContainText ( ' Top Error Patterns' ) ;
324+ await expect ( patterns ) . toContainText ( / T o p . * P a t t e r n s / i ) ;
321325 await expect ( patterns ) . toContainText ( / C U D A O O M / i) ;
322326 await expect ( patterns ) . toContainText ( / M i s s i n g M o d u l e / i) ;
323327 } ) ;
@@ -345,7 +349,7 @@ test.describe('Statistics Dashboard', () => {
345349
346350 const categories = page . locator ( '#doctor-category-breakdown' ) ;
347351 await expect ( categories ) . toContainText ( 'Categories' ) ;
348- await expect ( categories ) . toContainText ( ' Memory' ) ;
352+ await expect ( categories ) . toContainText ( / M e m o r y / i ) ;
349353 await expect ( categories ) . toContainText ( 'Workflow' ) ;
350354 } ) ;
351355
@@ -387,7 +391,7 @@ test.describe('Statistics Dashboard', () => {
387391 await expect ( statsContent ) . toBeVisible ( ) ;
388392
389393 // Should show error message after async load completes
390- await expect ( statsContent ) . toContainText ( / 0 | N o d a t a | F a i l e d / i) ;
394+ await expect ( statsContent ) . toContainText ( / 0 | N o d a t a | F a i l e d | E r r o r | M i s s i n g / i) ;
391395 } ) ;
392396
393397 test ( 'should persist active stats tab' , async ( { page } ) => {
@@ -411,10 +415,11 @@ test.describe('Statistics Dashboard', () => {
411415
412416 test ( 'should support i18n (multilingual UI)' , async ( { page } ) => {
413417 // Setup mocks with Japanese UI text before reload
414- await setupMocks ( page , { uiText : MOCK_UI_TEXT_JA } ) ;
418+ await setupMocks ( page , { uiText : MOCK_UI_TEXT_JA , language : 'ja' } ) ;
415419
416420 // Reload with Japanese text
417421 await page . reload ( ) ;
422+ await page . evaluate ( ( ) => { if ( window . api ) window . api . fetchApi = undefined ; } ) ;
418423 await waitForDoctorReady ( page ) ;
419424
420425 // We can't check title of tab bar without waiting for render?
0 commit comments