Skip to content

Commit

Permalink
Better E2E tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
asvinb committed Nov 6, 2024
1 parent 801c6c9 commit d922470
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
33 changes: 14 additions & 19 deletions tests/e2e/specs/setup-mc/step-1-accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,6 @@ test.describe( 'Set up accounts', () => {
'Google Ads ID: 12345'
);
} );

test( 'should see the conversion action notice', async () => {
const googleAccountCard =
setUpAccountsPage.getGoogleAccountCard();
await expect(
googleAccountCard.getByText(
'Google Ads conversion measurement has been set up for your store.',
{
exact: true,
}
)
).toBeVisible();
} );
} );
} );

Expand Down Expand Up @@ -408,17 +395,25 @@ test.describe( 'Set up accounts', () => {
await popupPage.waitForLoadState();
const url = popupPage.url();
expect( url ).toMatch( /^https:\/\/example\.com(\/|\?|$)/ );
await popupPage.close();
} );

test( 'should see the merchant center id once account has been claimed', async () => {
test( 'should see conversion action notice', async () => {
await setUpAccountsPage.mockAdsStatusClaimed();
await setUpAccountsPage.mockAdsAccountConnected();
const statusResponse =
setUpAccountsPage.registerAdsAccountStatusResponse();
await setUpAccountsPage.page.dispatchEvent( 'body', 'focus' );
await statusResponse;

await setUpAccountsPage.goto();
const googleAccountCard = setUpAccountsPage.getGoogleAccountCard();
await expect( googleAccountCard ).toContainText(
'Google Ads ID: 12345'
);
await expect(
googleAccountCard.getByText(
'Google Ads conversion measurement has been set up for your store.',
{
exact: true,
}
)
).toBeVisible();
} );
} );

Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/utils/pages/setup-mc/step-1-set-up-accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,17 @@ export default class SetUpAccountsPage extends MockRequests {
getTermsCheckbox() {
return this.page.getByLabel( /I accept the terms and conditions/ );
}

/**
* Register the responses when checking for account-status.
*
* @return {Promise<import('@playwright/test').Response>} The response.
*/
registerAdsAccountStatusResponse() {
return this.page.waitForResponse(
( response ) =>
response.url().includes( '/gla/ads/account-status' ) &&
response.status() === 200
);
}
}

0 comments on commit d922470

Please sign in to comment.