DigitalConsumer.FixMyGlass/playwright-tests/pages/VehicleLookupLicensePage.ts
maguire-arman 458e552d6b Removes URL declaration from page classes
Removes the explicit URL declaration from the page classes.

The URL validation and navigation are now handled directly within the tests, providing greater flexibility and control over test execution and removing the need to manage URLs within each page object.
2025-07-14 16:13:56 -04:00

44 lines
No EOL
2.1 KiB
TypeScript

import { type Locator, type Page } from '@playwright/test';
import { LookupPage } from './LookupPage';
import { IVehicleDetails } from 'safelite-playwright-core';
import { step } from 'framework/localTypes/Step';
import { ITestData } from 'framework/TestData';
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export class VehicleLookupLicensePage extends LookupPage {
readonly licensePlateNumTextBox: Locator;
readonly licensePlateStateDrpDwn: Locator;
constructor(page: Page) {
super(page);
this.licensePlateNumTextBox = page.getByRole('textbox', { name: 'License plate number'});
this.licensePlateStateDrpDwn = page.getByRole('combobox', { name: 'License plate state'});
// Override the service zip textbox locator for license-specific label
this.serviceZipTextBox = page.getByRole('textbox', { name: 'ZIP code on vehicle' });
// Override the unserviceableZipAlertMessage for license-specific message
this.unserviceableZipAlertMessage = this.page.locator('div.alert-danger.widget-name-AlertVinNotFoundWidget',
{ hasText: "Your license plate didn't return a VIN match." });
}
async enterPlateDetails(vehicleDetails: IVehicleDetails) {
let licensePlateNumber: string;
if (Array.isArray(vehicleDetails.licensePlate)) {
licensePlateNumber = vehicleDetails.licensePlate[0].licensePlateNumber;
} else {
licensePlateNumber = vehicleDetails.licensePlate?.licensePlateNumber || '';
}
await this.licensePlateNumTextBox.fill(licensePlateNumber);
}
@step("VehicleLookupLicensePage >> Lookup by license plate: ")
async handleVehicleLookupLicensePage(testData: Partial<ITestData>) {
const { customerDetails, vehicleDetails, alertFlags } = testData;
await this.validateProgressBar(ProgressBarPercentages.VehicleLookupLicensePage);
await this.enterPlateDetails(vehicleDetails!);
await this.enterZip(customerDetails!.address.postalCode!);
await this.handleZipValidation(customerDetails!.address.postalCode!, vehicleDetails!.vehicleLookupType!, alertFlags!);
}
}