From d922470f0a70cbf9037050436572609c0d325d9a Mon Sep 17 00:00:00 2001 From: asvinb Date: Wed, 6 Nov 2024 20:58:41 +0400 Subject: [PATCH] Better E2E tests. --- .../specs/setup-mc/step-1-accounts.test.js | 33 ++++++++----------- .../pages/setup-mc/step-1-set-up-accounts.js | 13 ++++++++ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/tests/e2e/specs/setup-mc/step-1-accounts.test.js b/tests/e2e/specs/setup-mc/step-1-accounts.test.js index 641bfce680..139ff1379d 100644 --- a/tests/e2e/specs/setup-mc/step-1-accounts.test.js +++ b/tests/e2e/specs/setup-mc/step-1-accounts.test.js @@ -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(); - } ); } ); } ); @@ -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(); } ); } ); diff --git a/tests/e2e/utils/pages/setup-mc/step-1-set-up-accounts.js b/tests/e2e/utils/pages/setup-mc/step-1-set-up-accounts.js index cf50408e4a..57d3e6b9c6 100644 --- a/tests/e2e/utils/pages/setup-mc/step-1-set-up-accounts.js +++ b/tests/e2e/utils/pages/setup-mc/step-1-set-up-accounts.js @@ -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} The response. + */ + registerAdsAccountStatusResponse() { + return this.page.waitForResponse( + ( response ) => + response.url().includes( '/gla/ads/account-status' ) && + response.status() === 200 + ); + } }