From bb15c615698640d881e93b063ecadf0e651b3be8 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Wed, 30 Oct 2024 17:21:44 +0530 Subject: [PATCH] Update E2E tests GH action workflow --- .github/workflows/e2e-tests.yml | 19 ++++---- package.json | 11 +---- ...w.setup.spec.js => _default.setup.spec.js} | 0 .../_legacy-experience/_legacy.setup.spec.js | 2 +- .../checkout/card-failures.spec.js | 2 +- .../checkout/normal-card.spec.js | 2 +- .../checkout/saved-card.spec.js | 4 +- .../checkout/sca-card.spec.js | 4 +- .../checkout/subscription-product.spec.js | 2 +- .../order/full-refund.spec.js | 4 +- .../subscription-renewal.spec.js | 2 +- .../woocommerce-blocks/card-failures.spec.js | 43 ++++++++++--------- .../woocommerce-blocks/normal-card.spec.js | 2 +- .../woocommerce-blocks/saved-card.spec.js | 2 +- .../woocommerce-blocks/sca-card.spec.js | 2 +- .../subscription-product.spec.js | 2 +- tests/e2e/utils/api.js | 3 +- 17 files changed, 52 insertions(+), 54 deletions(-) rename tests/e2e/tests/{_new.setup.spec.js => _default.setup.spec.js} (100%) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8392a956a..ebb12183a 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -42,6 +42,9 @@ jobs: shell: bash run: composer install --no-progress + - name: Add partner for QIT + run: ./vendor/bin/qit partner:add --user='${{ secrets.PARTNER_USER }}' --application_password='${{ secrets.PARTNER_SECRET }}' + # Node - name: Setup Node @@ -71,20 +74,14 @@ jobs: npm run build # E2E test environment - - - name: Prepare test environment - shell: bash - env: - GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }} - STRIPE_PUB_KEY: ${{ secrets.E2E_STRIPE_PUBLISHABLE_KEY }} - STRIPE_SECRET_KEY: ${{ secrets.E2E_STRIPE_SECRET_KEY }} - run: npm run test:e2e-setup + - name: Fill in local.env + working-directory: tests/e2e/config + run: | + echo 'STRIPE_PUB_KEY="${{ secrets.E2E_STRIPE_PUBLISHABLE_KEY }}"' >> local.env + echo 'STRIPE_SECRET_KEY="${{ secrets.E2E_STRIPE_SECRET_KEY }}"' >> local.env - name: Run ${{ matrix.checkout }} E2E tests shell: bash - env: - STRIPE_PUB_KEY: ${{ secrets.E2E_STRIPE_PUBLISHABLE_KEY }} - STRIPE_SECRET_KEY: ${{ secrets.E2E_STRIPE_SECRET_KEY }} run: npm run test:e2e${{ matrix.checkout == 'Legacy' && '-legacy' || '' }} - name: Upload ${{ matrix.checkout }} E2E test results diff --git a/package.json b/package.json index bc97c15e2..902e5502f 100644 --- a/package.json +++ b/package.json @@ -151,15 +151,8 @@ "jt:setup": "npm run up && ./bin/jurassic-tube-setup.sh", "jt:start": "./docker/bin/jt/tunnel.sh", "jt:stop": "./docker/bin/jt/tunnel.sh break", - "test:e2e-setup": "./tests/e2e/bin/setup.sh", - "test:e2e-up": "./tests/e2e/bin/up.sh", - "test:e2e-down": "./tests/e2e/bin/down.sh", - "test:e2e-cleanup": "npm run test:e2e-down && ./tests/e2e/bin/cleanup.sh", - "test:e2e": "./tests/e2e/bin/run-tests.sh --project=default", - "test:e2e-debug": "npm run test:e2e -- --debug", - "test:e2e-legacy": "./tests/e2e/bin/run-tests.sh --project=legacy", - "test:e2e-legacy-debug": "npm run test:e2e-legacy -- --debug", - "test:e2e-local": "./vendor/bin/qit run:e2e woocommerce-gateway-stripe ./tests/e2e --source ./" + "test:e2e": "./vendor/bin/qit run:e2e woocommerce-gateway-stripe ./tests/e2e --source ./ --pw_options=\"--grep-invert @legacy\"", + "test:e2e-legacy": "./vendor/bin/qit run:e2e woocommerce-gateway-stripe ./tests/e2e --source ./ --pw_options=\"--grep @legacy\"" }, "engines": { "node": ">=16.17.0", diff --git a/tests/e2e/tests/_new.setup.spec.js b/tests/e2e/tests/_default.setup.spec.js similarity index 100% rename from tests/e2e/tests/_new.setup.spec.js rename to tests/e2e/tests/_default.setup.spec.js diff --git a/tests/e2e/tests/_legacy-experience/_legacy.setup.spec.js b/tests/e2e/tests/_legacy-experience/_legacy.setup.spec.js index 320fd7afd..bf6181fb8 100644 --- a/tests/e2e/tests/_legacy-experience/_legacy.setup.spec.js +++ b/tests/e2e/tests/_legacy-experience/_legacy.setup.spec.js @@ -5,7 +5,7 @@ import qit from '/qitHelpers'; import { expect, test as setup } from '@playwright/test'; -setup( 'Enable legacy checkout experience', async ( { browser } ) => { +setup( 'Enable legacy checkout experience @legacy', async ( { browser } ) => { const adminContext = await browser.newContext( { storageState: qit.getEnv( 'ADMINSTATE' ), } ); diff --git a/tests/e2e/tests/_legacy-experience/checkout/card-failures.spec.js b/tests/e2e/tests/_legacy-experience/checkout/card-failures.spec.js index 2077d2bcd..ce8e5f9ab 100644 --- a/tests/e2e/tests/_legacy-experience/checkout/card-failures.spec.js +++ b/tests/e2e/tests/_legacy-experience/checkout/card-failures.spec.js @@ -44,7 +44,7 @@ const testCardBlocks = async ( page, cardKey ) => { }; test.describe.configure( { mode: 'parallel' } ); -test.describe( 'customer cannot checkout with invalid cards', () => { +test.describe( 'customer cannot checkout with invalid cards @legacy', () => { test( `a declined card shows the correct error message @smoke`, async ( { page, } ) => testCard( page, 'cards.declined' ) ); diff --git a/tests/e2e/tests/_legacy-experience/checkout/normal-card.spec.js b/tests/e2e/tests/_legacy-experience/checkout/normal-card.spec.js index e42bfa8b8..c9a1ce839 100644 --- a/tests/e2e/tests/_legacy-experience/checkout/normal-card.spec.js +++ b/tests/e2e/tests/_legacy-experience/checkout/normal-card.spec.js @@ -8,7 +8,7 @@ const { fillCreditCardDetailsShortcodeLegacy, } = payments; -test( 'customer can checkout with a normal credit card @smoke', async ( { +test( 'customer can checkout with a normal credit card @smoke @legacy', async ( { page, } ) => { await emptyCart( page ); diff --git a/tests/e2e/tests/_legacy-experience/checkout/saved-card.spec.js b/tests/e2e/tests/_legacy-experience/checkout/saved-card.spec.js index 003453a93..d61080a52 100644 --- a/tests/e2e/tests/_legacy-experience/checkout/saved-card.spec.js +++ b/tests/e2e/tests/_legacy-experience/checkout/saved-card.spec.js @@ -27,7 +27,9 @@ test.beforeAll( async () => { await api.create.customer( user ); } ); -test( 'customer can checkout with a saved card @smoke', async ( { page } ) => { +test( 'customer can checkout with a saved card @smoke @legacy', async ( { + page, +} ) => { await test.step( 'customer login', async () => { await qit.loginAs( page, diff --git a/tests/e2e/tests/_legacy-experience/checkout/sca-card.spec.js b/tests/e2e/tests/_legacy-experience/checkout/sca-card.spec.js index 74e63d2f5..d369226f2 100644 --- a/tests/e2e/tests/_legacy-experience/checkout/sca-card.spec.js +++ b/tests/e2e/tests/_legacy-experience/checkout/sca-card.spec.js @@ -8,7 +8,9 @@ const { fillCreditCardDetailsShortcodeLegacy, } = payments; -test( 'customer can checkout with a SCA card @smoke', async ( { page } ) => { +test( 'customer can checkout with a SCA card @smoke @legacy', async ( { + page, +} ) => { test.slow(); // Make sure test has enough time to complete. await emptyCart( page ); diff --git a/tests/e2e/tests/_legacy-experience/checkout/subscription-product.spec.js b/tests/e2e/tests/_legacy-experience/checkout/subscription-product.spec.js index ca4d4bbc8..bc8593fe2 100644 --- a/tests/e2e/tests/_legacy-experience/checkout/subscription-product.spec.js +++ b/tests/e2e/tests/_legacy-experience/checkout/subscription-product.spec.js @@ -31,7 +31,7 @@ test.afterAll( async () => { await api.deletePost.product( productId ); } ); -test( 'customer can purchase a subscription product @smoke @subscriptions', async ( { +test( 'customer can purchase a subscription product @smoke @subscriptions @legacy', async ( { page, } ) => { await page.goto( `?p=${ productId }` ); diff --git a/tests/e2e/tests/_legacy-experience/order/full-refund.spec.js b/tests/e2e/tests/_legacy-experience/order/full-refund.spec.js index 538620631..dd0dd1254 100644 --- a/tests/e2e/tests/_legacy-experience/order/full-refund.spec.js +++ b/tests/e2e/tests/_legacy-experience/order/full-refund.spec.js @@ -10,7 +10,9 @@ const { fillCreditCardDetailsShortcodeLegacy, } = payments; -test( 'merchant can issue a full refund @smoke', async ( { browser } ) => { +test( 'merchant can issue a full refund @smoke @legacy', async ( { + browser, +} ) => { let orderId, stripeChargeId, stripeRefundId; const adminContext = await browser.newContext( { diff --git a/tests/e2e/tests/_legacy-experience/subscriptions/subscription-renewal.spec.js b/tests/e2e/tests/_legacy-experience/subscriptions/subscription-renewal.spec.js index 5b266596a..35fdb8e26 100644 --- a/tests/e2e/tests/_legacy-experience/subscriptions/subscription-renewal.spec.js +++ b/tests/e2e/tests/_legacy-experience/subscriptions/subscription-renewal.spec.js @@ -47,7 +47,7 @@ test.afterAll( async () => { await api.deletePost.product( productId ); } ); -test( 'customer can renew a subscription @smoke @subscriptions', async ( { +test( 'customer can renew a subscription @smoke @subscriptions @legacy', async ( { page, } ) => { await test.step( 'customer login', async () => { diff --git a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/card-failures.spec.js b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/card-failures.spec.js index e5f333de6..9f8f0b064 100644 --- a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/card-failures.spec.js +++ b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/card-failures.spec.js @@ -38,28 +38,31 @@ const testCard = async ( page, cardKey ) => { }; test.describe.configure( { mode: 'parallel' } ); -test.describe( 'customer cannot checkout with invalid cards @blocks', () => { - test( `a declined card shows the correct error message @smoke`, async ( { - page, - } ) => testCard( page, 'cards.declined' ) ); +test.describe( + 'customer cannot checkout with invalid cards @blocks @legacy', + () => { + test( `a declined card shows the correct error message @smoke`, async ( { + page, + } ) => testCard( page, 'cards.declined' ) ); - test( `a card with insufficient funds shows the correct error message`, async ( { - page, - } ) => testCard( page, 'cards.declined-funds' ) ); + test( `a card with insufficient funds shows the correct error message`, async ( { + page, + } ) => testCard( page, 'cards.declined-funds' ) ); - test( `a card with invalid number shows the correct error message`, async ( { - page, - } ) => testCard( page, 'cards.declined-incorrect' ) ); + test( `a card with invalid number shows the correct error message`, async ( { + page, + } ) => testCard( page, 'cards.declined-incorrect' ) ); - test( `an expired card shows the correct error message`, async ( { - page, - } ) => testCard( page, 'cards.declined-expired' ) ); + test( `an expired card shows the correct error message`, async ( { + page, + } ) => testCard( page, 'cards.declined-expired' ) ); - test( `a card with incorrect CVC shows the correct error message @smoke`, async ( { - page, - } ) => testCard( page, 'cards.declined-cvc' ) ); + test( `a card with incorrect CVC shows the correct error message @smoke`, async ( { + page, + } ) => testCard( page, 'cards.declined-cvc' ) ); - test( `an error processing the card shows the correct error message`, async ( { - page, - } ) => testCard( page, 'cards.declined-processing' ) ); -} ); + test( `an error processing the card shows the correct error message`, async ( { + page, + } ) => testCard( page, 'cards.declined-processing' ) ); + } +); diff --git a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/normal-card.spec.js b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/normal-card.spec.js index 16b8744cf..3a7acc34c 100644 --- a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/normal-card.spec.js +++ b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/normal-card.spec.js @@ -8,7 +8,7 @@ const { setupBlocksCheckout, } = payments; -test( 'customer can checkout with a normal credit card @smoke @blocks', async ( { +test( 'customer can checkout with a normal credit card @smoke @blocks @legacy', async ( { page, } ) => { await emptyCart( page ); diff --git a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/saved-card.spec.js b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/saved-card.spec.js index c38a594c6..5d1b86bc6 100644 --- a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/saved-card.spec.js +++ b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/saved-card.spec.js @@ -27,7 +27,7 @@ test.beforeAll( async () => { await api.create.customer( user ); } ); -test( 'customer can checkout with a saved card @smoke @blocks', async ( { +test( 'customer can checkout with a saved card @smoke @blocks @legacy', async ( { page, } ) => { await test.step( 'customer login', async () => { diff --git a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/sca-card.spec.js b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/sca-card.spec.js index 9d659e056..a9da5559a 100644 --- a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/sca-card.spec.js +++ b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/sca-card.spec.js @@ -8,7 +8,7 @@ const { fillCreditCardDetailsLegacy, } = payments; -test( 'customer can checkout with a SCA card @smoke @blocks', async ( { +test( 'customer can checkout with a SCA card @smoke @blocks @legacy', async ( { page, } ) => { await emptyCart( page ); diff --git a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/subscription-product.spec.js b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/subscription-product.spec.js index 2b564f196..eb428aca0 100644 --- a/tests/e2e/tests/_legacy-experience/woocommerce-blocks/subscription-product.spec.js +++ b/tests/e2e/tests/_legacy-experience/woocommerce-blocks/subscription-product.spec.js @@ -28,7 +28,7 @@ test.afterAll( async () => { await api.deletePost.product( productId ); } ); -test( 'customer can purchase a subscription product @smoke @blocks @subscriptions', async ( { +test( 'customer can purchase a subscription product @smoke @blocks @subscriptions @legacy', async ( { page, } ) => { await page.goto( `?p=${ productId }` ); diff --git a/tests/e2e/utils/api.js b/tests/e2e/utils/api.js index badcb3427..32188fc17 100644 --- a/tests/e2e/utils/api.js +++ b/tests/e2e/utils/api.js @@ -1,8 +1,7 @@ import wcApi from '@woocommerce/woocommerce-rest-api'; -import config from '../config/playwright.config'; - import qit from '/qitHelpers'; +const config = require( '/qit/tests/e2e/qit-playwright.config' ); let api; // Ensure that global-setup.js runs before creating api client