|
1 | 1 | import { test, expect } from '../../pages/cards/card.fixture';
|
2 | 2 | import { REGULAR_TEST_CARD, TEST_CVC_VALUE, TEST_DATE_VALUE } from '../utils/constants';
|
3 | 3 | import LANG from '../../../server/translations/en-US.json';
|
| 4 | +import { pressEnter } from '../utils/keyboard'; |
4 | 5 |
|
5 | 6 | const PAN_ERROR_NOT_VALID = LANG['cc.num.902'];
|
6 | 7 | const PAN_ERROR_EMPTY = LANG['cc.num.900'];
|
7 | 8 | const PAN_ERROR_NOT_COMPLETE = LANG['cc.num.901'];
|
8 | 9 |
|
| 10 | +const EXPIRY_DATE_ERROR_EMPTY = LANG['cc.dat.910']; |
| 11 | +const CVC_ERROR_EMPTY = LANG['cc.cvc.920']; |
| 12 | + |
9 | 13 | test.describe('Card - Standard flow', () => {
|
10 | 14 | test('#1 Should fill in card fields and complete the payment', async ({ cardPage }) => {
|
11 | 15 | const { card, page } = cardPage;
|
@@ -49,4 +53,35 @@ test.describe('Card - Standard flow', () => {
|
49 | 53 | await expect(card.cardNumberErrorElement).toBeVisible();
|
50 | 54 | await expect(card.cardNumberErrorElement).toHaveText(PAN_ERROR_NOT_COMPLETE);
|
51 | 55 | });
|
| 56 | + |
| 57 | + test('#5 Filling PAN then pressing Enter will trigger validation ', async ({ cardPage }) => { |
| 58 | + const { card, page } = cardPage; |
| 59 | + |
| 60 | + await card.isComponentVisible(); |
| 61 | + await card.typeCardNumber(REGULAR_TEST_CARD); |
| 62 | + |
| 63 | + await pressEnter(page); |
| 64 | + |
| 65 | + await page.waitForTimeout(500); // wait for UI to show errors |
| 66 | + |
| 67 | + await expect(card.expiryDateErrorElement).toBeVisible(); |
| 68 | + await expect(card.expiryDateErrorElement).toHaveText(EXPIRY_DATE_ERROR_EMPTY); |
| 69 | + |
| 70 | + await expect(card.cvcErrorElement).toBeVisible(); |
| 71 | + await expect(card.cvcErrorElement).toHaveText(CVC_ERROR_EMPTY); |
| 72 | + }); |
| 73 | + |
| 74 | + test('#6 Filling in card fields then pressing Enter will trigger submission ', async ({ cardPage }) => { |
| 75 | + const { card, page } = cardPage; |
| 76 | + |
| 77 | + await card.isComponentVisible(); |
| 78 | + |
| 79 | + await card.typeCardNumber(REGULAR_TEST_CARD); |
| 80 | + await card.typeCvc(TEST_CVC_VALUE); |
| 81 | + await card.typeExpiryDate(TEST_DATE_VALUE); |
| 82 | + |
| 83 | + await pressEnter(page); |
| 84 | + |
| 85 | + await expect(page.locator('#result-message')).toHaveText('Authorised'); |
| 86 | + }); |
52 | 87 | });
|
0 commit comments