File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,10 +25,10 @@ export interface TestContext {
2525 * then used for all subsequent API calls, making them independent of cookie state.
2626 *
2727 * If the first attempt returns 401 (Octane hasn't fully committed the session yet),
28- * we reload the page to trigger a fresh CreateFreshApiToken and retry once .
28+ * we reload the page to trigger a fresh CreateFreshApiToken and retry.
2929 */
3030async function createApiToken ( page : Page ) : Promise < string > {
31- for ( let attempt = 0 ; attempt < 2 ; attempt ++ ) {
31+ for ( let attempt = 0 ; attempt < 3 ; attempt ++ ) {
3232 const result = await page . evaluate ( async ( baseUrl ) => {
3333 const xsrfCookie = document . cookie . split ( '; ' ) . find ( ( c ) => c . startsWith ( 'XSRF-TOKEN=' ) ) ;
3434 const xsrfToken = xsrfCookie
@@ -57,11 +57,12 @@ async function createApiToken(page: Page): Promise<string> {
5757 return result ;
5858 }
5959
60- // Reload to get a fresh laravel_token cookie and retry
61- await page . reload ( { waitUntil : 'domcontentloaded' } ) ;
60+ // Reload to get a fresh laravel_token cookie and retry.
61+ // networkidle gives Octane time to fully commit the session.
62+ await page . reload ( { waitUntil : 'networkidle' } ) ;
6263 }
6364
64- throw new Error ( 'Failed to create API token after retry ' ) ;
65+ throw new Error ( 'Failed to create API token after retries ' ) ;
6566}
6667
6768function buildAuthHeaders ( token : string , xsrfToken : string ) : Record < string , string > {
You can’t perform that action at this time.
0 commit comments