DigitalConsumer.ISS/playwright-tests/pages/VehicleDamagePage.ts
chase-safelite 5d3ab0ef59
Added playwright tests into repo (#923)
* Initial import of playwright tests

* Pipeline changes for automated tests

* Modified pipeline for testing

* Attempt #2

* Attempt #3

* Added missing paren

* Removed debug stuff from pipeline

* Changes from playwright repo

* Changed pipeline for debugging

* Fix for ServiceLocationPage playwright locators

* Change pipeline to run with TEST APIs

* Moved more of Siraj's changes to this repo

* Changed where updating env occurs

* Changed location of env update again

* Escaped double quotes

* Added visible report in Azure

* Moved changes into main pipeline

* Made it so dotenv only runs config in local
2025-02-14 09:54:11 -05:00

150 lines
No EOL
7.3 KiB
TypeScript

import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { SideDoorDamage, VehicleDamage, WindshieldDamage } from '@business-logic/types/Enums';
export class VehicleDamagePage extends BasePage {
readonly page: Page;
readonly windshieldChkBox: Locator;
readonly crackButton: Locator;
readonly chipButton: Locator;
readonly sideDoorButton: Locator;
readonly driverSideButton: Locator;
readonly passengerSideButton: Locator;
readonly driverQuarterPanelChkBox: Locator;
readonly driverFrontDoorChkBox: Locator;
readonly driverBackDoorChkBox: Locator;
readonly driverSlidingDoorChkBox: Locator;
readonly driverVentGlassChkBox: Locator;
readonly passengerQuarterPanelChkBox: Locator;
readonly passengerFrontDoorChkBox: Locator;
readonly passengerBackDoorChkBox: Locator;
readonly passengerVentGlassChkBox: Locator;
readonly rearWindowChkBox: Locator;
readonly separateApptsWarning: Locator;
readonly editVehicleButton: Locator;
url = process.env['BASE_URL']! + '/?issPage=vehicle-damage';
constructor(page: Page) {
super(page);
this.page = page;
this.windshieldChkBox = this.page.locator('[buttonlabel="Windshield"]');
this.crackButton = this.page.locator('[buttonlabel="Crack"]');
this.chipButton = this.page.locator('[buttonlabel="Chip(s)"]');
this.sideDoorButton = this.page.locator('[buttonlabel="Side door"]');
this.driverSideButton = this.page.locator('[buttonlabel="Driver side"]');
this.passengerSideButton = this.page.locator('[buttonlabel="Passenger side"]');
this.driverQuarterPanelChkBox = this.page.locator('[aria-labelledby="driverSideOptions"]').locator('[buttonlabel="Quarter panel"]');
this.driverFrontDoorChkBox = this.page.locator('[aria-labelledby="driverSideOptions"]').locator('[buttonlabel="Front door"]');
this.driverBackDoorChkBox = this.page.locator('[aria-labelledby="driverSideOptions"]').locator('[buttonlabel="Back door"]');
this.driverVentGlassChkBox = this.page.locator('[aria-labelledby="driverSideOptions"]').locator('[buttonlabel="Vent glass"]');
this.driverSlidingDoorChkBox = this.page.locator('[aria-labelledby="driverSideOptions"]').locator('[buttonlabel="Sliding door"]');
this.passengerQuarterPanelChkBox = this.page.locator('[aria-labelledby="passengerSideOptions"]').locator('[buttonlabel="Quarter panel"]');
this.passengerFrontDoorChkBox = this.page.locator('[aria-labelledby="passengerSideOptions"]').locator('[buttonlabel="Front door"]');
this.passengerVentGlassChkBox = this.page.locator('[aria-labelledby="passengerSideOptions"]').locator('[buttonlabel="Vent glass"]');
this.passengerBackDoorChkBox = this.page.locator('[aria-labelledby="passengerSideOptions"]').locator('[buttonlabel="Back door"]');
this.rearWindowChkBox = this.page.locator('[buttonlabel="Rear window"]');
this.separateApptsWarning = this.page.locator('[class*="widget-name-HasReplacementConflict"]');
this.editVehicleButton = this.page.getByRole('link', { name: 'Edit vehicle' });
}
async checkSeparateApptsWarning() {
// Select conflict
await this.windshieldChkBox.check();
await this.chipButton.check();
await this.rearWindowChkBox.check();
// Expect warning
await expect.soft(this.separateApptsWarning).toBeAttached();
// Undo changes
await this.crackButton.check();
await this.windshieldChkBox.uncheck();
await expect.soft(this.crackButton).not.toBeVisible();
await this.rearWindowChkBox.uncheck();
}
async selectDamage(vehicleDamage: VehicleDamage[]) {
for (const damage of vehicleDamage) {
switch(damage) {
case VehicleDamage.WindshieldOneChip:
await this.windshieldChkBox.check();
await this.selectChips('1');
break;
case VehicleDamage.WindshieldTwoChips:
await this.windshieldChkBox.check();
await this.selectChips('2');
break;
case VehicleDamage.WindshieldThreeChips:
await this.windshieldChkBox.check();
await this.selectChips('3');
break;
case VehicleDamage.WindshieldCrack:
await this.windshieldChkBox.check();
await this.selectCrack();
break;
case VehicleDamage.DriverFrontDoor:
await this.sideDoorButton.check();
await this.driverSideButton.check();
await this.driverFrontDoorChkBox.check();
break;
case VehicleDamage.DriverRearDoor:
await this.sideDoorButton.check();
await this.driverSideButton.check();
await this.driverBackDoorChkBox.check();
break;
case VehicleDamage.DriverQuarterPanel:
await this.sideDoorButton.check();
await this.driverSideButton.check();
await this.driverQuarterPanelChkBox.check();
break;
case VehicleDamage.DriverVentGlass:
await this.sideDoorButton.check();
await this.driverSideButton.check();
await this.driverVentGlassChkBox.check();
break;
case VehicleDamage.DriverSlidingDoor:
await this.sideDoorButton.check();
await this.driverSideButton.check();
await this.driverSlidingDoorChkBox.check();
break;
case VehicleDamage.PassengerFrontDoor:
await this.sideDoorButton.check();
await this.passengerSideButton.check();
await this.passengerFrontDoorChkBox.check();
break;
case VehicleDamage.PassengerRearDoor:
await this.sideDoorButton.check();
await this.passengerSideButton.check();
await this.passengerBackDoorChkBox.check();
break;
case VehicleDamage.PassengerQuarterPanel:
await this.sideDoorButton.check();
await this.passengerSideButton.check();
await this.passengerQuarterPanelChkBox.click();
break;
case VehicleDamage.PassengerVentGlass:
await this.sideDoorButton.check();
await this.passengerSideButton.check();
await this.passengerVentGlassChkBox.check();
break;
case VehicleDamage.RearWindow:
await this.selectRearWindowDamage();
break;
}
}
}
async selectCrack(){
await this.crackButton.check();
}
async selectChips(numChips: string){
const numChipsButton = this.page.getByText(numChips, {exact: true});
await this.chipButton.check();
await numChipsButton.check();
}
async selectRearWindowDamage(){
await this.rearWindowChkBox.check();
}
}