Skip to content

Commit

Permalink
Improve E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joemcgill committed Nov 14, 2024
1 parent e55f65e commit ddbb900
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
33 changes: 24 additions & 9 deletions tests/e2e/specs/setup-mc/step-1-accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,7 @@ test.describe( 'Set up accounts', () => {
await setUpAccountsPage.mockAdsAccountDisconnected();
await setUpAccountsPage.fulfillAdsAccounts( ADS_ACCOUNTS );
await setUpAccountsPage.mockMCConnected();
await setUpAccountsPage.mockContactInformation( {
wcAddressErrors: [],
isMCAddressDifferent: false,
} );
await setUpAccountsPage.mockContactInformation();

await setUpAccountsPage.goto();
} );
Expand Down Expand Up @@ -885,14 +882,11 @@ test.describe( 'Set up accounts', () => {
} );
} );

test.describe( 'When all accounts are connected and store address is synced', async () => {
test.describe( 'When all accounts are connected and store address is fulfilled', async () => {
test.beforeAll( async () => {
await setUpAccountsPage.mockAdsAccountConnected();
await setUpAccountsPage.mockMCConnected();
await setUpAccountsPage.mockContactInformation( {
wcAddressErrors: [],
isMCAddressDifferent: false,
} );
await setUpAccountsPage.mockContactInformation( {} );

await setUpAccountsPage.goto();
} );
Expand All @@ -903,6 +897,27 @@ test.describe( 'Set up accounts', () => {

await expect( continueButton ).toBeEnabled();
} );

test( 'should sync the address and show the heading of the next step when clicked', async () => {
const requestPromise =
setUpAccountsPage.registerContactInformationSyncRequest();

await setUpAccountsPage.clickContinueButton();

const request = await requestPromise;
const response = await request.response();
const responseBody = await response.json();

expect( response.status() ).toBe( 200 );
expect( responseBody.wc_address_errors ).toStrictEqual( [] );

await expect(
page.getByRole( 'heading', {
name: 'Configure your product listings',
exact: true,
} )
).toBeVisible();
} );
} );
} );

Expand Down
26 changes: 25 additions & 1 deletion tests/e2e/utils/pages/setup-mc/step-1-set-up-accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ export default class SetUpAccountsPage extends MockRequests {
} );
}

/**
* Click "Continue" button.
*
* @return {Promise<void>}
*/
async clickContinueButton() {
const continueButton = this.getContinueButton();
await continueButton.click();
await this.page.waitForLoadState( LOAD_STATE.DOM_CONTENT_LOADED );
}

/**
* Get link of Google Merchant Center Help.
*
Expand Down Expand Up @@ -403,7 +414,7 @@ export default class SetUpAccountsPage extends MockRequests {
}

/**
* Register the response when connecting an Ads account
* Register the response when connecting an Ads account.
*
* @return {Promise<import('@playwright/test').Response>} The response.
*/
Expand All @@ -414,4 +425,17 @@ export default class SetUpAccountsPage extends MockRequests {
response.status() === 200
);
}

/**
* Register the response when syncing the store address.
*
* @return {Promise<import('@playwright/test').Response>} The response.
*/
registerContactInformationSyncRequest() {
return this.page.waitForRequest(
( request ) =>
request.url().includes( '/gla/mc/contact-information' ) &&
request.method() === 'POST'
);
}
}
13 changes: 0 additions & 13 deletions tests/e2e/utils/pages/setup-mc/step-2-product-listings.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,6 @@ export default class ProductListingsPage extends MockRequests {
} );
}

/**
* Register the requests when the continue button is clicked.
*
* @return {Promise<import('@playwright/test').Request[]>} The requests.
*/
registerContinueRequest() {
return this.page.waitForRequest(
( request ) =>
request.url().includes( '/gla/mc/contact-information' ) &&
request.method() === 'GET'
);
}

/**
* Register settings request when the shipping rate radio button is checked.
*
Expand Down

0 comments on commit ddbb900

Please sign in to comment.