Skip to content

Commit 4fe51db

Browse files
committed
refactor: added more tests
1 parent e047002 commit 4fe51db

File tree

8 files changed

+64
-36
lines changed

8 files changed

+64
-36
lines changed

packages/e2e-playwright/fixtures/URL_MAP.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const URL_MAP = {
1313
cardWithInstallments: '/iframe.html?args=&id=cards-card--with-installments&viewMode=story',
1414
cardWithKcp: '/iframe.html?args=&id=cards-card--kcp&viewMode=story',
1515
cardWithClickToPay: '/iframe.html?args=&id=cards-card--with-click-to-pay&viewMode=story',
16+
bcmc: '/iframe.html?args=&globals=&id=cards-bancontact--default&viewMode=story',
1617
/* Custom card */
1718
customCard: '/iframe.html?globals=&args=&id=cards-custom-card--default&viewMode=story',
1819
customCardSeparateExpiryDate: '/iframe.html?globals=&args=&id=cards-custom-card--variant&viewMode=story',

packages/e2e-playwright/fixtures/card.fixture.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import { test as base, expect } from '@playwright/test';
22
import { Card } from '../models/card';
3+
import { BCMC } from '../models/bcmc';
4+
import { URL_MAP } from './URL_MAP';
35

46
type Fixture = {
57
card: Card;
8+
bcmc: BCMC;
69
};
710

811
const test = base.extend<Fixture>({
912
card: async ({ page }, use) => {
1013
const cardPage = new Card(page);
1114
await use(cardPage);
15+
},
16+
bcmc: async ({ page }, use) => {
17+
const bcmc = new BCMC(page);
18+
await bcmc.goto(URL_MAP.bcmc);
19+
await use(bcmc);
1220
}
1321
});
1422

packages/e2e-playwright/models/ancv.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ANCV extends Base {
1515

1616
constructor(
1717
public readonly page: Page,
18-
rootElementSelector = '.ancv-field'
18+
rootElementSelector = '.adyen-checkout__ancv'
1919
) {
2020
super(page);
2121
this.rootElement = page.locator(rootElementSelector);
@@ -39,6 +39,10 @@ class ANCV extends Base {
3939
async clickOnSubmit() {
4040
await this.submitButton.click({ delay: SELECTOR_DELAY });
4141
}
42+
43+
get paymentResult() {
44+
return this.page.locator('.adyen-checkout__await__subtitle--result');
45+
}
4246
}
4347

4448
export { ANCV };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Card } from './card';
2+
3+
class BCMC extends Card {
4+
async isComponentVisible() {
5+
await this.cardNumberInput.waitFor({ state: 'visible' });
6+
await this.expiryDateInput.waitFor({ state: 'visible' });
7+
}
8+
}
9+
10+
export { BCMC };

packages/e2e-playwright/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@
1616
"dotenv": "16.4.4",
1717
"ts-loader": "9.4.4",
1818
"typescript": "5.2.2"
19-
},
20-
"dependencies": {
21-
"@adyen/adyen-web": "6.5.0"
2219
}
2320
}

packages/e2e-playwright/tests/a11y/bcmc/bancontact.visa.a11y.spec.ts

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
import { test } from '@playwright/test';
1+
import { test, expect } from '../../../fixtures/card.fixture';
2+
import { BCMC_DUAL_BRANDED_VISA, TEST_CVC_VALUE, TEST_DATE_VALUE, VISA_CARD } from '../../utils/constants';
23

