Add test scenario for when client uses address vehicle

This commit is contained in:
JennyNou 2026-04-01 10:30:52 -04:00
parent 36233faf93
commit 7af77cae21
7 changed files with 141 additions and 10 deletions

View file

@ -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,

View file

@ -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

View file

@ -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,
}

View file

@ -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)
};
}

View file

@ -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();
}
}

View file

@ -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<ITestData>) {
// 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();

View file

@ -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<ITestData> = {
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;