Skip to content

Commit

Permalink
Merge pull request #454 from woocommerce/fix/e2e-wc-9.2
Browse files Browse the repository at this point in the history
Fix E2E tests for WooCommerce 9.2
  • Loading branch information
vikrampm1 authored Aug 16, 2024
2 parents 133434a + d200b26 commit 8f955e4
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions tests/e2e/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,12 @@ export async function updateProduct(page, productId, productDetails) {
* @param {Page} page Playwright page object
*/
export async function saveSettings(page) {
await page.getByRole('button', { name: 'Save changes' }).click();
await expect(page.locator('.updated').last()).toContainText(
'Your settings have been saved.'
);
if (await page.getByRole('button', { name: 'Save changes' }).isEnabled()) {
await page.getByRole('button', { name: 'Save changes' }).click();
await expect(page.locator('.updated').last()).toContainText(
'Your settings have been saved.'
);
}
}

/**
Expand Down Expand Up @@ -328,12 +330,8 @@ export async function blockFillBillingDetails(page, customerDetails) {
await page.locator('#billing-first_name').fill(customerDetails.firstname);
await page.locator('#billing-last_name').fill(customerDetails.lastname);
await page
.locator('#billing .wc-block-components-country-input input')
.fill(customerDetails.countryName);
await page
.locator('#billing .wc-block-components-country-input ul li')
.first()
.click();
.locator('#billing-country')
.selectOption(customerDetails.country);
await page
.locator('#billing-address_1')
.fill(customerDetails.addressfirstline);
Expand All @@ -352,9 +350,8 @@ export async function blockFillBillingDetails(page, customerDetails) {
await page.locator('#billing-city').fill(customerDetails.city);
if (customerDetails.state) {
await page
.locator('#billing-state input')
.fill(customerDetails.stateName);
await page.locator('#billing-state ul li').first().click();
.locator('#billing-state')
.selectOption(customerDetails.state);
}
await page.locator('#billing-postcode').fill(customerDetails.postcode);
await page.locator('#billing-postcode').blur();
Expand Down Expand Up @@ -593,10 +590,12 @@ export async function updateSettings(page, timeSettings) {
await page
.locator('#woocommerce_accommodation_bookings_times_check_out')
.fill(timeSettings.checkoutTime);
await page.getByRole('button', { name: 'Save changes' }).click();
await expect(
page.locator('.updated', { hasText: 'Settings saved' })
).toBeVisible();
if (await page.getByRole('button', { name: 'Save changes' }).isEnabled()) {
await page.getByRole('button', { name: 'Save changes' }).click();
await expect(
page.locator('.updated', { hasText: 'Settings saved' })
).toBeVisible();
}
}

/**
Expand Down

0 comments on commit 8f955e4

Please sign in to comment.