DigitalConsumer.FixMyGlass/playwright-tests/pages/VehicleLookupAddressPage.ts
2025-05-23 11:58:33 -04:00

40 lines
No EOL
1.9 KiB
TypeScript

import { type Page, Locator } from '@playwright/test';
import { LookupPage } from './LookupPage';
import { AddressForm } from './forms/AddressForm';
import { VehicleSelectionForm } from './forms/VehicleSelectionForm';
import { ICustomerDetails, IVehicleDetails } from '@business-logic/types/CustomerDetails';
import { step } from '@business-logic/types/Step';
import { ITestData } from '@business-logic/types/ITestData';
import { ProgressBarPercentages } from '@business-logic/types/Enums';
export class VehicleLookupAddressPage extends LookupPage {
readonly addressForm: AddressForm;
readonly vehicleSelectionForm: VehicleSelectionForm;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-zip';
constructor(page: Page) {
super(page);
this.addressForm = new AddressForm(page);
this.vehicleSelectionForm = new VehicleSelectionForm(page);
// Override the unserviceableZipAlertMessage for address-specific message
this.unserviceableZipAlertMessage = this.page.locator('div.alert-danger.widget-name-AlertVinNotFoundWidget',
{ hasText: "Your address didn't return a VIN match." });
}
async lookupVehicleByAddress(customerDetails: ICustomerDetails, vehicleDetails: IVehicleDetails) {
await this.addressForm.populateAddress(customerDetails);
//await this.nextPage();
//await this.vehicleSelectionForm.selectVehicle(vehicleDetails);
}
@step("VehicleLookupAddressPage >> Lookup by address: ")
async handleVehicleLookupAddressPage(testData: Partial<ITestData>) {
const { customerDetails, vehicleDetails, alertFlags } = testData;
await this.validateProgressBar(ProgressBarPercentages.VehicleLookupAddressPage);
await this.lookupVehicleByAddress(customerDetails!, vehicleDetails!);
await this.handleZipValidation(customerDetails!.address.postalCode!, vehicleDetails!.vehicleLookupType!, alertFlags!);
}
}