-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring panLength.focus.avs.spec.ts to work in new framework
- Loading branch information
Showing
3 changed files
with
28 additions
and
39 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
52 changes: 16 additions & 36 deletions
52
packages/e2e-playwright/tests/ui/card/binLookup/panLength/panLength.focus.avs.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,44 +1,24 @@ | ||
import { test } from '@playwright/test'; | ||
import { mocks } from './mocks'; | ||
import { binLookupUrl, getBinLookupMock, turnOffSDKMocking } from '../../cardMocks'; | ||
import { test, expect } from '../../../../../fixtures/card.fixture'; | ||
import { getStoryUrl } from '../../../../utils/getStoryUrl'; | ||
import { URL_MAP } from '../../../../../fixtures/URL_MAP'; | ||
import { binLookupMock } from '../../../../../mocks/binLookup/binLookup.mock'; | ||
import { optionalDateAndCvcWithPanLengthMock } from '../../../../../mocks/binLookup/binLookup.data'; | ||
import { REGULAR_TEST_CARD } from '../../../../utils/constants'; | ||
|
||
/** | ||
* NOTE - we are mocking the response until such time as we have a genuine card that returns the properties we want to test | ||
*/ | ||
test.describe('Test Card, binLookup w. panLength property & address fields', () => { | ||
test('#1 Fill out PAN & see that focus moves to an address field since expiryDate & cvc are optional', async ({ card, page }) => { | ||
await binLookupMock(page, optionalDateAndCvcWithPanLengthMock); | ||
|
||
let currentMock = null; | ||
const componentConfig = { billingAddressRequired: true, billingAddressRequiredFields: ['street', 'houseNumberOrName', 'postalCode', 'city'] }; | ||
|
||
const getMock = val => { | ||
const mock = mocks[val]; | ||
currentMock = getBinLookupMock(binLookupUrl, mock); | ||
return currentMock; | ||
}; | ||
await card.goto(getStoryUrl({ baseUrl: URL_MAP.card, componentConfig })); | ||
|
||
test.describe('Test how Card Component handles binLookup returning a panLength property for a card with address fields', () => { | ||
// use config from panLength.avs.clientScripts.js | ||
await card.isComponentVisible(); | ||
|
||
test.beforeEach(async () => { | ||
// todo: go to the card page | ||
// For individual test suites (that rely on binLookup & perhaps are being run in isolation) | ||
// - provide a way to ensure SDK bin mocking is turned off | ||
await turnOffSDKMocking(); | ||
}); | ||
await card.typeCardNumber(REGULAR_TEST_CARD); | ||
|
||
test('#1 Fill out PAN (binLookup w. panLength) see that focus moves to an address field since expiryDate & cvc are optional', async () => { | ||
// use mock await t.addRequestHooks(getMock('optionalDateAndCVC')); | ||
// Wait for field to appear in DOM | ||
// await cardPage.numHolder(); | ||
// | ||
// const firstDigits = REGULAR_TEST_CARD.substring(0, 15); | ||
// const lastDigits = REGULAR_TEST_CARD.substring(15, 16); | ||
// | ||
// await cardPage.cardUtils.fillCardNumber(t, firstDigits); | ||
// | ||
// await t.wait(INPUT_DELAY); | ||
// | ||
// await cardPage.cardUtils.fillCardNumber(t, lastDigits); | ||
// | ||
// // Expect focus to be place on address (street) field | ||
// await t.expect(cardPage.addressLabelWithFocus.exists).ok(); | ||
// Expect focus to be place on address (street) field | ||
await expect(card.cardNumberLabelWithFocus).not.toBeVisible(); | ||
await expect(card.addressLabelWithFocus).toBeVisible(); | ||
}); | ||
}); |
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