From 742f464a2c30b79e0933d19f68909f9016421a1e Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 14:22:43 +0100 Subject: [PATCH 01/16] extend checkout e2e test suite --- ...ferred-intent-creation-upe-enabled.spec.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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 1e9a6a27956..37ef26e2b3f 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 @@ -115,10 +115,26 @@ describe( 'Enabled UPE with deferred intent creation', () => { await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted' ); } ); + + it( 'should not allow guest user to save the card', async () => { + await shopperWCP.logout(); + await setupProductCheckout( + config.get( 'addresses.customer.billing' ) + ); + + await expect( page ).not.toMatchElement( + 'input#wc-woocommerce_payments-new-payment-method' + ); + } ); } ); describe( 'My Account', () => { let timeAdded; + + beforeAll( async () => { + await shopper.login(); + } ); + it( 'should add the card as a new payment method', async () => { await shopperWCP.goToPaymentMethods(); await shopperWCP.addNewPaymentMethod( 'basic', card ); @@ -136,6 +152,19 @@ describe( 'Enabled UPE with deferred intent creation', () => { ); } ); + it( 'should be able set card as default', async () => { + await shopperWCP.addNewPaymentMethod( 'basic', card ); + await shopperWCP.setDefaultPaymentMethod(); + + // Take note of the time when we added this card + timeAdded = Date.now(); + + // 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 to delete the card', async () => { await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted.' ); From 05ab14762dab2debfd87f01db85cdb334e8473a1 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 14:25:12 +0100 Subject: [PATCH 02/16] add changelog entry --- changelog/deferred-intent | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/deferred-intent diff --git a/changelog/deferred-intent b/changelog/deferred-intent new file mode 100644 index 00000000000..ef5442b5f17 --- /dev/null +++ b/changelog/deferred-intent @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Improve E2E checkout tests From 786b3a4a65b79201838bdd8f3d91155f040c3827 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 14:27:07 +0100 Subject: [PATCH 03/16] provide helper method for the test setup --- tests/e2e/utils/flows.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/utils/flows.js b/tests/e2e/utils/flows.js index 0a2d8a8e7f8..f8f23c72dec 100644 --- a/tests/e2e/utils/flows.js +++ b/tests/e2e/utils/flows.js @@ -129,6 +129,11 @@ export const shopperWCP = { await expect( page ).toClick( 'label', { text: label } ); }, + setDefaultPaymentMethod: async () => { + await expect( page ).toClick( '.button.default' ); + await page.waitForNavigation( { waitUntil: 'networkidle0' } ); + }, + toggleCreateAccount: async () => { await expect( page ).toClick( '#createaccount' ); }, From 387cbf150c14dd51010565236ddbb0ec398f8263 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 14:35:13 +0100 Subject: [PATCH 04/16] adjust shopper login attempt --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 37ef26e2b3f..5a97053217e 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 @@ -125,16 +125,13 @@ describe( 'Enabled UPE with deferred intent creation', () => { await expect( page ).not.toMatchElement( 'input#wc-woocommerce_payments-new-payment-method' ); + await shopper.login(); } ); } ); describe( 'My Account', () => { let timeAdded; - beforeAll( async () => { - await shopper.login(); - } ); - it( 'should add the card as a new payment method', async () => { await shopperWCP.goToPaymentMethods(); await shopperWCP.addNewPaymentMethod( 'basic', card ); From f09e566c252f97b61ce012a446ca46398bc76d5a Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 17:53:02 +0100 Subject: [PATCH 05/16] move default card assertions to the previous test to avoid timeouts & fix selectors --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 7 ++++++- tests/e2e/utils/flows.js | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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 5a97053217e..47dded81fa3 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 @@ -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 ); @@ -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 () => { diff --git a/tests/e2e/utils/flows.js b/tests/e2e/utils/flows.js index f8f23c72dec..aa18cd328a7 100644 --- a/tests/e2e/utils/flows.js +++ b/tests/e2e/utils/flows.js @@ -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' } ); }, From 8fc73fa3afde944d6e21c6288c06f7735b53d3e1 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 20:23:51 +0100 Subject: [PATCH 06/16] remove redundant test --- ...per-deferred-intent-creation-upe-enabled.spec.js | 13 ------------- 1 file changed, 13 deletions(-) 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 47dded81fa3..c4fd4ca88d9 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 @@ -154,19 +154,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { ); } ); - it( 'should be able set card as default', async () => { - await shopperWCP.addNewPaymentMethod( 'basic', card ); - await shopperWCP.setDefaultPaymentMethod(); - - // Take note of the time when we added this card - timeAdded = Date.now(); - - // 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 to delete the card', async () => { await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted.' ); From f3d79a6796f69b50c90c12fcf2ffde64eb2d929c Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 20:39:47 +0100 Subject: [PATCH 07/16] 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 ) ); - } ); + } } ); } ); From 507bb8e474623c2fe51bea2c5cd8fa1bdd2bb3d5 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Tue, 12 Dec 2023 21:01:40 +0100 Subject: [PATCH 08/16] use unique card --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 69e69775400..e743122f4f8 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 @@ -25,6 +25,7 @@ const UPE_METHOD_CHECKBOXES = [ '#inspector-checkbox-control-9', // sofort ]; const card = config.get( 'cards.basic' ); +const card2 = config.get( 'cards.basic2' ); const MIN_WAIT_TIME_BETWEEN_PAYMENT_METHODS = 20000; describe( 'Enabled UPE with deferred intent creation', () => { @@ -152,7 +153,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { it( 'should be able to set payment method as default', async () => { await shopperWCP.goToPaymentMethods(); - await shopperWCP.addNewPaymentMethod( 'basic', card ); + await shopperWCP.addNewPaymentMethod( 'basic2', card2 ); // Take note of the time when we added this card timeAdded = Date.now(); @@ -162,9 +163,9 @@ describe( 'Enabled UPE with deferred intent creation', () => { ); await expect( page ).toMatch( 'Payment method successfully added' ); await expect( page ).toMatch( - `${ card.expires.month }/${ card.expires.year }` + `${ card2.expires.month }/${ card2.expires.year }` ); - await shopperWCP.setDefaultPaymentMethod( card.label ); + await shopperWCP.setDefaultPaymentMethod( card2.label ); // Verify that the card was set as default await expect( page ).toMatch( 'This payment method was successfully set as your default.' From 22ba78ed35d6d29c0b66e33b2bc2d3e460bfd751 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 11:26:36 +0100 Subject: [PATCH 09/16] update APMs selectors --- ...hopper-deferred-intent-creation-upe-enabled.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 e743122f4f8..c355a740f4f 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 @@ -18,11 +18,11 @@ import { uiUnblocked } from '@woocommerce/e2e-utils/build/page-utils'; const { shopper, merchant } = require( '@woocommerce/e2e-utils' ); const UPE_METHOD_CHECKBOXES = [ - '#inspector-checkbox-control-5', // bancontact - '#inspector-checkbox-control-6', // eps - '#inspector-checkbox-control-7', // giropay - '#inspector-checkbox-control-8', // ideal - '#inspector-checkbox-control-9', // sofort + '#inspector-checkbox-control-2', // bancontact + '#inspector-checkbox-control-3', // eps + '#inspector-checkbox-control-4', // giropay + '#inspector-checkbox-control-5', // ideal + '#inspector-checkbox-control-6', // sofort ]; const card = config.get( 'cards.basic' ); const card2 = config.get( 'cards.basic2' ); From b58fc54eedc125a343eaa5ebff74f059d79f14f9 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 11:41:11 +0100 Subject: [PATCH 10/16] use more reliable currency switching on the checkout --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 c355a740f4f..83436409ab0 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 @@ -34,11 +34,9 @@ describe( 'Enabled UPE with deferred intent creation', () => { await merchantWCP.enablePaymentMethod( UPE_METHOD_CHECKBOXES ); await merchant.logout(); await shopper.login(); - await shopperWCP.changeAccountCurrencyTo( 'EUR' ); } ); afterAll( async () => { - await shopperWCP.changeAccountCurrencyTo( 'USD' ); await shopperWCP.logout(); await merchant.login(); await merchantWCP.disablePaymentMethod( UPE_METHOD_CHECKBOXES ); @@ -47,6 +45,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { describe( 'Enabled UPE with deferred intent creation', () => { it( 'should successfully place order with Giropay', async () => { + await shopperWCP.goToShopWithCurrency( 'EUR' ); await setupProductCheckout( config.get( 'addresses.customer.billing' ) ); From d4dc53a862aee8d9f6de5630ad4c08b4ed18f07e Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 12:26:43 +0100 Subject: [PATCH 11/16] get back to using currency switcher --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 3 ++- 1 file changed, 2 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 83436409ab0..c355a740f4f 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 @@ -34,9 +34,11 @@ describe( 'Enabled UPE with deferred intent creation', () => { await merchantWCP.enablePaymentMethod( UPE_METHOD_CHECKBOXES ); await merchant.logout(); await shopper.login(); + await shopperWCP.changeAccountCurrencyTo( 'EUR' ); } ); afterAll( async () => { + await shopperWCP.changeAccountCurrencyTo( 'USD' ); await shopperWCP.logout(); await merchant.login(); await merchantWCP.disablePaymentMethod( UPE_METHOD_CHECKBOXES ); @@ -45,7 +47,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { describe( 'Enabled UPE with deferred intent creation', () => { it( 'should successfully place order with Giropay', async () => { - await shopperWCP.goToShopWithCurrency( 'EUR' ); await setupProductCheckout( config.get( 'addresses.customer.billing' ) ); From 669ff1fba171e9f7847e17fadfdc661b8a21e54c Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 12:54:43 +0100 Subject: [PATCH 12/16] add logging --- ...ferred-intent-creation-upe-enabled.spec.js | 22 ++++++++++++++++++- 1 file changed, 21 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 c355a740f4f..7df74cbf314 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 @@ -22,7 +22,6 @@ const UPE_METHOD_CHECKBOXES = [ '#inspector-checkbox-control-3', // eps '#inspector-checkbox-control-4', // giropay '#inspector-checkbox-control-5', // ideal - '#inspector-checkbox-control-6', // sofort ]; const card = config.get( 'cards.basic' ); const card2 = config.get( 'cards.basic2' ); @@ -57,6 +56,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { waitUntil: 'networkidle0', } ); await expect( page ).toMatch( 'Order received' ); + console.log( 'DONE should successfully place order with Giropay' ); } ); it( 'should successfully place order with the default card', async () => { @@ -66,6 +66,9 @@ describe( 'Enabled UPE with deferred intent creation', () => { await fillCardDetails( page, card ); await shopper.placeOrder(); await expect( page ).toMatch( 'Order received' ); + console.log( + 'DONE should successfully place order with the default card' + ); } ); it( 'should process a payment with authentication for the 3DS card', async () => { @@ -79,6 +82,9 @@ describe( 'Enabled UPE with deferred intent creation', () => { waitUntil: 'networkidle0', } ); await expect( page ).toMatch( 'Order received' ); + console.log( + 'DONE should process a payment with authentication for the 3DS card' + ); } ); it( 'should successfully save the card', async () => { @@ -96,6 +102,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { await expect( page ).toMatch( `${ card.expires.month }/${ card.expires.year }` ); + console.log( 'DONE should successfully save the card' ); } ); it( 'should process a payment with the saved card', async () => { @@ -109,12 +116,14 @@ describe( 'Enabled UPE with deferred intent creation', () => { ); await shopper.placeOrder(); await expect( page ).toMatch( 'Order received' ); + console.log( 'DONE should process a payment with the saved card' ); } ); it( 'should delete the card', async () => { await shopperWCP.goToPaymentMethods(); await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted' ); + console.log( 'DONE should delete the card' ); } ); it( 'should not allow guest user to save the card', async () => { @@ -127,6 +136,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { 'input#wc-woocommerce_payments-new-payment-method' ); await shopper.login(); + console.log( 'DONE should not allow guest user to save the card' ); } ); } ); @@ -149,6 +159,9 @@ describe( 'Enabled UPE with deferred intent creation', () => { `${ card.expires.month }/${ card.expires.year }` ); await waitTwentySecondsSinceLastCardAdded(); + console.log( + 'DONE should add the card as a new payment method and set it as default payment method' + ); } ); it( 'should be able to set payment method as default', async () => { @@ -170,11 +183,18 @@ describe( 'Enabled UPE with deferred intent creation', () => { await expect( page ).toMatch( 'This payment method was successfully set as your default.' ); + console.log( + 'DONE should be able to set payment method as default' + ); } ); it( 'should be able to delete the card', async () => { await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted.' ); + + await shopperWCP.deleteSavedPaymentMethod( card2.label ); + await expect( page ).toMatch( 'Payment method deleted.' ); + console.log( 'DONE should be able to delete the card' ); } ); afterAll( async () => { From f8ff59b9f94d870a96c4bd873ed0c7ca1d16b79e Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 14:53:11 +0100 Subject: [PATCH 13/16] fix e2e tests for deferred UPE --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 9 +++------ tests/e2e/utils/flows.js | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) 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 7df74cbf314..3706d7d3c6a 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 @@ -18,10 +18,7 @@ import { uiUnblocked } from '@woocommerce/e2e-utils/build/page-utils'; const { shopper, merchant } = require( '@woocommerce/e2e-utils' ); const UPE_METHOD_CHECKBOXES = [ - '#inspector-checkbox-control-2', // bancontact - '#inspector-checkbox-control-3', // eps '#inspector-checkbox-control-4', // giropay - '#inspector-checkbox-control-5', // ideal ]; const card = config.get( 'cards.basic' ); const card2 = config.get( 'cards.basic2' ); @@ -33,11 +30,9 @@ describe( 'Enabled UPE with deferred intent creation', () => { await merchantWCP.enablePaymentMethod( UPE_METHOD_CHECKBOXES ); await merchant.logout(); await shopper.login(); - await shopperWCP.changeAccountCurrencyTo( 'EUR' ); } ); afterAll( async () => { - await shopperWCP.changeAccountCurrencyTo( 'USD' ); await shopperWCP.logout(); await merchant.login(); await merchantWCP.disablePaymentMethod( UPE_METHOD_CHECKBOXES ); @@ -46,6 +41,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { describe( 'Enabled UPE with deferred intent creation', () => { it( 'should successfully place order with Giropay', async () => { + await shopperWCP.goToShopWithCurrency( 'EUR' ); await setupProductCheckout( config.get( 'addresses.customer.billing' ) ); @@ -72,6 +68,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { } ); it( 'should process a payment with authentication for the 3DS card', async () => { + await shopperWCP.goToShopWithCurrency( 'EUR' ); await setupProductCheckout( config.get( 'addresses.customer.billing' ) ); @@ -188,7 +185,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { ); } ); - it( 'should be able to delete the card', async () => { + it( 'should be able to delete cards', async () => { await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted.' ); diff --git a/tests/e2e/utils/flows.js b/tests/e2e/utils/flows.js index aa18cd328a7..bd189a6008d 100644 --- a/tests/e2e/utils/flows.js +++ b/tests/e2e/utils/flows.js @@ -153,6 +153,7 @@ export const shopperWCP = { } ); await page.select( '#wcpay_selected_currency', currencyToSet ); + await new Promise( ( resolve ) => setTimeout( resolve, 2000 ) ); await expect( page ).toClick( 'button', { text: 'Save changes', } ); From ae8a50cddee1f9eb64113a0aa1a4b6c8f03e24c3 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 15:18:27 +0100 Subject: [PATCH 14/16] revert back the selector --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 2 +- 1 file changed, 1 insertion(+), 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 3706d7d3c6a..b0477f62893 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 @@ -18,7 +18,7 @@ import { uiUnblocked } from '@woocommerce/e2e-utils/build/page-utils'; const { shopper, merchant } = require( '@woocommerce/e2e-utils' ); const UPE_METHOD_CHECKBOXES = [ - '#inspector-checkbox-control-4', // giropay + '#inspector-checkbox-control-7', // giropay ]; const card = config.get( 'cards.basic' ); const card2 = config.get( 'cards.basic2' ); From 25e09281c4cea1afcba072b58f4bab49773cf8ae Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 15:41:09 +0100 Subject: [PATCH 15/16] remove debug logs --- ...eferred-intent-creation-upe-enabled.spec.js | 18 ------------------ 1 file changed, 18 deletions(-) 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 b0477f62893..cab3a20e28a 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 @@ -52,7 +52,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { waitUntil: 'networkidle0', } ); await expect( page ).toMatch( 'Order received' ); - console.log( 'DONE should successfully place order with Giropay' ); } ); it( 'should successfully place order with the default card', async () => { @@ -62,9 +61,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { await fillCardDetails( page, card ); await shopper.placeOrder(); await expect( page ).toMatch( 'Order received' ); - console.log( - 'DONE should successfully place order with the default card' - ); } ); it( 'should process a payment with authentication for the 3DS card', async () => { @@ -79,9 +75,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { waitUntil: 'networkidle0', } ); await expect( page ).toMatch( 'Order received' ); - console.log( - 'DONE should process a payment with authentication for the 3DS card' - ); } ); it( 'should successfully save the card', async () => { @@ -99,7 +92,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { await expect( page ).toMatch( `${ card.expires.month }/${ card.expires.year }` ); - console.log( 'DONE should successfully save the card' ); } ); it( 'should process a payment with the saved card', async () => { @@ -113,14 +105,12 @@ describe( 'Enabled UPE with deferred intent creation', () => { ); await shopper.placeOrder(); await expect( page ).toMatch( 'Order received' ); - console.log( 'DONE should process a payment with the saved card' ); } ); it( 'should delete the card', async () => { await shopperWCP.goToPaymentMethods(); await shopperWCP.deleteSavedPaymentMethod( card.label ); await expect( page ).toMatch( 'Payment method deleted' ); - console.log( 'DONE should delete the card' ); } ); it( 'should not allow guest user to save the card', async () => { @@ -133,7 +123,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { 'input#wc-woocommerce_payments-new-payment-method' ); await shopper.login(); - console.log( 'DONE should not allow guest user to save the card' ); } ); } ); @@ -156,9 +145,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { `${ card.expires.month }/${ card.expires.year }` ); await waitTwentySecondsSinceLastCardAdded(); - console.log( - 'DONE should add the card as a new payment method and set it as default payment method' - ); } ); it( 'should be able to set payment method as default', async () => { @@ -180,9 +166,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { await expect( page ).toMatch( 'This payment method was successfully set as your default.' ); - console.log( - 'DONE should be able to set payment method as default' - ); } ); it( 'should be able to delete cards', async () => { @@ -191,7 +174,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { await shopperWCP.deleteSavedPaymentMethod( card2.label ); await expect( page ).toMatch( 'Payment method deleted.' ); - console.log( 'DONE should be able to delete the card' ); } ); afterAll( async () => { From 6afff0120f8198edfe7f5c54ec8a561773c75392 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Wed, 13 Dec 2023 15:46:22 +0100 Subject: [PATCH 16/16] get rid of the redundant currency switch and cleanup further --- .../shopper-deferred-intent-creation-upe-enabled.spec.js | 3 +-- tests/e2e/utils/flows.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) 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 cab3a20e28a..e1062f6d1ca 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 @@ -64,7 +64,6 @@ describe( 'Enabled UPE with deferred intent creation', () => { } ); it( 'should process a payment with authentication for the 3DS card', async () => { - await shopperWCP.goToShopWithCurrency( 'EUR' ); await setupProductCheckout( config.get( 'addresses.customer.billing' ) ); @@ -129,7 +128,7 @@ describe( 'Enabled UPE with deferred intent creation', () => { describe( 'My Account', () => { let timeAdded; - it( 'should add the card as a new payment method and set it as default payment method', async () => { + it( 'should add the card as a new payment method', async () => { await shopperWCP.goToPaymentMethods(); await shopperWCP.addNewPaymentMethod( 'basic', card ); diff --git a/tests/e2e/utils/flows.js b/tests/e2e/utils/flows.js index bd189a6008d..aa18cd328a7 100644 --- a/tests/e2e/utils/flows.js +++ b/tests/e2e/utils/flows.js @@ -153,7 +153,6 @@ export const shopperWCP = { } ); await page.select( '#wcpay_selected_currency', currencyToSet ); - await new Promise( ( resolve ) => setTimeout( resolve, 2000 ) ); await expect( page ).toClick( 'button', { text: 'Save changes', } );