DigitalConsumer.FixMyGlass/playwright-tests/tests/alert-validation/alert0007_VinNotFound.ts
maguire-arman 565d9f473e fixes zip alert validation issue
Refactors the vehicle lookup test data structure to improve data handling and flexibility.
Consolidates license plate information into a dedicated object within vehicle details.
2025-06-25 16:25:04 -04:00

143 lines
No EOL
4 KiB
TypeScript

// Imports here
import { ITestData } from 'framework/TestData';
import { VehicleDamage, ServiceLocation, VehicleLookupType, ILicensePlate } from 'safelite-playwright-core';
import { ITestCase } from '../../framework/Typedefs'
import { getNextWeekday } from 'safelite-playwright-core';
import { faker } from "@faker-js/faker";
import { defaultTestData } from 'safelite-playwright-core';
// Vin not found (alert) - Combined test cases for all lookup types
const nextWeekday = getNextWeekday();
const baseVinNotFoundData: Partial<ITestData> = {
...defaultTestData, // Start with all defaults
// Override specific fields with test-specific data
customerDetails: {
...defaultTestData.customerDetails!,
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
address: {
street: faker.location.streetAddress(),
city: 'Raleigh',
state: 'North Carolina',
postalCode: '44089',
country: 'United States'
}
},
vehicleDamage: [
VehicleDamage.WindshieldCrack
],
appointmentDetails: {
serviceLocation: ServiceLocation.DropOff,
appointmentDate: nextWeekday
},
alertFlags: {
isVinNotFound: true
}
};
interface LookupTestCase {
type: VehicleLookupType;
vehicleDetails: {
year: string,
make: string,
model: string,
style?: string,
vin?: string|string[],
licensePlate?: ILicensePlate | ILicensePlate[],
vehicleLookupType?: VehicleLookupType,
};
enterFunnelWithZip?: boolean;
customerDetails?: {
address: {
street: string;
city: string;
state: string;
postalCode: string;
country: string;
};
};
tag: string;
displayName: string;
}
const lookupTypesToTest: LookupTestCase[] = [
{
type: VehicleLookupType.Address,
displayName: 'Address',
tag: 'Addr',
vehicleDetails: {
year: '2013',
make: 'Hyundai',
model: 'Sonata',
style: '4 door sedan'
},
customerDetails: {
address: {
street: '4076 Spectacle Drive',
city: 'Columbus',
state: 'OH',
postalCode: '59261',
country: 'United States'
}
},
enterFunnelWithZip: true
},
{
type: VehicleLookupType.LicensePlateNumber,
displayName: 'License Plate',
tag: 'Plate',
vehicleDetails: {
year: '2013',
make: 'Hyundai',
model: 'Sonata',
style: '4 door sedan',
licensePlate: { licensePlateNumber: '6WYN462', licensePlateState: 'Texas' },
}
},
{
type: VehicleLookupType.Vin,
displayName: 'VIN',
tag: 'Vin',
vehicleDetails: {
year: '2019',
make: 'Toyota',
model: 'C-HR',
style: '4 door hatchback',
vin: '1MMHK8F81CGA45982'
}
}
];
const vinNotFoundTests: ITestCase[] = [];
// Generate test cases for each lookup type
lookupTypesToTest.forEach((lookupType) => {
const testData = {
...baseVinNotFoundData,
vehicleDetails: {
...lookupType.vehicleDetails,
vehicleLookupType: lookupType.type
},
isEnterFunnelWithZip: lookupType.enterFunnelWithZip
};
// Handle special case for Address lookup which has different customer details
if (lookupType.type === VehicleLookupType.Address && lookupType.customerDetails) {
testData.customerDetails = {
...baseVinNotFoundData.customerDetails!,
address: lookupType.customerDetails.address,
};
}
const tc = {
name: `alert0007 ${lookupType.displayName} Lookup Vin Not Found`,
tags: ['@Alert', `@VinNotFound_${lookupType.tag}`, '@test_report'],
testData: testData
};
vinNotFoundTests.push(tc);
});
export default vinNotFoundTests;