From 7af77cae21a90b8a453f23b22e84180f15a89556 Mon Sep 17 00:00:00 2001 From: JennyNou Date: Wed, 1 Apr 2026 10:30:52 -0400 Subject: [PATCH] Add test scenario for when client uses address vehicle --- .../business-logic/types/CustomerDetails.ts | 6 ++ .../business-logic/types/ITestData.ts | 6 +- .../business-logic/types/ITestPages.ts | 4 +- .../business-logic/types/TestCase.ts | 6 +- playwright-tests/pages/AddressVehiclesPage.ts | 21 +++++ .../pages/OrderConfirmationPage.ts | 14 ++- .../tests/advanced/0024a_AddressVehicle.ts | 94 +++++++++++++++++++ 7 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 playwright-tests/pages/AddressVehiclesPage.ts create mode 100644 playwright-tests/tests/advanced/0024a_AddressVehicle.ts diff --git a/playwright-tests/business-logic/types/CustomerDetails.ts b/playwright-tests/business-logic/types/CustomerDetails.ts index 9a4abd95..1020694f 100644 --- a/playwright-tests/business-logic/types/CustomerDetails.ts +++ b/playwright-tests/business-logic/types/CustomerDetails.ts @@ -37,6 +37,12 @@ export interface IVehicleDetails { vehicleLookupType?: VehicleLookupType, } +export interface IAddressVehicleDetails { + year: string, + make: string, + model: string, +} + export interface IAppointmentDetails { serviceLocation: ServiceLocation, appointmentDate?: Date, diff --git a/playwright-tests/business-logic/types/ITestData.ts b/playwright-tests/business-logic/types/ITestData.ts index 3d350351..d3a19d34 100644 --- a/playwright-tests/business-logic/types/ITestData.ts +++ b/playwright-tests/business-logic/types/ITestData.ts @@ -1,5 +1,5 @@ import { ServicePackage, VehicleDamage } from "./Enums" -import { IAppointmentDetails, IClaimDetails, ICustomerDetails, IEndorsementDetails, IPartQuestion, IPaymentDetails, IVehicleDetails } from "./CustomerDetails" +import { IAppointmentDetails, IClaimDetails, ICustomerDetails, IEndorsementDetails, IPartQuestion, IPaymentDetails, IVehicleDetails, IAddressVehicleDetails } from "./CustomerDetails" import IBailoutFlags from "./IBailoutFlags" export interface ITestData { @@ -8,7 +8,8 @@ export interface ITestData { isDuplicateClaim: boolean, isPolicyFound: boolean, // Effective difference between advanced and essential isUnverifiedPolicyAfterVehicleLookup: boolean, // Changing license plate can cause flow to change to unverified from verified - isUseVehicleOnPolicy: boolean, // Should we use the vehicle on the policy? + isUseVehicleOnPolicy: boolean, + isUseVehicleFromAddressLookup: boolean, // Should we use the vehicle from the address lookup? isVehicleLookupValidations: boolean, // Should we validate vehicle lookup? isAddressLookupValidations: boolean, // Should we validate address lookup errors? isVehicleSelectBailout: boolean, // Should we bailout on vehicle lookup? @@ -29,6 +30,7 @@ export interface ITestData { customerDetails: ICustomerDetails, claimDetails: IClaimDetails, vehicleDetails: IVehicleDetails, + addressVehicleDetails: IAddressVehicleDetails, editVehicleDetails: IVehicleDetails, // Vehicle details entered after clicking "Edit vehicle" on Vehicle Details page otherVehiclesOnPolicy: IVehicleDetails[], // IF defined, we validate that the vehicles are present. vehicleDamage: VehicleDamage[], // Array of vehicle damage diff --git a/playwright-tests/business-logic/types/ITestPages.ts b/playwright-tests/business-logic/types/ITestPages.ts index 77ed4e54..87868718 100644 --- a/playwright-tests/business-logic/types/ITestPages.ts +++ b/playwright-tests/business-logic/types/ITestPages.ts @@ -1,4 +1,5 @@ import { AddressLookupPage } from "../../pages/AddressLookupPage"; +import { AddressVehiclesPage } from "../../pages/AddressVehiclesPage"; import { BailoutPage } from "../../pages/BailoutPage"; import CapabilityQuestionsPage from "../../pages/CapabilityQuestionsPage"; import { ContactConfirmationPage } from "../../pages/ContactConfirmationPage"; @@ -31,6 +32,8 @@ import { VinLookupPage } from "../../pages/VinLookupPage"; import { WelcomePage } from "../../pages/WelcomePage"; export default interface ITestPages { + addressLookupPage: AddressLookupPage, + addressVehiclesPage: AddressVehiclesPage, bailoutPage: BailoutPage, capabilityQuestionsPage: CapabilityQuestionsPage, contactConfirmationPage: ContactConfirmationPage, @@ -61,5 +64,4 @@ export default interface ITestPages { vehicleLookupLicensePage: VehicleLookupLicensePage, welcomePage: WelcomePage, moldingQuestionsPage: MoldingQuestionsPage, - addressLookupPage: AddressLookupPage, } \ No newline at end of file diff --git a/playwright-tests/business-logic/types/TestCase.ts b/playwright-tests/business-logic/types/TestCase.ts index ffc332d5..2cd1bb5a 100644 --- a/playwright-tests/business-logic/types/TestCase.ts +++ b/playwright-tests/business-logic/types/TestCase.ts @@ -45,6 +45,7 @@ import VehiclePartQuestionsPage from "../../pages/VehiclePartsPage"; import CapabilityQuestionsPage from "../../pages/CapabilityQuestionsPage"; import { MoldingQuestionsPage } from "../../pages/MoldingQuestionsPage"; import { AddressLookupPage } from "../../pages/AddressLookupPage"; +import { AddressVehiclesPage } from "../../pages/AddressVehiclesPage"; export default class TestCase extends DisposableBase implements ITestCase { public static FrameworkConfig: FrameworkConfig = { @@ -177,6 +178,8 @@ export default class TestCase extends DisposableBase implements ITestCase { public setupPages(page: Page): void { this.pages = { + addressLookupPage: new AddressLookupPage(page), + addressVehiclesPage: new AddressVehiclesPage(page), bailoutPage: new BailoutPage(page), capabilityQuestionsPage: new CapabilityQuestionsPage(page), contactConfirmationPage: new ContactConfirmationPage(page), @@ -206,8 +209,7 @@ export default class TestCase extends DisposableBase implements ITestCase { vehicleLookupAddressPage: new VehicleLookupAddressPage(page), vehicleLookupLicensePage: new VehicleLookupLicensePage(page), welcomePage: new WelcomePage(page), - moldingQuestionsPage: new MoldingQuestionsPage(page), - addressLookupPage: new AddressLookupPage(page) + moldingQuestionsPage: new MoldingQuestionsPage(page) }; } diff --git a/playwright-tests/pages/AddressVehiclesPage.ts b/playwright-tests/pages/AddressVehiclesPage.ts new file mode 100644 index 00000000..de4bc527 --- /dev/null +++ b/playwright-tests/pages/AddressVehiclesPage.ts @@ -0,0 +1,21 @@ +import { expect, type Locator, type Page } from '@playwright/test'; +import { BasePage } from './BasePage'; +import { IAddressVehicleDetails } from '@business-logic/types/CustomerDetails'; + +export class AddressVehiclesPage extends BasePage { + + readonly page: Page; + readonly selectVehicleButton: Locator; + issPageValue = 'address-vehicles'; + + constructor(page: Page) { + super(page); + this.page = page; + this.selectVehicleButton = this.page.getByRole('radio').first(); + } + + async selectVehicle(addressVehicleDetails: IAddressVehicleDetails){ + const vehicleRegExp = new RegExp(`${addressVehicleDetails.year} .+ ${addressVehicleDetails.model}`, 'i'); + await this.page.locator('label').filter({hasText: vehicleRegExp}).locator('div').click(); + } +} \ No newline at end of file diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 6e957c54..7ec6b4a0 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -1,6 +1,6 @@ import test, { expect, type Locator, type Page } from '@playwright/test'; import { BasePage } from './BasePage'; -import { ICustomerDetails, IVehicleDetails } from '@business-logic/types/CustomerDetails'; +import { ICustomerDetails, IVehicleDetails, IAddressVehicleDetails } from '@business-logic/types/CustomerDetails'; import { PaymentType, ServicePackage } from '@business-logic/types/Enums'; import { ITestData } from '@business-logic/types/ITestData'; @@ -50,8 +50,8 @@ export class OrderConfirmationPage extends BasePage { async validateOrderConfirmationPage(testData: Partial) { // Destructure data we use - const { vehicleDetails, customerDetails, servicePackage, isItac, - isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleOnPolicy } = testData; + const { vehicleDetails, servicePackage, isItac, + isNoComp, isPolicyFound, claimDetails, paymentDetails, isUseVehicleFromAddressLookup, addressVehicleDetails } = testData; // Grab text @@ -62,7 +62,7 @@ export class OrderConfirmationPage extends BasePage { // Derived conditions const isItacOrNoComp = !!(isItac || isNoComp); - const isUnverified = !isPolicyFound && claimDetails!.policyDeductible === -1; + const isUnverified = !isPolicyFound || claimDetails!.policyDeductible === -1; const isUnverifiedPolicyAfterVehicleLookup = testData.isUnverifiedPolicyAfterVehicleLookup === true; const hasPremiumOrStandard = (claimDetails!.policyDeductible >= 0 || !isPolicyFound) && @@ -93,7 +93,11 @@ export class OrderConfirmationPage extends BasePage { expect.soft(this.serviceText).toBeVisible();; expect.soft(this.successHeader).toBeVisible(); expect.soft(confirmationTextValue).toContain('Your appointment is on Safelite\'s schedule and your confirmation email is on the way.'); - expect.soft(serviceTextValue).toContain(`${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`); + if (isUseVehicleFromAddressLookup) { + expect.soft(serviceTextValue).toContain(`${addressVehicleDetails!.year} ${addressVehicleDetails!.make} ${addressVehicleDetails!.model}`); + } else { + expect.soft(serviceTextValue).toContain(`${vehicleDetails!.year} ${vehicleDetails!.make} ${vehicleDetails!.model}`); + } // Validate order number and appointment type header await this.validateOrderNumber(); diff --git a/playwright-tests/tests/advanced/0024a_AddressVehicle.ts b/playwright-tests/tests/advanced/0024a_AddressVehicle.ts new file mode 100644 index 00000000..5d0c1581 --- /dev/null +++ b/playwright-tests/tests/advanced/0024a_AddressVehicle.ts @@ -0,0 +1,94 @@ +import ClientData from "@business-logic/data/ClientData"; +import TestCase from "@business-logic/types/TestCase"; +import { DamageType, PartQuestionType, PaymentType, ServiceLocation, ServicePackage, VehicleDamage, VehicleLookupType } from "@business-logic/types/Enums"; +import { ITestData } from "@business-logic/types/ITestData" +import { faker } from "@faker-js/faker"; +import { getNextWeekday } from "@impl/utils/DateUtils"; +import MockPolicyData from "@business-logic/data/MockPolicyData"; +import { ICustomerDetails } from "@business-logic/types/CustomerDetails"; + +const nextWeekday = getNextWeekday(); +const customerDetails: ICustomerDetails = { + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), + email: 'itqatest@safelite.com', + phoneNumber: '614-531-0031', + notes: 'Automated Test', + address: { + street: '4530 Kenny Road', + city: 'Columbus', + state: 'OH', + postalCode: '43220', + country: 'United States' + } +} + +const policyNumber = `~AutomatedScenario0024a${crypto.randomUUID().replace(/-/g, '').slice(0, 16).toUpperCase()}`; // Ensure unique policy number for each test run since same key in request can cause 500 error +const policySoap = MockPolicyData.getPolicySoapByScenario('0024a', customerDetails, policyNumber); + +const advancedScenario0024Data: Partial = { + clientTag: '', + isDuplicateClaim: false, + isPolicyFound: false, + isNoComp: false, + hasStateLawPopup: false, + endorsements: undefined, + isUseVehicleOnPolicy: false, + isUseVehicleFromAddressLookup: true, + isVehicleLookupValidations: false, + isVehicleSelectBailout: false, + isAddressLookupValidations: true, + isMoldingQuestion: false, + isSafelite: true, + servicePackage: faker.helpers.enumValue(ServicePackage), + customerDetails: customerDetails, + claimDetails: { + policyNumber: policyNumber, + policyDeductible: -1, + damageDate: '2017-06-02', + damageCause: DamageType.Vandalism + }, + policySoap: policySoap, + vehicleDetails: { + year: '2015', + make: 'Audi', + model: 'A7', + style: '4 door hatchback', + vehicleLookupType: VehicleLookupType.Address, + address: [ + { street: '9 Test Street', city: 'Columbus', state: 'OH', postalCode: '43220', lastName: 'Test' }, + { street: '8621 GREENLEAF AVE', city: 'Whittier', state: 'California', postalCode: '90602', lastName: 'Johnson' }, + { street: '6531 CANYON RANCH', city: 'Frisco', state: 'Texas', postalCode: '75036', lastName: 'TRAINOR' } + ], + }, + addressVehicleDetails: { + year: '2020', + make: 'Audi', + model: 'A6', + }, + vehicleDamage: [ + VehicleDamage.WindshieldCrack, + ], + appointmentDetails: { + serviceLocation: ServiceLocation.InShop, + shopAddress: undefined, + appointmentDate: nextWeekday + }, + +} + +// TODO: Add validation for deductible/covered amount +const advancedClients = ClientData.getAdvancedClients(); +const advancedScenario0024TestCases: TestCase[] = []; +for (const client of advancedClients) { + const data = { ...advancedScenario0024Data }; + data.clientTag = client.clientTag; + const tc = new TestCase({ + name: `0024a Advanced Client Address Vehicle Lookup: "${client.accountName}"`, + tags: [`@${client.clientTag}`, `@${client.accountName}`, '@Advanced', '@INSR-2057'], + testData: data + }, undefined, '0024a'); + advancedScenario0024TestCases.push(tc); +} + +export default advancedScenario0024TestCases; \ No newline at end of file