Merge pull request #366 from Safelite/defect/digital/SSR-505
Defect/digital/ssr 505
This commit is contained in:
commit
6b183f01aa
2 changed files with 67 additions and 73 deletions
|
|
@ -373,53 +373,54 @@ export const useMainStore = defineStore({
|
||||||
registerClaim() {
|
registerClaim() {
|
||||||
// TODO: replace place holder correlationId with the real thing
|
// TODO: replace place holder correlationId with the real thing
|
||||||
const placeHolderCorrelationId = '00000000-0000-0000-0000-000000000000';
|
const placeHolderCorrelationId = '00000000-0000-0000-0000-000000000000';
|
||||||
|
const nonNumberCharRegex = /[^0-9]/g;
|
||||||
globalMethods.callHttpClient({
|
globalMethods.callHttpClient({
|
||||||
method: endpoints.RegisterClaim.method,
|
method: endpoints.RegisterClaim.method,
|
||||||
endpoint: endpoints.RegisterClaim.url,
|
endpoint: endpoints.RegisterClaim.url,
|
||||||
payload:
|
payload:
|
||||||
{
|
{
|
||||||
correlationId: placeHolderCorrelationId,
|
correlationId: placeHolderCorrelationId,
|
||||||
accountNumber: this.issConfig.accountNumber?.toString() ?? '',
|
accountNumber: this.issConfig.accountNumber?.toString() ?? '',
|
||||||
insured: {
|
insured: {
|
||||||
firstName: this.order.customer.firstName,
|
firstName: this.order.customer.firstName,
|
||||||
lastName: this.order.customer.lastName,
|
lastName: this.order.customer.lastName,
|
||||||
address: {
|
address: {
|
||||||
addressLine1: this.order.customer.address.streetAddress,
|
addressLine1: this.order.customer.address.streetAddress,
|
||||||
addressLine2: this.order.customer.address.streetAddress2,
|
addressLine2: this.order.customer.address.streetAddress2,
|
||||||
city: this.order.customer.address.city,
|
city: this.order.customer.address.city,
|
||||||
state: this.order.customer.address.state,
|
state: this.order.customer.address.state,
|
||||||
zipCode: this.order.customer.address.zipCode,
|
zipCode: this.order.customer.address.zipCode,
|
||||||
country: 'US' // TODO set from store
|
country: 'US' // TODO set from store
|
||||||
},
|
},
|
||||||
homePhone: {
|
homePhone: {
|
||||||
number: this.order.customer.phoneNumber
|
number: this.order.customer.phoneNumber?.replaceAll(nonNumberCharRegex, '') ?? ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
caller: {
|
caller: {
|
||||||
homePhone: {}
|
homePhone: {}
|
||||||
},
|
},
|
||||||
policyInfo: {
|
policyInfo: {
|
||||||
policyNumber: this.order.policy.policyNumber,
|
policyNumber: this.order.policy.policyNumber,
|
||||||
safelitePolicy: {
|
safelitePolicy: {
|
||||||
policies: []
|
policies: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lossInfo: {
|
lossInfo: {
|
||||||
dateOfLoss: this.order.policy.dateOfLoss,
|
dateOfLoss: this.order.policy.dateOfLoss,
|
||||||
location: {
|
location: {
|
||||||
city: this.order.policy.damageCity,
|
city: this.order.policy.damageCity,
|
||||||
state: this.order.policy.damageState,
|
state: this.order.policy.damageState,
|
||||||
country: 'US' // TODO set from store
|
country: 'US' // TODO set from store
|
||||||
},
|
},
|
||||||
vehicle: {
|
vehicle: {
|
||||||
year: this.order.vehicle.year?.toString() ?? '',
|
year: this.order.vehicle.year?.toString() ?? '',
|
||||||
make: this.order.vehicle.make,
|
make: this.order.vehicle.make,
|
||||||
model: this.order.vehicle.model,
|
model: this.order.vehicle.model,
|
||||||
vin: this.order.vehicle.vin
|
vin: this.order.vehicle.vin
|
||||||
}
|
},
|
||||||
},
|
damageDescription: this.order.policy.damageCause
|
||||||
damageDescription: this.order.policy.damageCause
|
}
|
||||||
}
|
}
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
const registerClaimFailed = response.data.isError;
|
const registerClaimFailed = response.data.isError;
|
||||||
this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed;
|
this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed;
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,27 @@
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import { createApp } from 'vue';
|
import { setActivePinia, createPinia } from 'pinia';
|
||||||
import { setActivePinia, createPinia } from "pinia";
|
import globalMethods from '@/global-methods';
|
||||||
import globalMethods from "@/global-methods";
|
|
||||||
import App from '@/App';
|
|
||||||
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation';
|
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation';
|
||||||
import { coverageStatuses } from "@/constants/coverage-statuses.js";
|
import { coverageStatuses } from '@/constants/coverage-statuses.js';
|
||||||
|
|
||||||
describe("Store", () => {
|
|
||||||
|
|
||||||
|
describe('Store', () => {
|
||||||
let store;
|
let store;
|
||||||
|
|
||||||
const vueApp = createApp(App);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
setActivePinia(pinia);
|
setActivePinia(pinia);
|
||||||
vueApp.use(pinia);
|
|
||||||
store = useMainStore();
|
store = useMainStore();
|
||||||
store.applicationUser.eventBus = [];
|
store.applicationUser.eventBus = [];
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should Store Vehicle Year', () => {
|
||||||
it("Should Store Vehicle Year", () => {
|
const testYear = '2001';
|
||||||
let testYear = "2001";
|
|
||||||
store.updateVehicleYear(testYear);
|
store.updateVehicleYear(testYear);
|
||||||
expect(store.order.vehicle.year).toEqual(testYear);
|
expect(store.order.vehicle.year).toEqual(testYear);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should add events to the bus", () => {
|
it('Should add events to the bus', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const category = getRandomString(1, 25);
|
const category = getRandomString(1, 25);
|
||||||
const subCategory = getRandomString(5, 20);
|
const subCategory = getRandomString(5, 20);
|
||||||
|
|
@ -54,7 +47,7 @@ describe("Store", () => {
|
||||||
expect(store.applicationUser.eventBus[0]).toEqual(event);
|
expect(store.applicationUser.eventBus[0]).toEqual(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should remove events from the bus", () => {
|
it('Should remove events from the bus', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const category = getRandomString(1, 25);
|
const category = getRandomString(1, 25);
|
||||||
const subCategory = getRandomString(5, 20);
|
const subCategory = getRandomString(5, 20);
|
||||||
|
|
@ -84,7 +77,7 @@ describe("Store", () => {
|
||||||
expect(store.applicationUser.eventBus.length).toBe(0);
|
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
|
// Arrange
|
||||||
const category = getRandomString(1, 25);
|
const category = getRandomString(1, 25);
|
||||||
const subCategory = getRandomString(5, 20);
|
const subCategory = getRandomString(5, 20);
|
||||||
|
|
@ -112,7 +105,7 @@ describe("Store", () => {
|
||||||
expect(actual).toEqual(event.eventValue);
|
expect(actual).toEqual(event.eventValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("UpdateVehicle should merge vehicle with response object", () => {
|
it('UpdateVehicle should merge vehicle with response object', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const carId = getRandomString(10,14);
|
const carId = getRandomString(10,14);
|
||||||
const category = getRandomString(3,7);
|
const category = getRandomString(3,7);
|
||||||
|
|
@ -154,7 +147,7 @@ describe("Store", () => {
|
||||||
expect(store.order.vehicle).toMatchObject(expectedVehicle);
|
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
|
// Arrange
|
||||||
const noCompensation = getRandomBoolean();
|
const noCompensation = getRandomBoolean();
|
||||||
const deductible = getRandomInt(1,500);
|
const deductible = getRandomInt(1,500);
|
||||||
|
|
@ -179,7 +172,7 @@ describe("Store", () => {
|
||||||
expect(store.order.policy).toMatchObject(expectedPolicy);
|
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
|
// Arrange
|
||||||
const noCompensation = getRandomBoolean();
|
const noCompensation = getRandomBoolean();
|
||||||
const deductible = getRandomInt(1,500);
|
const deductible = getRandomInt(1,500);
|
||||||
|
|
@ -205,7 +198,7 @@ describe("Store", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO update test to work also checking store values
|
// TODO update test to work also checking store values
|
||||||
it("setVehicle should call globalMethods.callHttpClient", () => {
|
it('setVehicle should call globalMethods.callHttpClient', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const carId = getRandomString(10,14);
|
const carId = getRandomString(10,14);
|
||||||
const category = getRandomString(3,7);
|
const category = getRandomString(3,7);
|
||||||
|
|
@ -240,7 +233,7 @@ describe("Store", () => {
|
||||||
expect(returned).resolves.toMatchObject(response);
|
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
|
// Arrange
|
||||||
const glassName = getRandomString(4,10);
|
const glassName = getRandomString(4,10);
|
||||||
const glassLocation = getRandomString(5,15);
|
const glassLocation = getRandomString(5,15);
|
||||||
|
|
@ -260,7 +253,7 @@ describe("Store", () => {
|
||||||
expect(store.order.damage.numberOfChips).toEqual(chipCount);
|
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
|
// Arrange
|
||||||
const glassName = getRandomString(4,10);
|
const glassName = getRandomString(4,10);
|
||||||
const glassLocation = getRandomString(5,15);
|
const glassLocation = getRandomString(5,15);
|
||||||
|
|
@ -282,7 +275,7 @@ describe("Store", () => {
|
||||||
expect(store.order.damage.numberOfChips).toEqual(expectedChipCount);
|
expect(store.order.damage.numberOfChips).toEqual(expectedChipCount);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return registration data if available", () => {
|
it('should return registration data if available', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
const streetAddress = getRandomString(5,15);
|
const streetAddress = getRandomString(5,15);
|
||||||
const city = getRandomString(5,15);
|
const city = getRandomString(5,15);
|
||||||
|
|
@ -318,7 +311,7 @@ describe("Store", () => {
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return customer data if registration data unavailable", () => {
|
it('should return customer data if registration data unavailable', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
const address = getRandomString(1,25);
|
const address = getRandomString(1,25);
|
||||||
const city = getRandomString(5,20);
|
const city = getRandomString(5,20);
|
||||||
|
|
@ -357,8 +350,8 @@ describe("Store", () => {
|
||||||
expect(actual).toMatchObject(expected);
|
expect(actual).toMatchObject(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("registerClaim method", () => {
|
describe('registerClaim method', () => {
|
||||||
it("successful response with no coverage => isVerified true and coverage status no comp", async () => {
|
it('successful response with no coverage => isVerified true and coverage status no comp', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const response = {
|
const response = {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -384,7 +377,7 @@ describe("Store", () => {
|
||||||
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COMP);
|
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
|
// Arrange
|
||||||
const response = {
|
const response = {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -408,9 +401,9 @@ describe("Store", () => {
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||||
expect(store.payment.insuranceCoverage.isVerified).toBe(true);
|
expect(store.payment.insuranceCoverage.isVerified).toBe(true);
|
||||||
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED);
|
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
|
// Arrange
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject());
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue