-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validating postal code when billingAddressMode is partial (#1924)
* feat: validating zipcode * feat: added e2e tests * fix: setting validation to null if no partial mode * fix: removed log
- Loading branch information
1 parent
8fad8fc
commit 18d6625
Showing
10 changed files
with
120 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const CLIENTSCRIPT_PARTIAL_AVS_WITH_COUNTRY = ` | ||
window.cardConfig = { | ||
billingAddressRequired: true, | ||
billingAddressMode: 'partial', | ||
data: { | ||
billingAddress: { | ||
country: 'BR' | ||
} | ||
} | ||
}; | ||
`; | ||
|
||
const CLIENTSCRIPT_PARTIAL_AVS_WITHOUT_COUNTRY = ` | ||
window.cardConfig = { | ||
billingAddressRequired: true, | ||
billingAddressMode: 'partial' | ||
}; | ||
`; | ||
|
||
export { CLIENTSCRIPT_PARTIAL_AVS_WITH_COUNTRY, CLIENTSCRIPT_PARTIAL_AVS_WITHOUT_COUNTRY }; |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { CARDS_URL } from '../../pages'; | ||
import { start } from '../../utils/commonUtils'; | ||
import { REGULAR_TEST_CARD } from '../utils/constants'; | ||
import CardComponentPage from '../../_models/CardComponent.page'; | ||
import { CLIENTSCRIPT_PARTIAL_AVS_WITH_COUNTRY, CLIENTSCRIPT_PARTIAL_AVS_WITHOUT_COUNTRY } from './avs.partial.clientScripts'; | ||
|
||
const TEST_SPEED = 1; | ||
const INVALID_POSTALCODE = 'aaaaaaaaaa'; | ||
|
||
let cardPage = null; | ||
|
||
fixture`Card with Partial AVS`.page(CARDS_URL).beforeEach(() => { | ||
cardPage = new CardComponentPage(); | ||
}); | ||
|
||
test('should validate Postal Code if property data.billingAddress.country is provided', async t => { | ||
await start(t, 2000, TEST_SPEED); | ||
|
||
await cardPage.cardUtils.fillCardNumber(t, REGULAR_TEST_CARD); | ||
await cardPage.cardUtils.fillDateAndCVC(t); | ||
|
||
await t.typeText(cardPage.postalCodeInput, INVALID_POSTALCODE); | ||
await t.click(cardPage.payButton); | ||
|
||
await t.expect(cardPage.postalCodeErrorText.innerText).contains('Invalid format. Expected format: 99999999'); | ||
}).clientScripts({ content: CLIENTSCRIPT_PARTIAL_AVS_WITH_COUNTRY }); | ||
|
||
test('should not validate Postal Code if property data.billingAddress.country is not provided', async t => { | ||
await t.setNativeDialogHandler(() => true); | ||
await start(t, 2000, TEST_SPEED); | ||
|
||
await cardPage.cardUtils.fillCardNumber(t, REGULAR_TEST_CARD); | ||
await cardPage.cardUtils.fillDateAndCVC(t); | ||
|
||
await t.typeText(cardPage.postalCodeInput, INVALID_POSTALCODE); | ||
await t.click(cardPage.payButton); | ||
|
||
// Check the value of the alert text | ||
const history = await t.getNativeDialogHistory(); | ||
await t.expect(history[0].text).eql('Authorised'); | ||
}).clientScripts({ content: CLIENTSCRIPT_PARTIAL_AVS_WITHOUT_COUNTRY }); |
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
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
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