// 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'; // Invalid zip (alert) - Combined test cases for all lookup types const nextWeekday = getNextWeekday(); const baseInvalidZipData: Partial = { ...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: 'Saco', state: 'Montana', postalCode: '99999', country: 'United States' } }, vehicleDamage: [ VehicleDamage.WindshieldCrack ], appointmentDetails: { serviceLocation: ServiceLocation.DropOff, appointmentDate: nextWeekday }, alertFlags: { isInvalidZip: 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.Zip, displayName: 'Zip', tag: 'Zip', vehicleDetails: { year: '2020', make: 'Acura', model: 'ILX', style: '4 door sedan' } }, { type: VehicleLookupType.LicensePlateNumber, displayName: 'License Plate', tag: 'Plate', vehicleDetails: { year: '2013', make: 'Hyundai', model: 'Sonata', style: '4 door sedan', licensePlate: { licensePlateNumber: 'FTY 7776', licensePlateState: 'Texas' }, } }, { type: VehicleLookupType.Vin, displayName: 'VIN', tag: 'Vin', vehicleDetails: { year: '2019', make: 'Toyota', model: 'C-HR', style: '4 door hatchback', vin: 'NMTKHMBX5KR086519' } } ]; const invalidZipTests: ITestCase[] = []; // Generate test cases for each lookup type lookupTypesToTest.forEach((lookupType) => { const testData = { ...baseInvalidZipData, vehicleDetails: { ...lookupType.vehicleDetails, vehicleLookupType: lookupType.type }, enterFunnelWithZip: lookupType.enterFunnelWithZip }; // Handle special case for Address lookup which has different customer details if (lookupType.type === VehicleLookupType.Address && lookupType.customerDetails) { testData.customerDetails = { ...baseInvalidZipData.customerDetails!, address: lookupType.customerDetails.address }; } const tc = { name: `alert0006 ${lookupType.displayName} Lookup Invalid zip`, tags: ['@Alert', `@InvalidZip_${lookupType.tag}`, '@test_report'], testData: testData }; invalidZipTests.push(tc); }); export default invalidZipTests;