From 97d703803d99669acb5f20157af3200b391ac3b4 Mon Sep 17 00:00:00 2001 From: brydon1 Date: Thu, 13 Jul 2023 12:12:37 -0400 Subject: [PATCH 1/6] Removing dashes from phone number in register claim call --- src/store/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index f04f4c68..4bfac477 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -392,7 +392,7 @@ export const useMainStore = defineStore({ country: 'US' // TODO set from store }, homePhone: { - number: this.order.customer.phoneNumber + number: this.order.customer.phoneNumber.replaceAll('-', '') } }, caller: { From 18c161ef963d293f6418ee20d0e09a86317b7e1c Mon Sep 17 00:00:00 2001 From: brydon1 Date: Thu, 13 Jul 2023 12:34:13 -0400 Subject: [PATCH 2/6] Fixing issues with register claim for liberty mutual --- src/store/index.js | 86 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 4bfac477..1e402c09 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -377,49 +377,49 @@ export const useMainStore = defineStore({ method: endpoints.RegisterClaim.method, endpoint: endpoints.RegisterClaim.url, payload: - { - correlationId: placeHolderCorrelationId, - accountNumber: this.issConfig.accountNumber?.toString() ?? '', - insured: { - firstName: this.order.customer.firstName, - lastName: this.order.customer.lastName, - address: { - addressLine1: this.order.customer.address.streetAddress, - addressLine2: this.order.customer.address.streetAddress2, - city: this.order.customer.address.city, - state: this.order.customer.address.state, - zipCode: this.order.customer.address.zipCode, - country: 'US' // TODO set from store - }, - homePhone: { - number: this.order.customer.phoneNumber.replaceAll('-', '') - } - }, - caller: { - homePhone: {} - }, - policyInfo: { - policyNumber: this.order.policy.policyNumber, - safelitePolicy: { - policies: [] - } - }, - lossInfo: { - dateOfLoss: this.order.policy.dateOfLoss, - location: { - city: this.order.policy.damageCity, - state: this.order.policy.damageState, - country: 'US' // TODO set from store - }, - vehicle: { - year: this.order.vehicle.year?.toString() ?? '', - make: this.order.vehicle.make, - model: this.order.vehicle.model, - vin: this.order.vehicle.vin - } - }, - damageDescription: this.order.policy.damageCause - } + { + correlationId: placeHolderCorrelationId, + accountNumber: this.issConfig.accountNumber?.toString() ?? '', + insured: { + firstName: this.order.customer.firstName, + lastName: this.order.customer.lastName, + address: { + addressLine1: this.order.customer.address.streetAddress, + addressLine2: this.order.customer.address.streetAddress2, + city: this.order.customer.address.city, + state: this.order.customer.address.state, + zipCode: this.order.customer.address.zipCode, + country: 'US' // TODO set from store + }, + homePhone: { + number: this.order.customer.phoneNumber.replaceAll('-', '') + } + }, + caller: { + homePhone: {} + }, + policyInfo: { + policyNumber: this.order.policy.policyNumber, + safelitePolicy: { + policies: [] + } + }, + lossInfo: { + dateOfLoss: this.order.policy.dateOfLoss, + location: { + city: this.order.policy.damageCity, + state: this.order.policy.damageState, + country: 'US' // TODO set from store + }, + vehicle: { + year: this.order.vehicle.year?.toString() ?? '', + make: this.order.vehicle.make, + model: this.order.vehicle.model, + vin: this.order.vehicle.vin + }, + damageDescription: this.order.policy.damageCause + } + } }).then((response) => { const registerClaimFailed = response.data.isError; this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed; From 154fdbc8b9387c61cdd66d45f4fd7487c08e0111 Mon Sep 17 00:00:00 2001 From: brydon1 Date: Fri, 14 Jul 2023 08:53:25 -0400 Subject: [PATCH 3/6] Swapping string replacement with non number regex --- src/store/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 1e402c09..8006f9f5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -373,6 +373,7 @@ export const useMainStore = defineStore({ registerClaim() { // TODO: replace place holder correlationId with the real thing const placeHolderCorrelationId = '00000000-0000-0000-0000-000000000000'; + const nonNumberCharRegex = /[^0-9]/g; globalMethods.callHttpClient({ method: endpoints.RegisterClaim.method, endpoint: endpoints.RegisterClaim.url, @@ -392,7 +393,7 @@ export const useMainStore = defineStore({ country: 'US' // TODO set from store }, homePhone: { - number: this.order.customer.phoneNumber.replaceAll('-', '') + number: this.order.customer.phoneNumber.replaceAll(nonNumberCharRegex, '') } }, caller: { From b78a027c9b649bbfcd93e4ec9197d40b6e1f0ed0 Mon Sep 17 00:00:00 2001 From: brydon1 Date: Fri, 14 Jul 2023 11:00:05 -0400 Subject: [PATCH 4/6] Fix store unit tests --- src/store/index.js | 2 +- src/store/store.spec.js | 53 ++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 8006f9f5..2204a474 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -393,7 +393,7 @@ export const useMainStore = defineStore({ country: 'US' // TODO set from store }, homePhone: { - number: this.order.customer.phoneNumber.replaceAll(nonNumberCharRegex, '') + number: this.order.customer.phoneNumber?.replaceAll(nonNumberCharRegex, '') ?? '' } }, caller: { diff --git a/src/store/store.spec.js b/src/store/store.spec.js index da26b1ac..57a24367 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1,34 +1,27 @@ import { useMainStore } from '@/store'; -import { createApp } from 'vue'; -import { setActivePinia, createPinia } from "pinia"; -import globalMethods from "@/global-methods"; -import App from '@/App'; +import { setActivePinia, createPinia } from 'pinia'; +import globalMethods from '@/global-methods'; import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation'; -import { coverageStatuses } from "@/constants/coverage-statuses.js"; - -describe("Store", () => { +import { coverageStatuses } from '@/constants/coverage-statuses.js'; +describe('Store', () => { let store; - const vueApp = createApp(App); - beforeEach(() => { const pinia = createPinia(); setActivePinia(pinia); - vueApp.use(pinia); store = useMainStore(); store.applicationUser.eventBus = []; jest.resetAllMocks(); }); - - - it("Should Store Vehicle Year", () => { - let testYear = "2001"; + + it('Should Store Vehicle Year', () => { + const testYear = '2001'; store.updateVehicleYear(testYear); expect(store.order.vehicle.year).toEqual(testYear); }); - it("Should add events to the bus", () => { + it('Should add events to the bus', () => { // Arrange const category = getRandomString(1, 25); const subCategory = getRandomString(5, 20); @@ -54,7 +47,7 @@ describe("Store", () => { expect(store.applicationUser.eventBus[0]).toEqual(event); }); - it("Should remove events from the bus", () => { + it('Should remove events from the bus', () => { // Arrange const category = getRandomString(1, 25); const subCategory = getRandomString(5, 20); @@ -84,7 +77,7 @@ describe("Store", () => { expect(store.applicationUser.eventBus.length).toBe(0); }); - it("Should return correct event using the getter function eventBusItem", () => { + it('Should return correct event using the getter function eventBusItem', () => { // Arrange const category = getRandomString(1, 25); const subCategory = getRandomString(5, 20); @@ -112,7 +105,7 @@ describe("Store", () => { expect(actual).toEqual(event.eventValue); }); - it("UpdateVehicle should merge vehicle with response object", () => { + it('UpdateVehicle should merge vehicle with response object', () => { // Arrange const carId = getRandomString(10,14); const category = getRandomString(3,7); @@ -154,7 +147,7 @@ describe("Store", () => { expect(store.order.vehicle).toMatchObject(expectedVehicle); }); - it("UpdateVehicle should set policy values appropriately with repair waived", () => { + it('UpdateVehicle should set policy values appropriately with repair waived', () => { // Arrange const noCompensation = getRandomBoolean(); const deductible = getRandomInt(1,500); @@ -179,7 +172,7 @@ describe("Store", () => { expect(store.order.policy).toMatchObject(expectedPolicy); }); - it("UpdateVehicle should set policy values appropriately with repair not waived", () => { + it('UpdateVehicle should set policy values appropriately with repair not waived', () => { // Arrange const noCompensation = getRandomBoolean(); const deductible = getRandomInt(1,500); @@ -205,7 +198,7 @@ describe("Store", () => { }); // TODO update test to work also checking store values - it("setVehicle should call globalMethods.callHttpClient", () => { + it('setVehicle should call globalMethods.callHttpClient', () => { // Arrange const carId = getRandomString(10,14); const category = getRandomString(3,7); @@ -240,7 +233,7 @@ describe("Store", () => { expect(returned).resolves.toMatchObject(response); }); - it("saveVehicleDamage with windshield repair should update damage with number of chips not null", () => { + it('saveVehicleDamage with windshield repair should update damage with number of chips not null', () => { // Arrange const glassName = getRandomString(4,10); const glassLocation = getRandomString(5,15); @@ -260,7 +253,7 @@ describe("Store", () => { expect(store.order.damage.numberOfChips).toEqual(chipCount); }); - it("saveVehicleDamage without windshield repair should update damage with number of chips null", () => { + it('saveVehicleDamage without windshield repair should update damage with number of chips null', () => { // Arrange const glassName = getRandomString(4,10); const glassLocation = getRandomString(5,15); @@ -282,7 +275,7 @@ describe("Store", () => { expect(store.order.damage.numberOfChips).toEqual(expectedChipCount); }); - it("should return registration data if available", () => { + it('should return registration data if available', () => { //Arrange const streetAddress = getRandomString(5,15); const city = getRandomString(5,15); @@ -318,7 +311,7 @@ describe("Store", () => { expect(actual).toEqual(expected); }); - it("should return customer data if registration data unavailable", () => { + it('should return customer data if registration data unavailable', () => { //Arrange const address = getRandomString(1,25); const city = getRandomString(5,20); @@ -357,8 +350,8 @@ describe("Store", () => { expect(actual).toMatchObject(expected); }); - describe("registerClaim method", () => { - it("successful response with no coverage => isVerified true and coverage status no comp", async () => { + describe('registerClaim method', () => { + it('successful response with no coverage => isVerified true and coverage status no comp', async () => { // Arrange const response = { data: { @@ -384,7 +377,7 @@ describe("Store", () => { expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COMP); }); - it("successful response with coverage => isVerified true and coverage status verified", async () => { + it('successful response with coverage => isVerified true and coverage status verified', async () => { // Arrange const response = { data: { @@ -408,9 +401,9 @@ describe("Store", () => { expect(globalMethods.callHttpClient).toHaveBeenCalled(); expect(store.payment.insuranceCoverage.isVerified).toBe(true); expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED); - }) + }); - it("Call to client returns exception, resulting in object with error property being returned", async () => { + it('Call to client returns exception, resulting in object with error property being returned', async () => { // Arrange globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject()); From ad18f2803e04ec62cbaf08edaca6d14a618566b7 Mon Sep 17 00:00:00 2001 From: brydon1 Date: Fri, 14 Jul 2023 15:12:54 -0400 Subject: [PATCH 5/6] Fixing bug with compensation --- .../coverage-statement/coverage-statement.vue | 223 ++++++++-------- .../policy-vehicles/policy-vehicles.spec.js | 10 +- .../policy-vehicles/policy-vehicles.vue | 3 +- src/store/index.js | 20 +- src/store/store.spec.js | 252 +++++++++--------- 5 files changed, 261 insertions(+), 247 deletions(-) diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index 510cc288..de887a8e 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -1,5 +1,9 @@ diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js index 8b585428..cd505ff7 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.spec.js +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -66,7 +66,7 @@ describe('policy-vehicles.vue', () => { const expectedInput = { year: year, vin: vin, - noCompensation: true, + noCoverage: true, deductible: 0, repairWaived: false } @@ -132,7 +132,7 @@ describe('policy-vehicles.vue', () => { }); }) - describe('noCompensationForSelectedVehicle computed property', () => { + describe('noCoverageForSelectedVehicle computed property', () => { it('No vehicle match => returns true', async () => { // Arrange const selectedVin = getRandomString(17,17); @@ -147,7 +147,7 @@ describe('policy-vehicles.vue', () => { } // Act - const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues); + const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues); // Assert expect(result).toBeTruthy(); @@ -167,7 +167,7 @@ describe('policy-vehicles.vue', () => { } // Act - const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues); + const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues); // Assert expect(result).toBeTruthy(); @@ -191,7 +191,7 @@ describe('policy-vehicles.vue', () => { } // Act - const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues); + const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues); // Assert expect(result).toBeFalsy(); diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 2e59d880..29e793ef 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -107,6 +107,7 @@ export default { noCompensationForSelectedVehicle() { const vehicle = this.policyVehicles.find((policyVehicle) => policyVehicle.vin === this.selectedVehicleVin); + console.log((vehicle?.coverages?.length ?? 0) === 0); return (vehicle?.coverages?.length ?? 0) === 0; }, deductibleForSelectedVehicle() { @@ -174,7 +175,7 @@ export default { this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.selectedVehicleVin, - noCompensation: this.noCompensationForSelectedVehicle, + noCoverage: this.noCompensationForSelectedVehicle, deductible: this.deductibleForSelectedVehicle, repairWaived: this.repairWaivedForSelectedVehicle }); diff --git a/src/store/index.js b/src/store/index.js index 2204a474..379fc0b8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -53,7 +53,7 @@ const getDefaultState = () => damageState: null, damageCity: null, isDamageGlassOnly: null, - noCompensation: null, + noCoverage: null, deductible: { repair: null, // numerical value; how much customer owes on deductible in repair case replace: null // numerical value; how much customer owes on deductible in replace case, @@ -396,6 +396,10 @@ export const useMainStore = defineStore({ number: this.order.customer.phoneNumber?.replaceAll(nonNumberCharRegex, '') ?? '' } }, + driver: { + firstName: this.order.customer.firstName, + lastName: this.order.customer.lastName + }, caller: { homePhone: {} }, @@ -424,11 +428,13 @@ export const useMainStore = defineStore({ }).then((response) => { const registerClaimFailed = response.data.isError; this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed; - this.order.payment.insuranceCoverage.coverageStatus = registerClaimFailed - ? coverageStatuses.PENDING - : this.policy.noCompensation - ? coverageStatuses.NO_COMP - : coverageStatuses.VERIFIED; + if (registerClaimFailed) { + this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING; + } else if (this.policy.noCoverage) { + this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.NO_COMP; + } else { + this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; + } }, (error) => { this.order.payment.insuranceCoverage.isVerified = false; this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING; @@ -764,7 +770,7 @@ export const useMainStore = defineStore({ this.order.vehicle.imageColor = vehicle.imageVifColor; // These could be undefined - this.order.policy.noCompensation = vehicle.noCoverage; + this.order.policy.noCoverage = vehicle.noCoverage; this.order.policy.deductible.replace = vehicle.deductible; this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible; diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 57a24367..aa4a6b5d 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1,7 +1,7 @@ -import { useMainStore } from '@/store'; +import { useMainStore } from '@/store/index.js'; import { setActivePinia, createPinia } from 'pinia'; -import globalMethods from '@/global-methods'; -import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation'; +import globalMethods from '@/global-methods.js'; +import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js'; import { coverageStatuses } from '@/constants/coverage-statuses.js'; describe('Store', () => { @@ -29,15 +29,15 @@ describe('Store', () => { const copy = getRandomString(5, 25); const headline = getRandomString(5, 25); const type = getRandomString(5, 15); - let event = { - category: category, - subCategory: subCategory, + const event = { + category, + subCategory, eventValue: { - isDismissible: isDismissible, + isDismissible, messageCopy: copy, messageHeadline: headline, - type: type, - }, + type + } }; // Act @@ -55,15 +55,15 @@ describe('Store', () => { const copy = getRandomString(5, 25); const headline = getRandomString(5, 25); const type = getRandomString(5, 15); - let event = { - category: category, - subCategory: subCategory, + const event = { + category, + subCategory, eventValue: { - isDismissible: isDismissible, + isDismissible, messageCopy: copy, messageHeadline: headline, - type: type, - }, + type + } }; store.addEventToBus(event); @@ -85,21 +85,21 @@ describe('Store', () => { const copy = getRandomString(5, 25); const headline = getRandomString(5, 25); const type = getRandomString(5, 15); - let event = { - category: category, - subCategory: subCategory, + const event = { + category, + subCategory, eventValue: { - isDismissible: isDismissible, + isDismissible, messageCopy: copy, messageHeadline: headline, - type: type, - }, + type + } }; store.addEventToBus(event); // Act - const actual = store.eventBusItem(event.category, event.subCategory) + const actual = store.eventBusItem(event.category, event.subCategory); // Assert expect(actual).toEqual(event.eventValue); @@ -107,38 +107,38 @@ describe('Store', () => { it('UpdateVehicle should merge vehicle with response object', () => { // Arrange - const carId = getRandomString(10,14); - const category = getRandomString(3,7); + const carId = getRandomString(10, 14); + const category = getRandomString(3, 7); const year = getRandomInt(1960, 2023); - const make = getRandomString(4,10); - const model = getRandomString(4,10); - const style = getRandomString(4,15); - const imageUrl = getRandomString(50,100); - const imageVifNumber = getRandomInt(10000,99999).toString(); - const imageColor = getRandomString(4,10); + const make = getRandomString(4, 10); + const model = getRandomString(4, 10); + const style = getRandomString(4, 15); + const imageUrl = getRandomString(50, 100); + const imageVifNumber = getRandomInt(10000, 99999).toString(); + const imageColor = getRandomString(4, 10); const providedVehicle = { - carId: carId, - category: category, - year: year, - make: make, - model: model, - style: style, - imageUrl: imageUrl, - imageVifNumber: imageVifNumber, + carId, + category, + year, + make, + model, + style, + imageUrl, + imageVifNumber, imageVifColor: imageColor }; const expectedVehicle = { - carId: carId, - category: category, - year: year, - make: make, - model: model, - style: style, - imageUrl: imageUrl, - imageVifNumber: imageVifNumber, - imageColor: imageColor - } + carId, + category, + year, + make, + model, + style, + imageUrl, + imageVifNumber, + imageColor + }; // Act store.updateVehicle(providedVehicle); @@ -149,16 +149,16 @@ describe('Store', () => { it('UpdateVehicle should set policy values appropriately with repair waived', () => { // Arrange - const noCompensation = getRandomBoolean(); - const deductible = getRandomInt(1,500); + const noCoverage = getRandomBoolean(); + const deductible = getRandomInt(1, 500); const vehicle = { - noCoverage: noCompensation, - deductible: deductible, + noCoverage, + deductible, repairWaived: true }; const expectedPolicy = { - noCompensation: noCompensation, + noCoverage, deductible: { replace: deductible, repair: 0 @@ -174,16 +174,16 @@ describe('Store', () => { it('UpdateVehicle should set policy values appropriately with repair not waived', () => { // Arrange - const noCompensation = getRandomBoolean(); - const deductible = getRandomInt(1,500); + const noCoverage = getRandomBoolean(); + const deductible = getRandomInt(1, 500); const vehicle = { - noCoverage: noCompensation, - deductible: deductible, + noCoverage, + deductible, repairWaived: false }; const expectedPolicy = { - noCompensation: noCompensation, + noCoverage, deductible: { replace: deductible, repair: deductible @@ -200,25 +200,25 @@ describe('Store', () => { // TODO update test to work also checking store values it('setVehicle should call globalMethods.callHttpClient', () => { // Arrange - const carId = getRandomString(10,14); - const category = getRandomString(3,7); + const carId = getRandomString(10, 14); + const category = getRandomString(3, 7); const year = getRandomInt(1960, 2023); - const make = getRandomString(4,10); - const model = getRandomString(4,10); - const style = getRandomString(4,15); - const imageUrl = getRandomString(50,100); - const imageVifNumber = getRandomInt(10000,99999).toString(); - const imageColor = getRandomString(4,10); + const make = getRandomString(4, 10); + const model = getRandomString(4, 10); + const style = getRandomString(4, 15); + const imageUrl = getRandomString(50, 100); + const imageVifNumber = getRandomInt(10000, 99999).toString(); + const imageColor = getRandomString(4, 10); const response = { data: { - carId: carId, - category: category, - year: year, - make: make, - model: model, - style: style, - imageUrl: imageUrl, - imageVifNumber: imageVifNumber, + carId, + category, + year, + make, + model, + style, + imageUrl, + imageVifNumber, imageVifColor: imageColor } }; @@ -235,14 +235,14 @@ describe('Store', () => { it('saveVehicleDamage with windshield repair should update damage with number of chips not null', () => { // Arrange - const glassName = getRandomString(4,10); - const glassLocation = getRandomString(5,15); + const glassName = getRandomString(4, 10); + const glassLocation = getRandomString(5, 15); const isWindshieldRepair = true; const selectedGlassToReplace = [{ - glassName: glassName, - glassLocation: glassLocation + glassName, + glassLocation }]; - const chipCount = getRandomInt(0,3); + const chipCount = getRandomInt(0, 3); // Act store.saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, chipCount); @@ -255,14 +255,14 @@ describe('Store', () => { it('saveVehicleDamage without windshield repair should update damage with number of chips null', () => { // Arrange - const glassName = getRandomString(4,10); - const glassLocation = getRandomString(5,15); + const glassName = getRandomString(4, 10); + const glassLocation = getRandomString(5, 15); const isWindshieldRepair = false; const selectedGlassToReplace = [{ - glassName: glassName, - glassLocation: glassLocation + glassName, + glassLocation }]; - const chipCount = getRandomInt(0,3); + const chipCount = getRandomInt(0, 3); const expectedChipCount = null; @@ -276,77 +276,77 @@ describe('Store', () => { }); it('should return registration data if available', () => { - //Arrange - const streetAddress = getRandomString(5,15); - const city = getRandomString(5,15); - const state = getRandomString(5,10); - const zipCode = getRandomInt(10000,99999).toString(); - const firstName = getRandomString(5,20); - const lastName = getRandomString(5,20); + // Arrange + const streetAddress = getRandomString(5, 15); + const city = getRandomString(5, 15); + const state = getRandomString(5, 10); + const zipCode = getRandomInt(10000, 99999).toString(); + const firstName = getRandomString(5, 20); + const lastName = getRandomString(5, 20); const expected = { addressQuestions: { - streetAddress: streetAddress, - city: city, - state: state, - zipCode: zipCode, + streetAddress, + city, + state, + zipCode }, - firstName: firstName, - lastName: lastName, - } + firstName, + lastName + }; store.order.vehicle.registration = { licensePlate: null, address: streetAddress, - city: city, - state: state, - zipCode: zipCode, - firstName: firstName, - lastName: lastName, + city, + state, + zipCode, + firstName, + lastName }; - //Act + // Act const actual = store.customerData; - //Assert + // Assert expect(actual).toEqual(expected); }); it('should return customer data if registration data unavailable', () => { - //Arrange - const address = getRandomString(1,25); - const city = getRandomString(5,20); - const state = getRandomString(4,20); + // Arrange + const address = getRandomString(1, 25); + const city = getRandomString(5, 20); + const state = getRandomString(4, 20); const zipCode = getRandomInt(10000, 99999).toString(); - const firstName = getRandomString(5,25); - const lastName = getRandomString(5,25); + const firstName = getRandomString(5, 25); + const lastName = getRandomString(5, 25); const expected = { addressQuestions: { streetAddress: address, - city: city, - state: state, - zipCode: zipCode, + city, + state, + zipCode }, - firstName: firstName, - lastName: lastName, - } + firstName, + lastName + }; store.order.vehicle.registration.address = null; store.order.customer = { address: { streetAddress: address, - city: city, - state: state, - zipCode: zipCode + city, + state, + zipCode }, - firstName: firstName, - lastName: lastName + firstName, + lastName }; - //Act + // Act const actual = store.customerData; - //Assert + // Assert expect(actual).toMatchObject(expected); }); @@ -364,7 +364,7 @@ describe('Store', () => { deductible: 0 } }; - store.policy.noCompensation = true; + store.policy.noCoverage = true; globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response)); @@ -390,7 +390,7 @@ describe('Store', () => { deductible: 0 } }; - store.policy.noCompensation = false; + store.policy.noCoverage = false; globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response)); From 30de957cdfae0b45ba42a0c1e17ffd9d9f7a6aeb Mon Sep 17 00:00:00 2001 From: brydon1 Date: Mon, 17 Jul 2023 13:38:02 -0400 Subject: [PATCH 6/6] Swapping compensation with coverage --- .../coverage-statement/coverage-statement.vue | 2 +- .../policy-vehicles/policy-vehicles.spec.js | 38 +++++++++---------- .../policy-vehicles/policy-vehicles.vue | 5 +-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index de887a8e..c3b96416 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -94,7 +94,7 @@ export default { } ]; - if (useMainStore().isClaimRegistrationRequired && !useMainStore().policy.noCompensation) { + if (useMainStore().isClaimRegistrationRequired && !useMainStore().policy.noCoverage) { const registerClaimResponse = await useMainStore().registerClaim(); promiseResultMap.push({ resultKey: 'registerClaim', diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js index cd505ff7..755f3590 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.spec.js +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -89,7 +89,7 @@ describe('policy-vehicles.vue', () => { //Arrange const { wrapper } = setupMocks({}); - const vin = getRandomString(17,17); + const vin = getRandomString(17, 17); await wrapper.setData({ selectedVehicleVin: vin, bailout: false @@ -130,21 +130,21 @@ describe('policy-vehicles.vue', () => { {} ); }); - }) + }); describe('noCoverageForSelectedVehicle computed property', () => { it('No vehicle match => returns true', async () => { // Arrange - const selectedVin = getRandomString(17,17); - const otherVin = getRandomString(17,17); + const selectedVin = getRandomString(17, 17); + const otherVin = getRandomString(17, 17); const testValues = { selectedVehicleVin: selectedVin, policyVehicles: [ { - vin: otherVin, - }, - ], - } + vin: otherVin + } + ] + }; // Act const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues); @@ -155,16 +155,16 @@ describe('policy-vehicles.vue', () => { it('Coverages list empty => true', () => { // Arrange - const vin = getRandomString(17,17); + const vin = getRandomString(17, 17); const testValues = { selectedVehicleVin: vin, policyVehicles: [ { - vin: vin, + vin, coverages: [] - }, - ], - } + } + ] + }; // Act const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues); @@ -175,20 +175,20 @@ describe('policy-vehicles.vue', () => { it('Coverages list non-empty => false', () => { // Arrange - const vin = getRandomString(17,17); + const vin = getRandomString(17, 17); const testValues = { selectedVehicleVin: vin, policyVehicles: [ { - vin: vin, + vin, coverages: [ { deductible: 0 } ] - }, - ], - } + } + ] + }; // Act const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues); @@ -196,7 +196,7 @@ describe('policy-vehicles.vue', () => { // Assert expect(result).toBeFalsy(); }); - }) + }); describe('deductibleForSelectedVehicle computed property', () => { diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 29e793ef..16699160 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -104,10 +104,9 @@ export default { }) ?? []; return mappedData; }, - noCompensationForSelectedVehicle() { + noCoverageForSelectedVehicle() { const vehicle = this.policyVehicles.find((policyVehicle) => policyVehicle.vin === this.selectedVehicleVin); - console.log((vehicle?.coverages?.length ?? 0) === 0); return (vehicle?.coverages?.length ?? 0) === 0; }, deductibleForSelectedVehicle() { @@ -175,7 +174,7 @@ export default { this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.selectedVehicleVin, - noCoverage: this.noCompensationForSelectedVehicle, + noCoverage: this.noCoverageForSelectedVehicle, deductible: this.deductibleForSelectedVehicle, repairWaived: this.repairWaivedForSelectedVehicle });