Skip to content

Commit

Permalink
retry API discovery along with login
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Jun 5, 2024
1 parent 6d2b1c3 commit 66092fd
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/e2e-test-utils-playwright/src/request-utils/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import * as fs from 'fs/promises';
import { dirname } from 'path';
import { expect } from '@playwright/test';
import type { APIRequestContext } from '@playwright/test';

/**
Expand Down Expand Up @@ -39,10 +40,23 @@ async function getAPIRootURL( request: APIRequestContext ) {
}

async function setupRest( this: RequestUtils ): Promise< StorageState > {
const [ nonce, rootURL ] = await Promise.all( [
this.login(),
getAPIRootURL( this.request ),
] );
let nonce = '';
let rootURL = '';

await expect
.poll(
async () => {
[ nonce, rootURL ] = await Promise.all( [
this.login(),
getAPIRootURL( this.request ),
] );
},
{
message: 'Failed to setup REST API.',
timeout: 60_000, // 1 minute.
}
)
.not.toThrow();

const { cookies } = await this.request.storageState();

Expand Down

0 comments on commit 66092fd

Please sign in to comment.