Skip to content

Commit 97f4bce

Browse files
committed
bump retries and wait for networkidle in retry
1 parent 6962b66 commit 97f4bce

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

e2e/utils/api.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff 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
*/
3030
async 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

6768
function buildAuthHeaders(token: string, xsrfToken: string): Record<string, string> {

0 commit comments

Comments
 (0)