Skip to content

Commit

Permalink
Wait for ads connection response.
Browse files Browse the repository at this point in the history
  • Loading branch information
asvinb committed Sep 18, 2024
1 parent 9081d20 commit 9a612d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/e2e/specs/setup-mc/step-4-complete-campaign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,10 @@ test.describe( 'Complete your campaign', () => {
);

test.describe( 'Free Ad Credit', () => {
test.beforeAll( async () => {
await setupAdsAccountPage.mockAdsAccountConnected();
} );

test( 'should not see the Free Ad Credit section if the account is not eligible', async () => {
await setupAdsAccountPage.mockAdsAccountConnected();
await completeCampaign.goto();
await setupAdsAccountPage.awaitAdsConnectionResponse();

// Check we are on the correct page.
await expect(
Expand All @@ -383,6 +381,7 @@ test.describe( 'Complete your campaign', () => {
created_timestamp: Math.floor( Date.now() / 1000 ),
} );
await completeCampaign.goto();
await setupAdsAccountPage.awaitAdsConnectionResponse();

await expect(
page.getByText(
Expand Down
14 changes: 14 additions & 0 deletions tests/e2e/utils/pages/setup-ads/setup-ads-accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,18 @@ export default class SetupAdsAccount extends MockRequests {
const button = this.getConnectDifferentAccountButton();
await button.click();
}

/**
* Await the response for ads connection.
*
* @return {Promise<import('@playwright/test').Response>} The response.
*/
async awaitAdsConnectionResponse() {
return this.page.waitForResponse( ( response ) => {
return (
response.url().includes( '/gla/ads/connection' ) &&
response.status() === 200
);
} );
}
}

0 comments on commit 9a612d3

Please sign in to comment.