3-
test('BCMC logo should have correct alt text', async () => {
4-
// wait for card number field shown
5-
// await fillCardNumber(t, '41');
6-
// BCMC logo still in number field
7-
// await t.expect(cc.brandingIcon.withAttribute('alt', 'Bancontact card').exists).ok();
8-
// Hidden cvc field - check aria hidden?
4+
test('BCMC logo should have correct alt text', async ({ bcmc }) => {
5+
await bcmc.typeCardNumber('41');
6+
expect(bcmc.rootElement.getByAltText(/bancontact card/i)).toBeTruthy();
97
});
108

11-
test('Visa logo should have correct alt text', async () => {});
9+
test('Visa logo should have correct alt text', async ({ bcmc }) => {
10+
await bcmc.typeCardNumber(VISA_CARD);
11+
expect(bcmc.rootElement.getByAltText(/visa/i)).toBeTruthy();
12+
});
1213

1314
test(
1415
'#4 Enter card number (co-branded bcmc/visa) ' +
1516
'then complete expiryDate and expect comp to be valid' +
1617
'then click Visa logo and expect comp to not be valid' +
1718
'then click BCMC logo and expect comp to be valid again',
18-
async () => {
19-
// Wait for field to appear in DOM
20-
// fillCardNumber(t, BCMC_DUAL_BRANDED_VISA);
21-
// fillDate(t, TEST_DATE_VALUE);
22-
// Expect drop in to be valid? - todo move this test to dropin?
23-
// Click Visa brand icon
24-
// Expect visible CVC field
25-
// Expect iframe to exist in CVC field and with aria-required set to true
26-
// await checkIframeForAttrVal(t, 2, 'encryptedSecurityCode', 'aria-required', 'true');
27-
// Expect dropin not to be valid
28-
// Click BCMC brand icon
29-
// Eppect hidden CVC field
30-
// Expect dropin to be valid (also check that it is set on state for this PM)
31-
// Expect the active payment to be valid (also check that it is set on state for this PM)
19+
async ({ page, bcmc }) => {
20+
await bcmc.typeCardNumber(BCMC_DUAL_BRANDED_VISA);
21+
await bcmc.typeExpiryDate(TEST_DATE_VALUE);
22+
expect(bcmc.cvcField).toBeHidden();
23+
await page.waitForFunction(() => globalThis.component.isValid === true);
24+
25+
await bcmc.rootElement.getByAltText(/visa/i).first().click();
26+
await bcmc.cvcInput.waitFor({ state: 'visible' });
27+
expect(bcmc.cvcInput).toHaveAttribute('aria-required', 'true');
28+
await page.waitForFunction(() => globalThis.component.isValid === false);
29+
30+
await bcmc.rootElement
31+
.getByAltText(/bancontact card/i)
32+
.first()
33+
.click();
34+
await bcmc.cvcField.waitFor({ state: 'hidden' });
35+
await page.waitForFunction(() => globalThis.component.isValid === true);
3236
}
3337
);
3438

@@ -37,15 +41,16 @@ test(
3741
'then complete expiryDate and expect comp to be valid' +
3842
'then click Visa logo and expect comp to not be valid' +
3943
'then enter CVC and expect comp to be valid',
40-
async () => {
41-
// Wait for field to appear in DOM
42-
// fillCardNumber(t, BCMC_DUAL_BRANDED_VISA);
43-
// fillDate(t, TEST_DATE_VALUE);
44-
// Expect dropin.isValid
45-
// Click Visa brand icon
46-
// Expect dropin.isValid not to be valid
47-
// fill CVC
48-
// Expect dropin.isValid to now be valid
44+
async ({ bcmc, page }) => {
45+
await bcmc.typeCardNumber(BCMC_DUAL_BRANDED_VISA);
46+
await bcmc.typeExpiryDate(TEST_DATE_VALUE);
47+
await page.waitForFunction(() => globalThis.component.isValid === true);
48+
49+
await bcmc.rootElement.getByAltText(/visa/i).first().click();
50+
await page.waitForFunction(() => globalThis.component.isValid === false);
51+
52+
await bcmc.typeCvc(TEST_CVC_VALUE);
53+
await page.waitForFunction(() => globalThis.component.isValid === true);
4954
}
5055
);
5156

packages/e2e-playwright/tests/ui/customCard/expiryDate/customCard.regular.expiryDatePolicies.hidden.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ test.describe('Test how Custom Card Component with regular date field handles hi
7373
await expect(cardValid).toEqual(true);
7474
});
7575
// flaky
76-
test.fixme('#3 date field in error does not stop card becoming valid', async ({ page, customCard }) => {
76+
test('#3 date field in error does not stop card becoming valid', async ({ browserName, page, customCard }) => {
77+
test.skip(browserName === 'webkit', 'Skipping tests for WebKit');
78+
7779
await binLookupMock(page, hiddenDateAndCvcMock);
7880

7981
// Card out of date

packages/e2e-playwright/tests/utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const BIN_LOOKUP_VERSION = 'v3';
22

33
export const REGULAR_TEST_CARD = '5500000000000004';
4+
export const VISA_CARD = '4111111111111111';
45
export const AMEX_CARD = '370000000000002';
56
export const KOREAN_TEST_CARD = '9490220006611406'; // 9490220006611406 works against Test. For localhost:8080 use: 5067589608564358 + hack in triggerBinLookup
67
export const BCMC_CARD = '6703444444444449'; // actually dual branded bcmc & maestro

0 commit comments

Comments
 (0)