Clean up logic for Afterpay flow
This commit is contained in:
parent
58b497fcc4
commit
75e84452a8
1 changed files with 4 additions and 28 deletions
|
|
@ -4,51 +4,27 @@ import { IPaymentDetails } from "@business-logic/types/CustomerDetails";
|
||||||
|
|
||||||
export class AfterpayPage extends BasePage {
|
export class AfterpayPage extends BasePage {
|
||||||
readonly page: Page;
|
readonly page: Page;
|
||||||
readonly submitButton: Locator;
|
|
||||||
|
|
||||||
// Login
|
|
||||||
readonly passwordTextBox: Locator;
|
readonly passwordTextBox: Locator;
|
||||||
|
readonly submitButton: Locator;
|
||||||
// Card details
|
|
||||||
readonly cardholderNameTextBox: Locator;
|
|
||||||
readonly cardNumberTextBox: Locator;
|
|
||||||
readonly expirationDateTextBox: Locator;
|
|
||||||
readonly cvvTextBox: Locator;
|
|
||||||
|
|
||||||
readonly confirmButton: Locator;
|
readonly confirmButton: Locator;
|
||||||
|
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
super(page);
|
super(page);
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.passwordTextBox = page.getByRole('textbox', { name: 'Please enter your password' });
|
this.passwordTextBox = page.getByTestId('login-password-input');
|
||||||
this.submitButton = page.getByRole('button', { name: 'Continue' });
|
this.submitButton = page.getByRole('button', { name: 'Continue' });
|
||||||
|
|
||||||
this.cardholderNameTextBox = page.getByTestId('payment-method-cardHolderName-input');
|
|
||||||
this.cardNumberTextBox = page.getByTestId('payment-method-cardNumber-input');
|
|
||||||
this.expirationDateTextBox = page.getByTestId('payment-method-cardExpiry-input');
|
|
||||||
this.cvvTextBox = page.getByTestId('payment-method-cardCvv-input');
|
|
||||||
|
|
||||||
this.confirmButton = page.getByRole('button', { name: 'Confirm' });
|
this.confirmButton = page.getByRole('button', { name: 'Confirm' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async login(password: string) {
|
async login(password: string) {
|
||||||
|
await this.passwordTextBox.click();
|
||||||
await this.passwordTextBox.fill(password);
|
await this.passwordTextBox.fill(password);
|
||||||
await this.submitButton.click();
|
await this.submitButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async populateCardDetails(paymentDetails: IPaymentDetails) {
|
|
||||||
await this.cardholderNameTextBox.fill('Roberts'); // TODO: Add cardholder name field
|
|
||||||
await this.cardNumberTextBox.fill(paymentDetails.cardNumber!);
|
|
||||||
await this.expirationDateTextBox.fill(`${paymentDetails.expirationMonth}/${paymentDetails.expirationYear}`);
|
|
||||||
await this.cvvTextBox.fill(paymentDetails.cvv!);
|
|
||||||
await this.submitButton.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
async executeAfterpayPayment(paymentDetails: IPaymentDetails) {
|
async executeAfterpayPayment(paymentDetails: IPaymentDetails) {
|
||||||
await this.login(paymentDetails.password!);
|
await this.login(paymentDetails.password!);
|
||||||
|
|
||||||
await this.populateCardDetails(paymentDetails);
|
|
||||||
|
|
||||||
await this.confirmButton.click();
|
await this.confirmButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue