From f3d79a6796f69b50c90c12fcf2ffde64eb2d929c Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 20:39:47 +0100 Subject: [PATCH] adjust timeouts to ensure tests are passing --- ...ferred-intent-creation-upe-enabled.spec.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/e2e/specs/upe-split/shopper/shopper-deferred-intent-creation-upe-enabled.spec.js b/tests/e2e/specs/upe-split/shopper/shopper-deferred-intent-creation-upe-enabled.spec.js index c4fd4ca88d9..69e69775400 100644 --- a/tests/e2e/specs/upe-split/shopper/shopper-deferred-intent-creation-upe-enabled.spec.js +++ b/tests/e2e/specs/upe-split/shopper/shopper-deferred-intent-creation-upe-enabled.spec.js @@ -139,6 +139,23 @@ describe( 'Enabled UPE with deferred intent creation', () => { // Take note of the time when we added this card timeAdded = Date.now(); + // Verify that the card was added + await expect( page ).not.toMatch( + 'You cannot add a new payment method so soon after the previous one. Please wait for 20 seconds.' + ); + await expect( page ).toMatch( 'Payment method successfully added' ); + await expect( page ).toMatch( + `${ card.expires.month }/${ card.expires.year }` + ); + await waitTwentySecondsSinceLastCardAdded(); + } ); + + it( 'should be able to set payment method as default', async () => { + await shopperWCP.goToPaymentMethods(); + await shopperWCP.addNewPaymentMethod( 'basic', card ); + // Take note of the time when we added this card + timeAdded = Date.now(); + // Verify that the card was added await expect( page ).not.toMatch( 'You cannot add a new payment method so soon after the previous one. Please wait for 20 seconds.' @@ -160,6 +177,10 @@ describe( 'Enabled UPE with deferred intent creation', () => { } ); afterAll( async () => { + await waitTwentySecondsSinceLastCardAdded(); + } ); + + async function waitTwentySecondsSinceLastCardAdded() { // Make sure that at least 20s had already elapsed since the last card was added. // Otherwise, you will get the error message, // "You cannot add a new payment method so soon after the previous one." @@ -171,6 +192,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { : 0; await new Promise( ( r ) => setTimeout( r, remainingWaitTime ) ); - } ); + } } ); } );