Skip to content

Commit a01f543

Browse files
authored
Merge pull request #3305 from woocommerce/fix/GOOWOO-519-e2e-tests-v2
Fix E2E tests
2 parents d386293 + b9c5ccc commit a01f543

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

tests/e2e/specs/onboarding-ads-only/step-2-create-campaign.test.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ test.describe( 'Create campaign for Ads only merchants', () => {
416416
test.describe( 'With WooCommerce tracking disabled', () => {
417417
test.beforeAll( async () => {
418418
await setupAdsAccountPage.mockAdsAccountIncomplete();
419+
await dashboardPage.fulfillAdsCampaignsRequest( [] );
419420
await createCampaignPage.goto();
420421
await createCampaignPage.clickSkipPaidAdsCreationButton();
421422
} );
@@ -440,11 +441,18 @@ test.describe( 'Create campaign for Ads only merchants', () => {
440441
await expect( setupSuccessModal ).toBeVisible();
441442
} );
442443

443-
test( 'should see buttons on Dashboard for Google Ads onboarding', async () => {
444-
await page.keyboard.press( 'Escape' );
445-
await page
446-
.getByRole( 'tab', { name: 'Dashboard' } )
447-
.click();
444+
test( 'should be able to close the setup success modal', async () => {
445+
const closeModalButton =
446+
createCampaignPage.getSetupSuccessModalCloseButton();
447+
await expect( closeModalButton ).toBeVisible();
448+
await expect( closeModalButton ).toBeEnabled();
449+
await closeModalButton.click();
450+
await expect(
451+
createCampaignPage.getSetupSuccessModal()
452+
).toBeHidden();
453+
} );
454+
455+
test( 'should see Google Ads onboarding buttons on Dashboard', async () => {
448456
const { addPaidCampaignButton, createCampaignButton } =
449457
dashboardPage;
450458

tests/e2e/specs/settings/settings.test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ test.describe( 'Settings', () => {
180180
} );
181181

182182
test.describe( 'YouTube Shopping', () => {
183+
test.afterEach( async () => {
184+
// Prevent setup/complete handlers from leaking between tests.
185+
await page.unroute( /\/wc\/gla\/youtube\/setup\/complete\b/ );
186+
} );
187+
183188
test( 'should show connect button when account is not connected', async () => {
189+
await settingsPage.mockYouTubeAccountNotConnected();
184190
await settingsPage.goto();
185191

186192
const connectButton = settingsPage.youTubeCard.getByRole(
@@ -222,9 +228,7 @@ test.describe( 'Settings', () => {
222228
} );
223229

224230
test( 'should display error message when "Complete setup" fails', async () => {
225-
await settingsPage
226-
.withFulfillTimes( 1 )
227-
.mockNotEligibleYouTubeChannel();
231+
await settingsPage.mockNotEligibleYouTubeChannel();
228232
const requestPromise =
229233
settingsPage.registerYouTubeCompleteSetupRequest();
230234

@@ -242,10 +246,8 @@ test.describe( 'Settings', () => {
242246
} );
243247

244248
test( 'should complete YouTube account setup successfully', async () => {
245-
await settingsPage
246-
.withFulfillTimes( 1 )
247-
.mockYouTubeAccountIncomplete();
248249
await settingsPage.mockEligibleYouTubeChannel();
250+
await settingsPage.mockYouTubeAccountIncomplete();
249251
await settingsPage.goto();
250252

251253
const requestPromise =

tests/e2e/utils/pages/onboarding/step-3-complete-campaign.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ export default class CompleteCampaign extends MockRequests {
203203
} );
204204
}
205205

206+
/**
207+
* Retrieves the "Close" button from the setup success modal.
208+
*
209+
* @return {import('@playwright/test').Locator} Locator for the "Close" button in the setup success modal.
210+
*/
211+
getSetupSuccessModalCloseButton() {
212+
return this.getSetupSuccessModal().getByRole( 'button', {
213+
name: 'Close',
214+
exact: true,
215+
} );
216+
}
217+
206218
/**
207219
* Retrieves the "Send and complete setup" button from the skip paid ads survey modal.
208220
*

0 commit comments

Comments
 (0)