DigitalConsumer.FixMyGlass/playwright-tests/pages/InsuranceDetailsPage.ts
2026-05-08 10:54:06 -04:00

61 lines
No EOL
2.6 KiB
TypeScript

import { type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { step } from 'framework/localTypes/Step';
import { ITestData } from 'framework/TestData';
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export class InsuranceDetailsPage extends BasePage {
readonly page: Page;
readonly insuranceCompany: Locator;
readonly policyNumber: Locator;
readonly dateOfLoss: Locator;
readonly damageCause: Locator;
readonly claimNumber: Locator; // conditional — only shown for certain insurers like Kentucky Farm Bureau
readonly streetAddress: Locator;
readonly apartment: Locator;
readonly city: Locator;
readonly policyState: Locator;
readonly policyZip: Locator;
constructor(page: Page) {
super(page);
this.page = page;
this.insuranceCompany = page.getByLabel('Insurance company');
this.policyNumber = page.getByLabel('Policy number');
this.dateOfLoss = page.getByLabel('Approximate date of loss');
this.claimNumber = page.getByLabel('Claim Number');
this.damageCause = page.getByLabel('How did the damage occur?');
this.streetAddress = page.getByLabel('Street address');
this.apartment = page.getByLabel('Apt. number (optional)');
this.city = page.getByLabel('City');
this.policyState = page.getByLabel('State');
this.policyZip = page.getByLabel('Zip');
}
private async populatePage(testData: Partial<ITestData>): Promise<void> {
const { claimDetails, customerDetails } = testData;
await this.policyNumber.fill(claimDetails!.policyNumber);
await this.dateOfLoss.fill(claimDetails!.damageDate);
await this.damageCause.selectOption(claimDetails!.damageCause);
await this.streetAddress.fill(customerDetails!.address.street);
await this.apartment.fill(customerDetails!.address.aptNumber ?? '');
await this.city.fill(customerDetails!.address.city);
await this.policyState.selectOption(customerDetails!.address.state);
await this.policyZip.fill(customerDetails!.address.postalCode);
if (await this.claimNumber.isVisible()) {
await this.claimNumber.fill(claimDetails!.claimNumber ?? '');
}
}
@step("InsuranceDetailsPage >> Fill out insurance details for non integrated insurance flow")
async handleInsuranceDetailsPage(testData: Partial<ITestData>): Promise<void> {
await this.validateProgressBar(ProgressBarPercentages.InsuranceDetailsPage);
await this.populatePage(testData);
await this.nextPage();
}
}