DigitalConsumer.ISS/playwright-tests/pages/AfterpayPage.ts
chase-safelite 5d3ab0ef59
Added playwright tests into repo (#923)
* Initial import of playwright tests

* Pipeline changes for automated tests

* Modified pipeline for testing

* Attempt #2

* Attempt #3

* Added missing paren

* Removed debug stuff from pipeline

* Changes from playwright repo

* Changed pipeline for debugging

* Fix for ServiceLocationPage playwright locators

* Change pipeline to run with TEST APIs

* Moved more of Siraj's changes to this repo

* Changed where updating env occurs

* Changed location of env update again

* Escaped double quotes

* Added visible report in Azure

* Moved changes into main pipeline

* Made it so dotenv only runs config in local
2025-02-14 09:54:11 -05:00

56 lines
No EOL
2 KiB
TypeScript

import { Locator, Page } from "@playwright/test";
import { BasePage } from "./BasePage";
import { IPaymentDetails } from "@business-logic/types/CustomerDetails";
export class AfterpayPage extends BasePage {
readonly page: Page;
readonly submitButton: Locator;
// Login
readonly passwordTextBox: Locator;
// Card details
readonly cardholderNameTextBox: Locator;
readonly cardNumberTextBox: Locator;
readonly expirationDateTextBox: Locator;
readonly cvvTextBox: Locator;
readonly confirmButton: Locator;
constructor(page: Page) {
super(page);
this.page = page;
this.passwordTextBox = page.getByRole('textbox', { name: 'Please enter your password' });
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' });
}
async login(password: string) {
await this.passwordTextBox.fill(password);
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) {
await this.login(paymentDetails.password!);
await this.populateCardDetails(paymentDetails);
await this.confirmButton.click();
}
}