Sets up the core infrastructure for Playwright-based automated testing, including: - Docker support for consistent environments - Azure Pipelines configuration for CI/CD - Page Object Model structure for maintainable tests - Test data, validation, and rule engine implementation - Test configuration for alerts and other scenarios
114 lines
No EOL
3.9 KiB
TypeScript
114 lines
No EOL
3.9 KiB
TypeScript
// DefaultTestData.ts
|
|
import { faker } from "@faker-js/faker";
|
|
import { PaymentMethod, ServicePackage, VehicleLookupType, AppointmentType, PaymentType, DamageType, VehicleDamage } from "@business-logic/types/Enums";
|
|
import { ITestData } from "@business-logic/types/ITestData";
|
|
import { getNextWeekday } from "@impl/utils/DateUtils";
|
|
import { ICustomerDetails, IVehicleDetails, IAppointmentDetails, IPaymentDetails, IClaimDetails } from "@business-logic/types/CustomerDetails";
|
|
|
|
// Set a default seed for consistent data generation
|
|
const DEFAULT_SEED = 1234;
|
|
faker.seed(DEFAULT_SEED);
|
|
|
|
// Function to reset faker to the default seed
|
|
export function resetFakerToDefaultSeed() {
|
|
faker.seed(DEFAULT_SEED);
|
|
}
|
|
|
|
// Simple hash function to convert a string to a numeric value
|
|
function hashStringToNumber(str: string): number {
|
|
let hash = 0;
|
|
for (let i = 0; i < str.length; i++) {
|
|
const char = str.charCodeAt(i);
|
|
hash = (hash << 5) - hash + char;
|
|
hash = hash & hash; // Convert to 32bit integer
|
|
}
|
|
return Math.abs(hash);
|
|
}
|
|
|
|
// Function to set a custom seed based on test name
|
|
export function setFakerSeedFromTestName(testName: string) {
|
|
const seed = hashStringToNumber(testName);
|
|
faker.seed(seed);
|
|
}
|
|
|
|
// Functions to generate data (rather than using pre-generated data)
|
|
export function getCustomerDetails(): ICustomerDetails {
|
|
return {
|
|
firstName: faker.person.firstName(),
|
|
lastName: faker.person.lastName(),
|
|
email: "itqatest@safelite.com",
|
|
phoneNumber: '614-254-4109',
|
|
notes: 'Automated Test',
|
|
address: {
|
|
street: faker.location.streetAddress(),
|
|
city: 'Columbus',
|
|
state: 'Ohio',
|
|
postalCode: '21237',
|
|
country: 'United States'
|
|
}
|
|
};
|
|
}
|
|
|
|
export function getVehicleDetails(): IVehicleDetails {
|
|
return {
|
|
year: '2020',
|
|
make: 'Honda',
|
|
model: 'Accord',
|
|
style: '4 door sedan',
|
|
vehicleLookupType: VehicleLookupType.Zip
|
|
};
|
|
}
|
|
|
|
export function getAppointmentDetails(): IAppointmentDetails {
|
|
return {
|
|
serviceLocation: AppointmentType.InShop,
|
|
appointmentDate: getNextWeekday()
|
|
};
|
|
}
|
|
|
|
export function getPaymentDetails(): IPaymentDetails {
|
|
return {
|
|
paymentType: PaymentType.PayAtService
|
|
};
|
|
}
|
|
|
|
export function getClaimDetails(): IClaimDetails {
|
|
return {
|
|
client: 'ACUITY INSURANCE',
|
|
policyNumber: 'Mock' + faker.string.alphanumeric(6).toUpperCase(),
|
|
policyDeductible: 0,
|
|
damageDate: new Date(new Date().setDate(new Date().getDate() - 1)).toLocaleDateString('en-US', {month: '2-digit', day: '2-digit', year: 'numeric'}),
|
|
damageCause: DamageType.Hail
|
|
};
|
|
}
|
|
|
|
// Function to get the entire default test data set with current faker state
|
|
export function getDefaultTestData(): Partial<ITestData> {
|
|
return {
|
|
paymentMethod: PaymentMethod.SelfPay,
|
|
servicePackage: ServicePackage.GlassOnly,
|
|
customerDetails: getCustomerDetails(),
|
|
vehicleDetails: getVehicleDetails(),
|
|
appointmentDetails: getAppointmentDetails(),
|
|
paymentDetails: getPaymentDetails(),
|
|
claimDetails: getClaimDetails(),
|
|
vehicleDamage: [VehicleDamage.WindshieldCrack],
|
|
isDuplicateClaim: false,
|
|
isPolicyDriver: false,
|
|
isPolicyFound: false,
|
|
isUseVehicleOnPolicy: true,
|
|
isRecalNotification: false,
|
|
hasOemEndorsement: false,
|
|
skipEstimatePage: false,
|
|
isRecalVehicle: false,
|
|
enterFunnelWithZip: false
|
|
};
|
|
}
|
|
|
|
// Keep the pre-generated data for backward compatibility
|
|
export const defaultCustomerDetails = getCustomerDetails();
|
|
export const defaultVehicleDetails = getVehicleDetails();
|
|
export const defaultAppointmentDetails = getAppointmentDetails();
|
|
export const defaultPaymentDetails = getPaymentDetails();
|
|
export const defaultClaimDetails = getClaimDetails();
|
|
export const defaultTestData = getDefaultTestData(); |