Skip to content

Commit

Permalink
Update E2E tests GH action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Oct 30, 2024
1 parent 09a4526 commit bb15c61
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 54 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/e2e/tests/_legacy-experience/_legacy.setup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/tests/_legacy-experience/checkout/sca-card.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }` );
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/tests/_legacy-experience/order/full-refund.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }` );
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/utils/api.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit bb15c61

Please sign in to comment.