-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for
errorPanel.card.visible.spec.ts
and refactor custom…
… card models (#3057) * test(errorPanel.card.visible.spec.ts): added test * test(e2e): use `pressSequentially` for `customCard.ts` and `customCardSeparateExpiryDate.ts` models * test(e2e): added tests for customCard.spec.ts
- Loading branch information
1 parent
2c6271f
commit 0b5ebb7
Showing
10 changed files
with
76 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 49 additions & 22 deletions
71
packages/e2e-playwright/tests/a11y/card/errorPanel.card.visible.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,55 @@ | ||
import { test } from '@playwright/test'; | ||
import { mergeTests, expect } from '@playwright/test'; | ||
import { test as card } from '../../../fixtures/card.fixture'; | ||
import { test as srPanel } from '../../../fixtures/srPanel.fixture'; | ||
import { URL_MAP } from '../../../fixtures/URL_MAP'; | ||
import { REGULAR_TEST_CARD } from '../../utils/constants'; | ||
|
||
test('#1 Error panel is present at start, when there are no errors, but is empty', async () => { | ||
// Wait for field to appear in DOM | ||
// error panel exists but is empty | ||
const test = mergeTests(card, srPanel); | ||
|
||
test('#1 Error panel is present at start, when there are no errors, but is empty', async ({ card, srPanel }) => { | ||
await card.goto(URL_MAP.cardWithVisibleSrPanel); | ||
expect(await srPanel.allMessages).toHaveLength(0); | ||
}); | ||
|
||
test('#2 Click pay with empty fields and error panel is populated', async () => { | ||
// Wait for field to appear in DOM | ||
// click pay, to validate & generate errors | ||
// Expect 3 elements, in order, with specific text | ||
// expect(cardPage.errorPanelEls.nth(0).withExactText(CARD_NUMBER_EMPTY).exists) | ||
// expect(cardPage.errorPanelEls.nth(1).withExactText(EXPIRY_DATE_EMPTY).exists) | ||
// expect(cardPage.errorPanelEls.nth(2).withExactText(CVC_EMPTY).exists) | ||
// no 4th element | ||
// Expect focus to be place on Card number field - since SRConfig for this card comp says it should be | ||
test('#2 Click pay with empty fields and error panel is populated', async ({ card, srPanel, page, browserName }) => { | ||
const expectedSRPanelTexts = ['Enter the card number-sr', 'Enter the expiry date-sr', 'Enter the security code-sr']; | ||
await card.goto(URL_MAP.cardWithVisibleSrPanel); | ||
await card.pay(); | ||
// Wait for all sr panel messages | ||
await page.waitForFunction( | ||
expectedLength => [...document.querySelectorAll('.adyen-checkout-sr-panel__msg')].map(el => el.textContent).length === expectedLength, | ||
expectedSRPanelTexts.length | ||
); | ||
// check individual messages | ||
const srErrorMessages = await srPanel.allMessages; | ||
srErrorMessages.forEach((retrievedText, index) => { | ||
expect(retrievedText).toHaveText(expectedSRPanelTexts[index]); | ||
}); | ||
if (browserName !== 'firefox') { | ||
await expect(card.cardNumberInput).toBeFocused(); | ||
} else { | ||
console.log('Skipping focus check for Firefox'); | ||
} | ||
}); | ||
|
||
test('#3 Fill out PAN & see that first error in error panel is date related', async () => { | ||
// Wait for field to appear in DOM | ||
// await cardPage.cardUtils.fillCardNumber(t, REGULAR_TEST_CARD); | ||
// click pay, to validate & generate errors | ||
// Expect 2 elements, in order, with specific text | ||
// expect(cardPage.errorPanelEls.nth(0).withExactText(EXPIRY_DATE_EMPTY).exists) | ||
// expect(cardPage.errorPanelEls.nth(1).withExactText(CVC_EMPTY).exists) | ||
// no 3rd element | ||
// Expect focus to be place on Expiry date field | ||
test('#3 Fill out PAN & see that first error in error panel is date related', async ({ card, srPanel, page, browserName }) => { | ||
const expectedSRPanelTexts = ['Enter the expiry date-sr', 'Enter the security code-sr']; | ||
await card.goto(URL_MAP.cardWithVisibleSrPanel); | ||
await card.fillCardNumber(REGULAR_TEST_CARD); | ||
await card.pay(); | ||
// Wait for all sr panel messages | ||
await page.waitForFunction( | ||
expectedLength => [...document.querySelectorAll('.adyen-checkout-sr-panel__msg')].map(el => el.textContent).length === expectedLength, | ||
expectedSRPanelTexts.length | ||
); | ||
// check individual messages | ||
const srErrorMessages = await srPanel.allMessages; | ||
srErrorMessages.forEach((retrievedText, index) => { | ||
expect(retrievedText).toHaveText(expectedSRPanelTexts[index]); | ||
}); | ||
if (browserName !== 'firefox') { | ||
await expect(card.expiryDateInput).toBeFocused(); | ||
} else { | ||
console.log('Skipping focus check for Firefox'); | ||
} | ||
}); |
13 changes: 11 additions & 2 deletions
13
packages/e2e-playwright/tests/e2e/customCard/customCard.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
import { test, expect } from '../../../fixtures/customCard.fixture'; | ||
import { PAYMENT_RESULT, REGULAR_TEST_CARD, TEST_CVC_VALUE, TEST_DATE_VALUE } from '../../utils/constants'; | ||
import { PAYMENT_RESULT, REGULAR_TEST_CARD, TEST_CVC_VALUE, TEST_DATE_VALUE, TEST_MONTH_VALUE, TEST_YEAR_VALUE } from '../../utils/constants'; | ||
|
||
test.describe('Custom Card - Standard flow', () => { | ||
test('should fill in card fields and complete the payment', async ({ customCard }) => { | ||
test('should fill out the fields in the regular custom card and make a successful payment', async ({ customCard }) => { | ||
await customCard.typeCardNumber(REGULAR_TEST_CARD); | ||
await customCard.typeExpiryDate(TEST_DATE_VALUE); | ||
await customCard.typeCvc(TEST_CVC_VALUE); | ||
await customCard.pay(); | ||
await expect(customCard.paymentResult).toContainText(PAYMENT_RESULT.authorised); | ||
}); | ||
|
||
test('should fill out the fields in the separate custom card and make a successful payment', async ({ customCardSeparateExpiryDate }) => { | ||
await customCardSeparateExpiryDate.typeCardNumber(REGULAR_TEST_CARD); | ||
await customCardSeparateExpiryDate.typeExpiryMonth(TEST_MONTH_VALUE); | ||
await customCardSeparateExpiryDate.typeExpiryYear(TEST_YEAR_VALUE); | ||
await customCardSeparateExpiryDate.typeCvc(TEST_CVC_VALUE); | ||
await customCardSeparateExpiryDate.pay(); | ||
await expect(customCardSeparateExpiryDate.paymentResult).toContainText(PAYMENT_RESULT.authorised); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
packages/e2e-playwright/tests/ui/customCard/general/general.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters