import ClientData from "@business-logic/data/ClientData";
import TestCase from "@business-logic/types/TestCase";
import { DamageType, PartQuestionType, PaymentType, ServiceLocation, ServicePackage, VehicleDamage } 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: faker.location.streetAddress(),
        city: 'PORTLAND',
        state: 'OR',
        postalCode: '97230-6373',
        country: 'United States'
    }
}

const policyNumber = `~AutomatedScenario0001a${faker.string.uuid().substring(0, 6)}`;
const policySoap = MockPolicyData.getPolicySoapByScenario('0001a', customerDetails, policyNumber);

const advancedScenario0001Data: Partial<ITestData> = {
    clientTag: '',
    isDuplicateClaim: false,
    isPolicyFound: true,
    isNoComp: false,
    hasStateLawPopup: true,
    endorsements: undefined,
    vehiclePartQuestions: [

    ],
    isSafelite: true,
    servicePackage: faker.helpers.enumValue(ServicePackage),
    customerDetails: customerDetails,
    claimDetails: {
        policyNumber: policyNumber,
        policyDeductible: 250,
        damageDate: '2023-08-01',
        damageCause: DamageType.Vandalism
    },
    policySoap: policySoap,
    vehicleDetails: {
        year: '2020',
        make: 'BMW',
        model: '740',
        style: ''
    },
    vehicleDamage: [
        VehicleDamage.WindshieldCrack,
    ],
    appointmentDetails: {
        serviceLocation: ServiceLocation.InShop,
        shopAddress: undefined,
        appointmentDate: nextWeekday
    },
    paymentDetails: ClientData.getDefaultPaypalDetails()//ClientData.getDefaultCreditCardDetails()
}

// TODO: Add validation for deductible/covered amount
const advancedClients = ClientData.getAdvancedClients();
const advancedScenario0001TestCases: TestCase[] = [];
for (const client of advancedClients) {
    const data = { ...advancedScenario0001Data };
    data.clientTag = client.clientTag;
    const tc = new TestCase({
        name: `0001a_Advanced_Replace_Deductible_Client: "${client.accountName}"`,
        tags: [`@${client.clientTag}`, `@${client.accountName}`, '@Advanced'],
        testData: data
    }, undefined, '0001a');
    advancedScenario0001TestCases.push(tc);
}

export default advancedScenario0001TestCases;