DigitalConsumer.ISS/playwright-tests/pages/VinLookupPage.ts
Rob Donahey d539df9550
Feature/insr 7038: Playwright tests for big truck scenarios (#963)
List of commits in this pr:

* Begin essential Playwright test cases for big truck

* Implement non serviceable big truck vin lookup and fix test case tags

* Rename non serviceable vin cases

* Common sense .env.dev example

* Move extraneous stuff to .env.example

* Add playwright environment file to gitignore

* Stop tracking .env.dev

* Specify file ignore

* Ignore .env

* Implement advanced tests for big truck

* Remove duplicate smoke test

* Implement PR feedback

* Add  comments to type definitions for clarity for any future uses

* More descriptive env comment
2025-10-16 16:07:01 -04:00

49 lines
1.8 KiB
TypeScript

import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
export class VinLookupPage extends BasePage {
readonly page: Page;
readonly vinLookupTextBox: Locator;
readonly lookupVinForMe: Locator;
readonly vinMismatchAlert: Locator;
issPageValue = 'vin-lookup';
constructor(page: Page) {
super(page);
this.page = page;
this.vinLookupTextBox = page.getByRole('textbox', { name: 'Enter your VIN' });
this.lookupVinForMe = page.getByRole('link', { name: 'look up your VIN' });
this.vinMismatchAlert = page.getByLabel('vehicle-not-matched-alert');
// this.validateURL(this.url);
}
async enterVin(vin: string | string[], isVehicleLookupValidations = false) {
if (Array.isArray(vin)) {
if (vin.length > 1) {
if (isVehicleLookupValidations) {
await this.vinLookupTextBox.fill(vin[0]);
await this.continueButton.click({ timeout: 1000 });
await expect(this.vinMismatchAlert).toBeVisible();
await this.vinLookupTextBox.fill(vin[1]);
}
} else {
console.warn("VIN array is blank. Either provide VIN as string or string[]")
}
} else {
await this.vinLookupTextBox.fill(vin);
}
}
async triggerBailout() {
await this.continueButton.click();
await this.lookupVinForMe.click();
}
async handleNonServiceableVin() {
await this.continueButton.click();
const nonServiceableWarning = this.page.getByText('Service not available for your vehicle');
await expect(nonServiceableWarning).toBeVisible();
await expect(this.continueButton).toBeDisabled();
}
}