51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { type Locator, type Page, expect } from '@playwright/test';
|
|
import { BasePage } from './BasePage';
|
|
import { step } from 'framework/localTypes/Step';
|
|
import { ICustomerDetails } from 'safelite-playwright-core';
|
|
import { ITestData } from 'framework/TestData';
|
|
|
|
export class BailoutPage extends BasePage {
|
|
readonly page: Page;
|
|
readonly firstNameTextBox: Locator;
|
|
readonly lastNameTextBox: Locator;
|
|
readonly emailAddressTextBox: Locator;
|
|
readonly phoneNumberTextBox: Locator;
|
|
readonly textOptInBox: Locator;
|
|
|
|
constructor(page: Page) {
|
|
super(page);
|
|
this.page = page;
|
|
|
|
this.firstNameTextBox = this.page.getByRole('textbox', { name: 'First name' });
|
|
this.lastNameTextBox = this.page.getByRole('textbox', { name: 'Last name' });
|
|
this.emailAddressTextBox = this.page.getByRole('textbox', { name: 'Email address' });
|
|
this.phoneNumberTextBox = this.page.getByRole('textbox', { name: 'Phone number' });
|
|
this.textOptInBox = this.page.getByRole('checkbox', { name: 'Opt in to SMS' });
|
|
}
|
|
|
|
async fillOutBailoutForm(customerDetails: ICustomerDetails) {
|
|
await this.firstNameTextBox.fill(customerDetails!.firstName!);
|
|
await this.lastNameTextBox.fill(customerDetails!.lastName!);
|
|
await this.emailAddressTextBox.fill(customerDetails!.email!);
|
|
await this.phoneNumberTextBox.fill(customerDetails!.phoneNumber!);
|
|
}
|
|
|
|
async checkTextMeUpdates(customerDetails: ICustomerDetails) {
|
|
await this.textOptInBox.check();
|
|
}
|
|
|
|
@step("BailoutPage >> Fill out bailout form: ")
|
|
async handleBailoutPage(testData: Partial<ITestData>) {
|
|
|
|
const { customerDetails } = testData;
|
|
|
|
await expect(this.page).toHaveURL(/bailout/);
|
|
await this.fillOutBailoutForm(customerDetails!);
|
|
|
|
if (testData.isOptedInForTextMessages) {
|
|
await this.checkTextMeUpdates(customerDetails!);
|
|
}
|
|
|
|
await this.nextPage();
|
|
}
|
|
}
|