import { expect, type Locator, type Page } from '@playwright/test'; import { BasePage } from './BasePage'; import { IVehicleDetails } from '@business-logic/types/CustomerDetails'; export class VehicleLookupLicensePage extends BasePage { readonly page: Page; readonly licensePlateNumTextBox: Locator; readonly licensePlateStateDrpDwn: Locator; readonly plateNoMatchError: Locator; readonly plateMismatchAlert: Locator; issPageValue = 'license-plate-lookup'; constructor(page: Page) { super(page); this.page = page; this.licensePlateNumTextBox = page.getByRole('textbox', { name: 'License plate number' }); this.licensePlateStateDrpDwn = page.getByRole('combobox', { name: 'License plate state' }); this.plateNoMatchError = page.getByText('Your license plate didn’t return a VIN match.Please re-enter the information'); this.plateMismatchAlert = page.getByText('We found a windshield, but the VIN associated with the license plate you provided is for a'); } async enterPlateDetails(vehicleDetails: IVehicleDetails, isVehicleLookupValidations = false) { if (Array.isArray(vehicleDetails.licensePlateNumber)) { if (isVehicleLookupValidations) { await this.licensePlateNumTextBox.fill(vehicleDetails.licensePlateNumber[0]); await this.continueButton.click({ timeout: 1000 }); await expect(this.plateNoMatchError).toBeVisible(); await this.licensePlateNumTextBox.fill(vehicleDetails.licensePlateNumber[1]); await this.licensePlateStateDrpDwn.selectOption(vehicleDetails.licensePlateState![1]); await this.continueButton.click({ timeout: 1000 }); await expect(this.plateMismatchAlert).toBeVisible(); await this.licensePlateNumTextBox.fill(vehicleDetails.licensePlateNumber[2]); } } else { await this.licensePlateNumTextBox.fill(vehicleDetails.licensePlateNumber || ''); } await this.licensePlateStateDrpDwn.selectOption(vehicleDetails.licensePlateState!); } }