import ClientData from "@business-logic/data/ClientData";
import { DamageType, PartQuestionType, ServiceLocation, ServicePackage, VehicleDamage, VehicleLookupType } from "@business-logic/types/Enums";
import { ITestData } from "@business-logic/types/ITestData"
import TestCase from "@business-logic/types/TestCase";
import { faker } from "@faker-js/faker";
import { getNextWeekday } from "@impl/utils/DateUtils";

const nextWeekday = getNextWeekday();

const essentialReplaceData: Partial<ITestData> = {
    clientTag: 'ALL_ESSENTIAL',
    isDuplicateClaim: false,
    isPolicyFound: false,
    endorsements: [],
    isReplace: false,
    vehiclePartQuestions: [
        {
            partQuestionType: PartQuestionType.WindshieldColor,
            isOnPage: true,
            optionToSelect: 'Green Tint'
        },
        {
            partQuestionType: PartQuestionType.DriverFrontColor,
            isOnPage: true,
            optionToSelect: 'Green Tint'
        },
        {
            partQuestionType: PartQuestionType.DriverRearColor,
            isOnPage: true,
            optionToSelect: 'Green Tint'
        },
        {
            partQuestionType: PartQuestionType.PassengerFrontColor,
            isOnPage: true,
            optionToSelect: 'Green Tint'
        },
        {
            partQuestionType: PartQuestionType.PassengerRearColor,
            isOnPage: true,
            optionToSelect: 'Green Tint'
        },
    ],
    isSafelite: true,
    servicePackage: faker.helpers.enumValue(ServicePackage),
    customerDetails: {
        firstName: faker.person.firstName(),
        lastName: 'Reed',
        email: "itqatest@safelite.com",
        phoneNumber: faker.helpers.fromRegExp(/[2-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]/),
        notes: 'Automated Test',
        address: {
            street: '10212 JEWEL CT',// DO NOT use fake address here as this scenario search vehicle by address //faker.location.streetAddress(),
            city: 'CONROE',
            state: 'Texas',
            postalCode: '77385',
            country: 'United States'
        }
    },
    claimDetails: {
        policyNumber: faker.string.alphanumeric(5),
        policyDeductible: -1,   // Not advanced, so we don't care about deductible.
        damageDate: '2024-10-10',
        damageCause: DamageType.Other
    },
    vehicleDetails: {
        year: '2015',
        make: 'Ford',
        model: 'F Series F150',
        style: '2 door super cab',
        vin: '5N1AN0NW9BC524974',
        vehicleLookupType: VehicleLookupType.Address,
    },
    vehicleDamage: [
        VehicleDamage.WindshieldCrack,
        VehicleDamage.DriverFrontDoor,
        VehicleDamage.DriverRearDoor,
        VehicleDamage.PassengerFrontDoor,
        VehicleDamage.PassengerRearDoor,
    ],
    appointmentDetails: {
        serviceLocation: ServiceLocation.InShop,
        shopAddress: undefined,
        appointmentDate: nextWeekday
    }

}

const essentialClients = ClientData.getEssentialClients();
const essentialReplaceTestCases: TestCase[] = [];
for (const client of essentialClients) {
    const data = {...essentialReplaceData};
    data.clientTag = client.clientTag;
    data.isAuthenticationRequired = client.clientFlags.isAuthenticationEnabled ?? false
    const tc = new TestCase({
        name: `0013 Essential Replace Client: "${client.accountName}"`,
        tags: [`@${client.clientTag}`, `@${client.accountName}`, '@Essentials'],
        testData: data
    }, undefined, '0013');
    essentialReplaceTestCases.push(tc);
}

export default essentialReplaceTestCases;