DigitalConsumer.ISS/playwright-tests/pages/VehicleLookupLicensePage.ts
2026-03-19 10:53:55 -04:00

40 lines
No EOL
2.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 didnt 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!);
}
}