-
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.
- Loading branch information
1 parent
52fe294
commit 8ab24c1
Showing
10 changed files
with
508 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Base } from './base'; | ||
import { Address } from './address'; | ||
import { Page } from '@playwright/test'; | ||
import { PersonalDetails } from './personal-details'; | ||
|
||
class Boleto extends Base { | ||
readonly billingAddress: Address; | ||
readonly personalDetails: PersonalDetails; | ||
|
||
constructor(page: Page) { | ||
super(page); | ||
this.personalDetails = new PersonalDetails(page, { socialSecurityLabel: 'CPF/CNPJ' }); | ||
this.billingAddress = new Address(page); | ||
} | ||
|
||
get barcodeLocator() { | ||
return this.page.locator('.adyen-checkout__voucher-result__code > img'); | ||
} | ||
} | ||
|
||
export default Boleto; |
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,35 @@ | ||
import { Locator, Page } from '@playwright/test'; | ||
|
||
class PersonalDetails { | ||
readonly rootElement: Locator; | ||
readonly rootElementSelector: string; | ||
|
||
// Social security label varies per country | ||
private readonly socialSecurityLabel: string; | ||
|
||
constructor( | ||
public readonly page: Page, | ||
options?: { | ||
rootElementSelector?: string; | ||
socialSecurityLabel?: string; | ||
} | ||
) { | ||
this.rootElementSelector = options.rootElementSelector || '.adyen-checkout__fieldset--personalDetails'; | ||
this.rootElement = page.locator(this.rootElementSelector); | ||
this.socialSecurityLabel = options?.socialSecurityLabel || 'Social security number'; | ||
} | ||
|
||
get firstNameInput() { | ||
return this.rootElement.getByRole('textbox', { name: /first name/i }); | ||
} | ||
|
||
get lastNameInput() { | ||
return this.rootElement.getByRole('textbox', { name: /last name/i }); | ||
} | ||
|
||
get socialSecurityNumberInput() { | ||
return this.rootElement.getByRole('textbox', { name: this.socialSecurityLabel }); | ||
} | ||
} | ||
|
||
export { PersonalDetails }; |
90 changes: 23 additions & 67 deletions
90
packages/e2e-playwright/tests/e2e/vouchers/boleto/boleto.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,75 +1,31 @@ | ||
import { test } from '@playwright/test'; | ||
import { test as base, expect } from '@playwright/test'; | ||
import Boleto from '../../../../models/boleto'; | ||
import { URL_MAP } from '../../../../fixtures/URL_MAP'; | ||
|
||
const getComponentData = () => { | ||
return globalThis.boletoInput.data; | ||
type Fixture = { | ||
boleto: Boleto; | ||
}; | ||
|
||
const mockData = { | ||
shopperName: { | ||
firstName: 'Tom', | ||
lastName: 'Jobim' | ||
}, | ||
socialSecurityNumber: '32553325916', | ||
billingAddress: { | ||
country: 'BR', | ||
street: 'Fake street', | ||
houseNumberOrName: '123', | ||
city: 'Sao Paulo', | ||
postalCode: '11111555', | ||
stateOrProvince: 'SP' | ||
}, | ||
shopperEmail: 'shopper@adyen.nl' | ||
}; | ||
const test = base.extend<Fixture>({ | ||
boleto: async ({ page }, use) => { | ||
const boleto = new Boleto(page); | ||
await boleto.goto(URL_MAP.boleto); | ||
await use(boleto); | ||
} | ||
}); | ||
|
||
async function fillBoleto(t) { | ||
// await t | ||
// .typeText('.boleto-input .adyen-checkout__field--firstName .adyen-checkout__input', mockData.shopperName.firstName) | ||
// .typeText('.boleto-input .adyen-checkout__field--lastName .adyen-checkout__input', mockData.shopperName.lastName) | ||
// .typeText('.boleto-input .adyen-checkout__field--socialSecurityNumber .adyen-checkout__input', mockData.socialSecurityNumber) | ||
// .typeText('.boleto-input .adyen-checkout__input--street', mockData.billingAddress.street) | ||
// .typeText('.boleto-input .adyen-checkout__input--houseNumberOrName', mockData.billingAddress.houseNumberOrName) | ||
// .typeText('.boleto-input .adyen-checkout__input--city', mockData.billingAddress.city) | ||
// .typeText('.boleto-input .adyen-checkout__input--postalCode', mockData.billingAddress.postalCode) | ||
// .click(Selector('.boleto-input .adyen-checkout__field--stateOrProvince .adyen-checkout__dropdown__button')) | ||
// .click(Selector('.boleto-input [data-value=SP]')); | ||
} | ||
test('should make a Boleto payment', async ({ boleto, page }) => { | ||
await boleto.personalDetails.firstNameInput.fill('Jose'); | ||
await boleto.personalDetails.lastNameInput.fill('Fernandez'); | ||
await boleto.personalDetails.socialSecurityNumberInput.fill('56861752509'); | ||
|
||
test('should make a Boleto payment', async () => { | ||
// await fillBoleto(t); | ||
// const stateData = await getComponentData(); | ||
// | ||
// await t | ||
// .expect(stateData.paymentMethod.type) | ||
// .eql('boletobancario') | ||
// .expect(stateData.shopperName) | ||
// .eql(mockData.shopperName) | ||
// .expect(stateData.socialSecurityNumber) | ||
// .eql(mockData.socialSecurityNumber) | ||
// .expect(stateData.billingAddress) | ||
// .eql(mockData.billingAddress) | ||
// .expect(getIsValid('boletoInput')) | ||
// .eql(true); | ||
}); | ||
await boleto.billingAddress.streetInput.fill('Main St'); | ||
await boleto.billingAddress.houseNumberInput.fill('1'); | ||
await boleto.billingAddress.postalCodeInput.fill('13010111'); | ||
await boleto.billingAddress.cityInput.fill('Capital'); | ||
await boleto.billingAddress.selectState({ name: 'São Paulo' }); | ||
|
||
test('should not submit a Boleto payment if the form in not valid', async () => {}); | ||
await boleto.pay({ name: 'Generate Boleto' }); | ||
|
||
test('should allow shoppers to send a copy to their email and make a Boleto payment', async () => { | ||
// await fillBoleto(t); | ||
// await t.expect(getIsValid('boletoInput')).eql(true); | ||
// | ||
// await t.click(Selector('.boleto-input .adyen-checkout__field--sendCopyToEmail .adyen-checkout__checkbox')); | ||
// await t.expect(getIsValid('boletoInput')).eql(false); | ||
// | ||
// await t.typeText('.boleto-input .adyen-checkout__input--email', mockData.shopperEmail); | ||
// await t.expect(getIsValid('boletoInput')).eql(true); | ||
// | ||
// const stateData = await getComponentData(); | ||
// | ||
// await t | ||
// .expect(stateData.paymentMethod.type) | ||
// .eql('boletobancario') | ||
// .expect(stateData.shopperEmail) | ||
// .eql(mockData.shopperEmail) | ||
// .expect(getIsValid('boletoInput')) | ||
// .eql(true); | ||
await expect(boleto.barcodeLocator).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
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
Oops, something went wrong.