DigitalConsumer.FixMyGlass/playwright-tests/pages/VinLookupPage.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

41 lines
No EOL
1.7 KiB
TypeScript

import { type Locator, type Page } from '@playwright/test';
import { LookupPage } from './LookupPage';
import { step } from 'framework/localTypes/Step';
import { ITestData } from 'framework/TestData';
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export class VinLookupPage extends LookupPage {
readonly vinLookupTextBox: Locator;
readonly invalidVinInlineError: Locator;
readonly cameraButton: Locator;
readonly whereCanIFindMyVinLink: Locator;
constructor(page: Page) {
super(page);
this.vinLookupTextBox = page.getByRole('textbox', { name: 'Enter your VIN' });
this.invalidVinInlineError = this.page.locator('span.d-inline-flex.small.mt-1:has-text("Invalid VIN")');
this.cameraButton = this.page.getByRole('textbox', { name: 'Camera icon/button' });
this.whereCanIFindMyVinLink = this.page.getByRole('link', { name: 'Where can I find my VIN?', exact: true });
}
async enterVin(vin: string) {
await this.vinLookupTextBox.fill(vin);
}
@step("VinLookupPage >> Lookup by VIN: ")
async handleVehicleLookupVinPage(testData: Partial<ITestData>) {
const { customerDetails, vehicleDetails, alertFlags } = testData;
let vin: string;
if (Array.isArray(vehicleDetails?.vin)) {
vin = vehicleDetails.vin[0];
} else {
vin = vehicleDetails?.vin || '';
}
await this.validateProgressBar(ProgressBarPercentages.VinLookupPage);
await this.enterVin(vin);
await this.enterZip(customerDetails!.address.postalCode!);
await this.handleZipValidation(customerDetails!.address.postalCode!, vehicleDetails!.vehicleLookupType!, alertFlags!);
}
}