Skip to content

Commit

Permalink
Merge pull request #457 from woocommerce/dev/compat-e2e-billing-state…
Browse files Browse the repository at this point in the history
…-input

Make the value entering of the billing state field in e2e test compatible with WC < 9.2
  • Loading branch information
eason9487 authored Aug 14, 2024
2 parents 11e35ce + 50cbf3d commit 146b651
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/e2e/utils/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,17 @@ export async function checkout( page ) {
.fill( user.addressfirstline );
await page.getByLabel( 'City' ).fill( user.city );
await page.getByLabel( 'ZIP Code' ).fill( user.postcode );
await page.locator( '#billing-state' ).selectOption( user.statename );

const stateField = page.getByRole( 'combobox', { name: /State$/ } );
const stateFieldTagName = await stateField.evaluate(
( element ) => element.tagName
);
if ( stateFieldTagName === 'SELECT' ) {
stateField.selectOption( user.statename );
} else {
// compatibility-code "WC < 9.2"
stateField.fill( user.statename );
}
}

//TODO: See if there's an alternative method to click the button without relying on waitForTimeout.
Expand Down

0 comments on commit 146b651

Please sign in to comment.