Skip to content

Commit

Permalink
move default card assertions to the previous test to avoid timeouts &…
Browse files Browse the repository at this point in the history
… fix selectors
  • Loading branch information
Timur Karimov committed Dec 12, 2023
1 parent 387cbf1 commit f09e566
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe( 'Enabled UPE with deferred intent creation', () => {
describe( 'My Account', () => {
let timeAdded;

it( 'should add the card as a new payment method', async () => {
it( 'should add the card as a new payment method and set it as default payment method', async () => {
await shopperWCP.goToPaymentMethods();
await shopperWCP.addNewPaymentMethod( 'basic', card );

Expand All @@ -147,6 +147,11 @@ describe( 'Enabled UPE with deferred intent creation', () => {
await expect( page ).toMatch(
`${ card.expires.month }/${ card.expires.year }`
);
await shopperWCP.setDefaultPaymentMethod( card.label );
// Verify that the card was set as default
await expect( page ).toMatch(
'This payment method was successfully set as your default.'
);
} );

it( 'should be able set card as default', async () => {
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/utils/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ export const shopperWCP = {
await expect( page ).toClick( 'label', { text: label } );
},

setDefaultPaymentMethod: async () => {
await expect( page ).toClick( '.button.default' );
setDefaultPaymentMethod: async ( label ) => {
const [ paymentMethodRow ] = await page.$x(
`//tr[contains(., '${ label }')]`
);
await expect( paymentMethodRow ).toClick( '.button.default' );
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
},

Expand Down

0 comments on commit f09e566

Please sign in to comment.