@@ -40,18 +40,44 @@ test.describe('Doc Routing', () => {
4040 await expect ( page ) . toHaveURL ( / \/ d o c s \/ $ / ) ;
4141 } ) ;
4242
43- test ( 'checks 500 page' , async ( { page } ) => {
44- await page . waitForTimeout ( 300 ) ;
43+ test ( 'checks 500 refresh retries original document request' , async ( {
44+ page,
45+ browserName,
46+ } ) => {
47+ const [ docTitle ] = await createDoc ( page , 'doc-routing-500' , browserName , 1 ) ;
48+ await verifyDocName ( page , docTitle ) ;
49+
50+ const docId = page . url ( ) . split ( '/docs/' ) [ 1 ] ?. split ( '/' ) [ 0 ] ;
51+ let documentRequestCount = 0 ;
52+
53+ await page . route ( / \* * \/ d o c u m e n t s \/ \* * / , async ( route ) => {
54+ const request = route . request ( ) ;
55+ if (
56+ request . method ( ) . includes ( 'GET' ) &&
57+ docId &&
58+ request . url ( ) . includes ( `/documents/${ docId } /` )
59+ ) {
60+ documentRequestCount += 1 ;
61+ await route . fulfill ( {
62+ status : 500 ,
63+ json : { detail : 'Internal Server Error' } ,
64+ } ) ;
65+ } else {
66+ await route . continue ( ) ;
67+ }
68+ } ) ;
69+
70+ await page . reload ( ) ;
4571
46- await page . goto ( '/ 500' ) ;
72+ await expect ( page ) . toHaveURL ( / \/ 5 0 0 \/ ? \? f r o m = / , { timeout : 15000 } ) ;
4773
4874 const refreshButton = page . getByRole ( 'button' , { name : 'Refresh page' } ) ;
4975 await expect ( refreshButton ) . toBeVisible ( ) ;
76+ await refreshButton . click ( ) ;
5077
51- const homeLink = page . getByRole ( 'link' , { name : 'Home' , exact : true } ) ;
52- await expect ( homeLink ) . toBeVisible ( ) ;
53- await homeLink . click ( ) ;
54- await expect ( page ) . toHaveURL ( / \/ $ / ) ;
78+ await expect
79+ . poll ( ( ) => documentRequestCount , { timeout : 10000 } )
80+ . toBeGreaterThan ( 1 ) ;
5581 } ) ;
5682
5783 test ( 'checks 404 on docs/[id] page' , async ( { page } ) => {
0 commit comments