Skip to content

Commit

Permalink
test: fix tests (#2974)
Browse files Browse the repository at this point in the history
  • Loading branch information
longyulongyu authored Nov 20, 2024
1 parent 4bd35a2 commit 87194b5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build-then-e2e:
if: ${{ github.actor != 'renovate[bot]' && github.actor != 'lgtm-com[bot]' }}
timeout-minutes: 30
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
18 changes: 9 additions & 9 deletions packages/e2e-playwright/tests/a11y/card/errorPanel.avs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ test('#3 fill out credit card fields & see that first error in error panel is co
'Enter the City-sr'
];
await cardWithAvs.goto(url);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);

await cardWithAvs.pay();
// Wait for all sr panel messages
Expand Down Expand Up @@ -105,9 +105,9 @@ test('#5 Switch country to US, fill out credit card fields & see that first erro
const expectedSRPanelTexts = ['Enter the Address-sr', 'Enter the City-sr', 'Enter the State-sr', 'Enter the Zip code-sr'];

await cardWithAvs.goto(url);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);
await cardWithAvs.billingAddress.selectCountry({ name: 'United States' });
await cardWithAvs.pay();
// Wait for all sr panel messages
Expand Down Expand Up @@ -158,9 +158,9 @@ test('#7 Switch country to UK, fill out credit card fields & see that first erro
const expectedSRPanelTexts = ['Enter the House number-sr', 'Enter the Street-sr', 'Enter the City / Town-sr', 'Enter the Postal code-sr'];

await cardWithAvs.goto(url);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);
await cardWithAvs.billingAddress.selectCountry({ name: 'United Kingdom' });
await cardWithAvs.pay();
// Wait for all sr panel messages
Expand Down
36 changes: 18 additions & 18 deletions packages/e2e-playwright/tests/e2e/card/avs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { URL_MAP } from '../../../fixtures/URL_MAP';
test.describe('Card payments with address lookup', () => {
test('should make a successful card payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(URL_MAP.addressLookupUrl);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);

await cardWithAvs.billingAddress.searchAddressAndChooseTheFirst('1');
await cardWithAvs.pay();
Expand All @@ -20,9 +20,9 @@ test.describe('Card payments with partial avs', () => {
test.describe('When fill in a valid the post code', () => {
test('should make a successful card payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(URL_MAP.cardWithPartialAvs);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);
await cardWithAvs.billingAddress.fillInPostCode(TEST_POSTCODE);
await cardWithAvs.pay();
await cardWithAvs.paymentResult.waitFor({ state: 'visible' });
Expand All @@ -33,9 +33,9 @@ test.describe('Card payments with partial avs', () => {
test.describe('When not fill in a post code ', () => {
test('should not submit the payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(URL_MAP.cardWithPartialAvs);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);
await cardWithAvs.pay();
await expect(cardWithAvs.billingAddress.postalCodeError).toContainText('Enter the zip code');
});
Expand All @@ -46,9 +46,9 @@ test.describe('Card payments with full avs', () => {
test.describe('When fill in the valid address data', () => {
test('should make a successful card payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(URL_MAP.fullAvsWithoutPrefilledDataUrl);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);

await cardWithAvs.billingAddress.selectCountry({ name: 'United States' });
await cardWithAvs.billingAddress.fillInStreet('Test address');
Expand All @@ -64,9 +64,9 @@ test.describe('Card payments with full avs', () => {
test.describe('When fill in the invalid address data', () => {
test('should not submit the payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(URL_MAP.fullAvsWithoutPrefilledDataUrl);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);

await cardWithAvs.billingAddress.selectCountry({ name: 'United States' });
await cardWithAvs.pay();
Expand All @@ -84,9 +84,9 @@ test.describe('Card payments with full avs', () => {
await cardWithAvs.goto(url);
await expect(cardWithAvs.billingAddress.postalCodeError).toContainText('Invalid format. Expected format');
await cardWithAvs.billingAddress.selectCountry({ name: 'Japan' });
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
await cardWithAvs.typeCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.typeExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.typeCvc(TEST_CVC_VALUE);
await cardWithAvs.pay();
await cardWithAvs.paymentResult.waitFor({ state: 'visible' });
await expect(cardWithAvs.paymentResult).toContainText(PAYMENT_RESULT.authorised);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ENCRYPTED_CARD_NUMBER,
ENCRYPTED_EXPIRY_DATE,
ENCRYPTED_SECURITY_CODE,
SYNCHRONY_PLCC_NO_DATE,
PLCC_NO_LUHN_NO_DATE,
TEST_CVC_VALUE
} from '../../../utils/constants';
import { getStoryUrl } from '../../../utils/getStoryUrl';
Expand All @@ -22,7 +22,7 @@ test.describe('Test how Card Component handles hidden expiryDate policy', () =>
await card.goto(url);

// Fill number to provoke binLookup response
await card.typeCardNumber(SYNCHRONY_PLCC_NO_DATE);
await card.typeCardNumber(PLCC_NO_LUHN_NO_DATE);

// UI reflects that binLookup says expiryDate is hidden
await expect(card.expiryDateField).not.toBeVisible();
Expand Down Expand Up @@ -66,7 +66,7 @@ test.describe('Test how Card Component handles hidden expiryDate policy', () =>
await expect(cardErrors[ENCRYPTED_SECURITY_CODE]).not.toBe(undefined);

// Fill number to provoke binLookup response
await card.typeCardNumber(SYNCHRONY_PLCC_NO_DATE);
await card.typeCardNumber(PLCC_NO_LUHN_NO_DATE);

// Headless test seems to need time for UI reset to register on state
await page.waitForTimeout(500);
Expand Down Expand Up @@ -95,7 +95,7 @@ test.describe('Test how Card Component handles hidden expiryDate policy', () =>
await card.cardNumberLabelElement.click();

// Fill number to provoke binLookup response
await card.typeCardNumber(SYNCHRONY_PLCC_NO_DATE);
await card.typeCardNumber(PLCC_NO_LUHN_NO_DATE);

// UI reflects that binLookup says expiryDate is hidden
await expect(card.expiryDateField).not.toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test.describe('Testing PLCCs, in the custom card component)', () => {
// await t.expect(getPropFromStateValid('encryptedCardNumber')).eql(true);
//
// // Enter bin that needs luhn check but replace last digit to one that will mean number fails luhn check
// const partialNum = SYNCHRONY_PLCC_WITH_LUHN.substr(0, 15);
// const partialNum = PLCC_WITH_LUHN_NO_DATE.substr(0, 15);
// await cardUtilsRegular.fillCardNumber(t, partialNum + '8', 'replace');
//
// // num is not valid
Expand All @@ -36,7 +36,7 @@ test.describe('Testing PLCCs, in the custom card component)', () => {
// cardUtilsRegular.deleteDigitsFromCardNumber(t, 18, 19);
//
// // now enter correct last digit
// const endNum = SYNCHRONY_PLCC_WITH_LUHN.substr(15, 16);
// const endNum = PLCC_WITH_LUHN_NO_DATE.substr(15, 16);
// await cardUtilsRegular.fillCardNumber(t, endNum);
//
// // num is valid w. luhn check
Expand All @@ -54,7 +54,7 @@ test.describe('Testing PLCCs, in the custom card component)', () => {
// await start(t, 2000, TEST_SPEED);
//
// // Enter num
// await cardUtilsRegular.fillCardNumber(t, SYNCHRONY_PLCC_WITH_LUHN);
// await cardUtilsRegular.fillCardNumber(t, PLCC_WITH_LUHN_NO_DATE);
// // num is valid
// await t.expect(getPropFromStateValid('encryptedCardNumber')).eql(true);
//
Expand All @@ -64,7 +64,7 @@ test.describe('Testing PLCCs, in the custom card component)', () => {
// await t.expect(getPropFromStateValid('encryptedCardNumber')).eql(true);
//
// // Enter bin that needs luhn check but replace last digit to one that will mean number fails luhn check
// const partialNum = SYNCHRONY_PLCC_WITH_LUHN.substr(0, 15);
// const partialNum = PLCC_WITH_LUHN_NO_DATE.substr(0, 15);
// await cardUtilsRegular.fillCardNumber(t, partialNum + '8', 'paste');
// // num is not valid
// await t.expect(getPropFromStateValid('encryptedCardNumber')).eql(false);
Expand All @@ -73,7 +73,7 @@ test.describe('Testing PLCCs, in the custom card component)', () => {
// cardUtilsRegular.deleteDigitsFromCardNumber(t, 18, 19);
//
// // now enter correct last digit
// const endNum = SYNCHRONY_PLCC_WITH_LUHN.substr(15, 16);
// const endNum = PLCC_WITH_LUHN_NO_DATE.substr(15, 16);
// await cardUtilsRegular.fillCardNumber(t, endNum);
//
// // num is valid w. luhn check
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-playwright/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
/* Include types for the browser: window, document, etc */
"lib": ["es2022", "dom", "dom.iterable"]
},
"include": ["app/", "tests/", "mocks/", "models/", "pages/"],
"include": ["tests/", "mocks/", "models/"],
"exclude": ["node_modules"]
}

0 comments on commit 87194b5

Please sign in to comment.