Update e2e tests to be compatible with WP 6.7 (#52304)

* Updated e2e tests to be compatible with WP 6.7

* Add changelog
This commit is contained in:
Veljko V. 2024-10-24 19:40:11 +02:00 committed by GitHub
parent f5701ab537
commit cd2edff752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 11 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
E2E tests: Update relevant e2e tests to be compatible with the upcoming changes in WP 6.7

View File

@ -9,11 +9,16 @@ test.describe( 'Coupons page', () => {
await page.goto( await page.goto(
'wp-admin/edit.php?post_type=shop_coupon&legacy_coupon_menu=1' 'wp-admin/edit.php?post_type=shop_coupon&legacy_coupon_menu=1'
); );
await expect( page.locator( 'h1.wp-heading-inline' ) ).toHaveText( await expect( page.locator( 'h1.wp-heading-inline' ) ).toHaveText(
'Coupons' 'Coupons'
); );
// Use regex to allow for "Add coupon" or "Add new coupon"
// making it compatible with WP <=6.6 & 6.7+
const addCouponRegex = /Add (coupon|new coupon)/i;
await expect( page.locator( 'a.page-title-action' ) ).toHaveText( await expect( page.locator( 'a.page-title-action' ) ).toHaveText(
'Add coupon' addCouponRegex
); );
} ); } );
} ); } );

View File

@ -207,7 +207,7 @@ for ( const currentPage of wcPages ) {
async ( { page } ) => { async ( { page } ) => {
await page await page
.locator( .locator(
`li.wp-menu-open > ul.wp-submenu > li a:text-is("${ currentPage.subpages[ i ].name }")` `li.wp-menu-open > ul.wp-submenu > li a:has-text("${ currentPage.subpages[ i ].name }")`
) )
.click(); .click();

View File

@ -461,12 +461,12 @@ test.describe(
await test.step( 'Confirm order details on the backend (as a merchant)', async () => { await test.step( 'Confirm order details on the backend (as a merchant)', async () => {
await page.goto( 'wp-login.php' ); await page.goto( 'wp-login.php' );
await page await page
.locator( 'input[name="log"]' ) .getByLabel( 'Username or Email Address' )
.fill( admin.username ); .fill( admin.username );
await page await page
.locator( 'input[name="pwd"]' ) .getByRole( 'textbox', { name: 'Password' } )
.fill( admin.password ); .fill( admin.password );
await page.locator( 'text=Log In' ).click(); await page.getByRole( 'button', { name: 'Log In' } ).click();
// load the order placed as a guest // load the order placed as a guest
await page.goto( await page.goto(
@ -497,12 +497,12 @@ test.describe(
test( 'allows existing customer to place order', async ( { page } ) => { test( 'allows existing customer to place order', async ( { page } ) => {
await page.goto( 'my-account/' ); await page.goto( 'my-account/' );
await page await page
.locator( 'input[name="username"]' ) .getByLabel( 'Username or Email Address' )
.fill( customer.username ); .fill( customer.username );
await page await page
.locator( 'input[name="password"]' ) .getByRole( 'textbox', { name: 'Password' } )
.fill( customer.password ); .fill( customer.password );
await page.locator( 'text=Log In' ).click(); await page.getByRole( 'button', { name: 'Log In' } ).click();
await expect( await expect(
page.getByText( page.getByText(
`Hello ${ customer.first_name } ${ customer.last_name }` `Hello ${ customer.first_name } ${ customer.last_name }`
@ -563,9 +563,13 @@ test.describe(
// Switch to admin user. // Switch to admin user.
await page.goto( 'wp-login.php?loggedout=true' ); await page.goto( 'wp-login.php?loggedout=true' );
await page.locator( 'input[name="log"]' ).fill( admin.username ); await page
await page.locator( 'input[name="pwd"]' ).fill( admin.password ); .getByLabel( 'Username or Email Address' )
await page.locator( 'text=Log In' ).click(); .fill( admin.username );
await page
.getByRole( 'textbox', { name: 'Password' } )
.fill( admin.password );
await page.getByRole( 'button', { name: 'Log In' } ).click();
// load the order placed as a customer // load the order placed as a customer
await page.goto( await page.goto(