Skip to content

Commit

Permalink
refactor(avs.spec.ts): move the urls
Browse files Browse the repository at this point in the history
  • Loading branch information
longyulongyu committed Nov 18, 2024
1 parent 9f701f7 commit c0d8fa4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
3 changes: 3 additions & 0 deletions packages/e2e-playwright/fixtures/URL_MAP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const URL_MAP = {
cardWithInstallments: '/iframe.html?args=&id=cards-card--with-installments&viewMode=story',
cardWithKcp: '/iframe.html?args=&id=cards-card--kcp&viewMode=story',
cardWithClickToPay: '/iframe.html?args=&id=cards-card--with-click-to-pay&viewMode=story',
fullAvsWithoutPrefilledDataUrl: '/iframe.html?args=componentConfiguration.data:!undefined&globals=&id=cards-card--with-avs&viewMode=story',
fullAvsWithPrefilledDataUrl: '/iframe.html?globals=&args=&id=cards-card--with-avs&viewMode=story',
addressLookupUrl: '/iframe.html?id=cards-card--with-avs-address-lookup&viewMode=story',
bcmc: '/iframe.html?args=&globals=&id=cards-bancontact--default&viewMode=story',
/* Custom card */
customCard: '/iframe.html?globals=&args=&id=cards-custom-card--default&viewMode=story',
Expand Down
25 changes: 5 additions & 20 deletions packages/e2e-playwright/tests/e2e/card/avs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import { test as base, expect } from '@playwright/test';
import { test, expect } from '../../../fixtures/card.fixture';
import { PAYMENT_RESULT, REGULAR_TEST_CARD, TEST_CVC_VALUE, TEST_DATE_VALUE, TEST_POSTCODE } from '../../utils/constants';
import { CardWithAvs } from '../../../models/card-avs';
import { URL_MAP } from '../../../fixtures/URL_MAP';

const fullAvsWithoutPrefilledDataUrl = '/iframe.html?args=componentConfiguration.data:!undefined&globals=&id=cards-card--with-avs&viewMode=story';
const fullAvsWithPrefilledDataUrl = '/iframe.html?globals=&args=&id=cards-card--with-avs&viewMode=story';
const addressLookupUrl = '/iframe.html?id=cards-card--with-avs-address-lookup&viewMode=story';

type Fixture = {
cardWithAvs: CardWithAvs;
};

const test = base.extend<Fixture>({
cardWithAvs: async ({ page }, use) => {
await use(new CardWithAvs(page));
}
});

test.describe('Card payments with address lookup', () => {
test('should make a successful card payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(addressLookupUrl);
await cardWithAvs.goto(URL_MAP.addressLookupUrl);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
Expand Down Expand Up @@ -60,7 +45,7 @@ test.describe('Card payments with partial avs', () => {
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(fullAvsWithoutPrefilledDataUrl);
await cardWithAvs.goto(URL_MAP.fullAvsWithoutPrefilledDataUrl);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
Expand All @@ -78,7 +63,7 @@ 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(fullAvsWithoutPrefilledDataUrl);
await cardWithAvs.goto(URL_MAP.fullAvsWithoutPrefilledDataUrl);
await cardWithAvs.fillCardNumber(REGULAR_TEST_CARD);
await cardWithAvs.fillExpiryDate(TEST_DATE_VALUE);
await cardWithAvs.fillCvc(TEST_CVC_VALUE);
Expand Down Expand Up @@ -108,7 +93,7 @@ test.describe('Card payments with full avs', () => {
});

test('should not submit the payment', async ({ cardWithAvs }) => {
await cardWithAvs.goto(fullAvsWithPrefilledDataUrl);
await cardWithAvs.goto(URL_MAP.fullAvsWithPrefilledDataUrl);
await cardWithAvs.billingAddress.selectCountry({ name: 'Canada' });
await expect(cardWithAvs.billingAddress.postalCodeError).toContainText('Invalid format. Expected format');
});
Expand Down

0 comments on commit c0d8fa4

Please sign in to comment.