DigitalConsumer.ISS/playwright-tests/pages/VehicleLookupLicensePage.ts
Alex Humphries 49c951fe25 Update validateURL to account for variations in query string
In scenarios that reach the order confirmation page, the query string
includes more than the issPageValue, whiche was breaking validateURL
2025-03-07 11:47:06 -05:00

39 lines
No EOL
1.9 KiB
TypeScript
Raw 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.getByRole('alert').locator('div');
}
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.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!);
}
}