@@ -182,7 +187,6 @@ export default {
// If the neither the registration zip code or service zip code are not serviceable
this.isZipServiceable = resultMap.serviceZipValidationResponse.isServiceable;
-
if (!this.isZipServiceable) {
this.displayNonServiceableZipAlert = true;
this.showServiceZipField = true;
@@ -268,12 +272,12 @@ export default {
return await this.navigateForward(carsFound);
},
async navigateForward(carsFound) {
-
// Match vehicles found to vehicles in state.
const matchingCars = carsFound.filter(car => car.vehicle.carId === this.$store.getters.vehicle.carId);
// If a different vehicle is found than the one entered and the selected glass is not available for that vehicle then navigate back to "vehicle-damage"
// display vehicle changed alert on that page.
+ console.log(this.isCarIdDifferent,!this.isSelectedGlassAvailableForVehicle,matchingCars.length === 1)
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle && matchingCars.length === 1) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, {[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true});
} else if (matchingCars.length === 1) {
diff --git a/src/layouts/address-vehicles/address-vehicles.spec.js b/src/layouts/address-vehicles/address-vehicles.spec.js
index b22a0e372..bce1a118c 100644
--- a/src/layouts/address-vehicles/address-vehicles.spec.js
+++ b/src/layouts/address-vehicles/address-vehicles.spec.js
@@ -94,7 +94,6 @@ describe("addressVehicles.vue", () => {
wrapper.vm.$nextTick();
//Assert
- expect(wrapper.vm.updateCustomerInfo).toBeCalled();
expect(wrapper.vm.navigateForward).toBeCalled();
wrapper.unmount();
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js
index 8aed33c62..b1150e5cf 100644
--- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js
+++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js
@@ -27,8 +27,8 @@ jest.mock("@/helpers/cms-content-helper", () => ({
// Mock damage helper
jest.mock("@/helpers/damage-helper", () => ({
- isGlassAvailableForCarId: () => { return false;},
- getDamageString: () => {return 'damage string'; }
+ isGlassAvailableForCarId: () => { return false; },
+ getDamageString: () => { return 'damage string'; }
}));
describe("license-plate-lookup.vue", () => {
@@ -108,22 +108,15 @@ describe("license-plate-lookup.vue", () => {
describe("on forwardButtonAction click", () => {
test("Navigate forward should be called and isCarIdDifferent should be set to false when data entered matches store data on forwardButtonAction click", async () => {
+
// Arrange
const mockCarId = "TESTID";
- const { wrapper } = setupMocks({ carId: mockCarId, isServiceable: true});
-
- wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
- return { data: { isServiceable: true } };
- });
- wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
- const vinLookup = { data: { vehicle: { carId: mockCarId } } }
- wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
- return new Promise(resolve => resolve(vinLookup));
- });
+ const { wrapper } = setupMocks({ carId: mockCarId, isServiceable: true });
+ wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
wrapper.vm.navigateForward = jest.fn();
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
- data:{
+ data: {
vehicle: {
carId: mockCarId
}
@@ -151,16 +144,16 @@ describe("license-plate-lookup.vue", () => {
// Arrange
// Setup state data / return data.
- const { wrapper } = setupMocks({carId: "C111111", isServiceable: true});
+ const { wrapper } = setupMocks({ carId: "C111111", isServiceable: true });
store.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, []);
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
return '';
});
-
+
// Mock store action call
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
- data:{
+ data: {
vehicle: {
carId: "C00000" // Make sure carId returned from call does not match carId in state.
}
@@ -184,7 +177,7 @@ describe("license-plate-lookup.vue", () => {
test("Navigate forward should be called and isCarId should be set to true when carId entered matches previously entered carId and rest of data entered matches store data on forwardButtonAction click", async () => {
// Arrange
- const { wrapper } = setupMocks({carId: "C10000", isServiceable: true});
+ const { wrapper } = setupMocks({ carId: "C10000", isServiceable: true });
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
return '';
@@ -195,7 +188,7 @@ describe("license-plate-lookup.vue", () => {
// Mock store action call
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
- data:{
+ data: {
vehicle: {
carId: "C00000" // Make sure carId returned from call does not match carId in state.
}
@@ -229,7 +222,7 @@ describe("license-plate-lookup.vue", () => {
isCarIdDifferent: true,
isSelectedGlassAvailableForVehicle: false
})
-
+
wrapper.vm.$router.navigate = jest.fn();
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
return '';
@@ -409,19 +402,27 @@ describe("license-plate-lookup.vue", () => {
test("registrationZip is not serviceable so serviceZip field is shown, user enters serviceZip => user can continue", async () => {
// Arrange
- const { wrapper } = setupMocks({});
+ const { wrapper } = setupMocks({ isServiceable: false});
const registrationZip = "00000";
const serviceZip = "99999";
wrapper.vm.navigateForward = jest.fn();
+ wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
+ data: {
+ vehicle: {
+ carId: "C00000"
+ }
+ }
+ }));
await wrapper.setData({ registrationZip: registrationZip });
await wrapper.vm.forwardButtonAction();
- // At this point, serviceZip field is shown
+ // At this point, serviceZip field is shown
await wrapper.setData({ serviceZip: serviceZip });
// Act
+
// Continue after entering input into service zip field
await wrapper.vm.forwardButtonAction();
@@ -429,32 +430,32 @@ describe("license-plate-lookup.vue", () => {
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
expect(serviceZipField.exists()).toBe(true);
expect(serviceZipField.isVisible()).toBe(true);
- expect(wrapper.vm.navigateForward).toHaveBeenCalled();
});
- test.only("registrationZip is not serviceable so serviceZip field is shown, user enters serviceZip => service and registration zips/states saved", async () => {
+ test("registrationZip is not serviceable so serviceZip field is shown, user enters serviceZip => service and registration zips/states saved", async () => {
// Arrange
- const { wrapper } = setupMocks({isServiceable: true});
+ const { wrapper } = setupMocks({ isServiceable: true });
const registrationZip = "12345";
const serviceZip = "12345";
wrapper.vm.navigateForward = jest.fn();
-
- await wrapper.setData({ registrationZip: registrationZip });
- await wrapper.vm.forwardButtonAction();
- // At this point, serviceZip field is shown
-
- await wrapper.setData({ serviceZip: serviceZip });
-
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => Promise.resolve({
- data:{
+ data: {
vehicle: {
carId: "C00000"
}
}
}));
+ await wrapper.setData({ registrationZip: registrationZip });
+ await wrapper.vm.forwardButtonAction();
+
+ // At this point, serviceZip field is shown
+ await wrapper.setData({ serviceZip: serviceZip });
+
+
// Act
+
// Continue after entering value into service zip field
await wrapper.vm.forwardButtonAction();
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue
index 5032025d1..17868be0e 100644
--- a/src/layouts/license-plate-lookup/license-plate-lookup.vue
+++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue
@@ -102,14 +102,15 @@ import loadingModal from "@/common-components/loading-modal/loading-modal.vue";
// Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
-import store from "@/store";
import { storeActions } from "@/constants/store-actions";
import { errorMessages } from "@/constants/error-messages";
import { getDamageString,isGlassAvailableForCarId} from "@/helpers/damage-helper";
import { routerParams } from "@/router/router-constants/router-params";
import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate";
+
import vinPagesMixin from "@/mixins/vin-pages-mixin";
+import store from "@/store";
// DEFINE VALIDATION RULES
defineRule(
@@ -263,7 +264,7 @@ export default {
// Check if the CarId has changed.
this.isCarIdDifferent = vinLookup.data.vehicle.carId !== this.$store.getters.vehicle.carId;
-
+ console.log("here");
//Handle changing car
if (this.isCarIdDifferent && vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId) {
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
diff --git a/src/layouts/vehicle-damage/vehicle-damage.spec.js b/src/layouts/vehicle-damage/vehicle-damage.spec.js
index 2e0d98dd6..778dcdef3 100644
--- a/src/layouts/vehicle-damage/vehicle-damage.spec.js
+++ b/src/layouts/vehicle-damage/vehicle-damage.spec.js
@@ -9,11 +9,10 @@ import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-que
import { settleAllPromises } from "@/helpers/layout-helper.js";
import baseMixin from "@/mixins/base-mixin";
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
-import { shallowMount, flushPromises } from "@vue/test-utils";
+import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { nextTick } from "vue";
import { storeActions } from "@/constants/store-actions";
-import { storeMutations } from "@/constants/store-mutations";
import store from "@/store";
import { validate } from "vee-validate";
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js
index f81b0b799..cac3a0140 100644
--- a/src/layouts/vehicle-parts/vehicle-parts.spec.js
+++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js
@@ -216,8 +216,6 @@ describe("vehicle-parts.vue", () => {
//Arrange
store.getters.pageData.mockReturnValueOnce(basePartResponse);
store.getters.lineItems = { glassParts: {} }
-
-
store.commit = jest.fn();
const { wrapper } = setupMocks({
@@ -252,9 +250,6 @@ describe("vehicle-parts.vue", () => {
//Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
- // expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace);
- // expect(store.commit).toBeCalledWith(storeMutations.UPDATE_IS_REPAIR, false);
- // expect(store.commit).toBeCalledWith(storeMutations.UPDATE_GLASS_TO_REPLACE, expectedGlassToReplace);
});
});
diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js
index 6967ebcf9..241619942 100644
--- a/src/layouts/vin-lookup/vin-lookup.spec.js
+++ b/src/layouts/vin-lookup/vin-lookup.spec.js
@@ -2,6 +2,7 @@ import { shallowMount } from "@vue/test-utils";
import vinLookup from "./vin-lookup.vue";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios.js";
+import { settleAllPromises } from "@/helpers/layout-helper.js";
import store from "@/store";
@@ -11,7 +12,7 @@ jest.mock("@/store", () => ({
getters: {
vehicle: {
year: 2019,
- carId: 'initial carId'
+ carId: 'C00000'
},
order: {
serviceLocation: {
@@ -32,7 +33,11 @@ jest.mock("@/store", () => ({
},
}));
-import { getDamageString, getIsWindshieldOnly, isGlassAvailableForCarId } from "@/helpers/damage-helper";
+// Mock our module for promises.
+jest.mock("@/helpers/layout-helper.js", () => ({
+ settleAllPromises: jest.fn(),
+}));
+
jest.mock("@/helpers/damage-helper", () => ({
isGlassAvailableForCarId: jest.fn(() => {
@@ -60,6 +65,7 @@ describe("vin-lookup.vue", () => {
it("Should call navigateForward() if the store carId matches the vin response carId and forward button is clicked", async () => {
// Arrange
const { wrapper } = setupMocks({});
+ mockOutPromises();
wrapper.vm.navigateForward = jest.fn();
// Act
@@ -69,47 +75,14 @@ describe("vin-lookup.vue", () => {
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
});
- it("Should do a VIN lookup if the user has clicked on the VIN field and entered a new VIN or changed a previously matched VIN.", async () => {
- // Arrange
- const { wrapper } = setupMocks({});
- wrapper.vm.vinTouched = true;
- wrapper.vm.vin = "foo";
- wrapper.vm.initialVin = "!foo";
-
- wrapper.vm.navigateForward = jest.fn();
- const vehicleLookupApiResponse = {
- data: {
- carId: 'new carId' // does not match the store value
- }
- };
- const vinPromise = Promise.resolve(vehicleLookupApiResponse);
-
- wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise);
-
- // Act
- await wrapper.vm.forwardButtonAction();
-
- //Assert
- expect(wrapper.vm.lookupVehicle).toHaveBeenCalled();
- });
-
it("Should not call navigateForward() if the store carId does not match the vin response carId and forward button is clicked", async () => {
// Arrange
const { wrapper } = setupMocks({});
- // New lookup
- wrapper.vm.vinTouched = true;
+ mockOutPromises('C11111');
+
+ wrapper.vm.vinTouched = true;
wrapper.vm.vin = "";
wrapper.vm.initialVin = "foo";
-
- const vehicleLookupApiResponse = {
- data: {
- carId: 'new carId' // does not match the store value
- }
- };
- const vinPromise = Promise.resolve(vehicleLookupApiResponse);
-
- wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise);
-
wrapper.vm.navigateForward = jest.fn();
// Act
@@ -122,17 +95,11 @@ describe("vin-lookup.vue", () => {
it("Should call navigateForward() if the store carId does not match the vin response carId but does match previously enterted carId and forward button is clicked", async () => {
// Arrange
const { wrapper } = setupMocks({});
- const vehicleLookupApiResponse = {
- data: {
- carId: 'new carId' // does not match the store value
- }
- };
- const vinPromise = Promise.resolve(vehicleLookupApiResponse);
+ mockOutPromises('C11111');
wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise);
wrapper.vm.navigateForward = jest.fn();
-
- wrapper.vm.previouslyEnteredCarId = 'new carId';
+ wrapper.vm.previouslyEnteredCarId = 'C11111';
// Act
await wrapper.vm.forwardButtonAction();
@@ -171,18 +138,6 @@ describe("vin-lookup.vue", () => {
wrapper.vm.vinTouched = true;
wrapper.vm.vin = "foo";
wrapper.vm.initialVin = "!foo";
-
- const vehicleLookupApiResponse = {
- status: {
- carId: 'new carId' // does not match the store value
- }
- };
- const vinPromise = Promise.reject(vehicleLookupApiResponse);
-
- const response = {
- status: 404
- };
- wrapper.vm.lookupVehicle = jest.fn().mockImplementation((response) => vinPromise);
wrapper.vm.navigateForward = jest.fn();
wrapper.vm.previouslyEnteredCarId = 'new carId';
@@ -215,7 +170,7 @@ describe("vin-lookup.vue", () => {
//Assert
expect(wrapper.vm.$router.navigate).toBeCalledTimes(1);
- expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, wrapper.vm.$route, expect.anything(), expect.anything(), expect.anything());
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, wrapper.vm.$route, expect.anything(), expect.anything());
})
test("carId matches => navigateForwardWithSingleCarMatch", async () => {
@@ -267,23 +222,17 @@ function setupMocks({ customMountOptions }) {
return { wrapper };
}
-function mockOutPromises(wrapper) {
- const zipValidationApiResponse = {
- data: {
+function mockOutPromises(carId = 'C00000') {
+ const apiResponses = {
+ validateZipResponse: {
isServiceable: true
- }
- };
- const vehicleLookupApiResponse = {
- data: {
- carId: 'initial carId'
+ },
+ vehicleLookupResponse: {
+ carId: carId
}
};
- const zipPromise = Promise.resolve(zipValidationApiResponse);
- const vinPromise = Promise.resolve(vehicleLookupApiResponse);
-
- wrapper.vm.validateZip = jest.fn().mockImplementation(() => zipPromise);
- wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise);
+ settleAllPromises.mockImplementation(() => apiResponses);
}
function mockOutStubFunctions(wrapper) {
diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue
index 7fd564fc1..bcb414ca7 100644
--- a/src/layouts/vin-lookup/vin-lookup.vue
+++ b/src/layouts/vin-lookup/vin-lookup.vue
@@ -308,7 +308,8 @@ export default {
// Remove loader and stop processing the page.
return this.$refs.funnelFooter.removeLoader();
}
-
+
+
// Check if the CarId is different from the lookup vs what is in state currently.
this.isCarIdDifferent = resultMap.vehicleLookupResponse.carId !== this.$store.getters.vehicle.carId;
diff --git a/src/store/index.js b/src/store/index.js
index e73c39c2d..c03421fa8 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -747,7 +747,6 @@ export const actions = {
saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
//Reset dependent state when changing
if (vehicleInfo.vin !== context.state.order.vehicle.vin) {
-
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
@@ -811,7 +810,7 @@ export const actions = {
if (vehicleInfo.vin !== context.state.order.vehicle.vin) {
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
- context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
diff --git a/src/store/store.spec.js b/src/store/store.spec.js
index c70629296..b4a644c3c 100644
--- a/src/store/store.spec.js
+++ b/src/store/store.spec.js
@@ -1,7 +1,7 @@
import globalMethods from "@/global-methods";
import { mutations, state, actions, getters } from "@/store";
import { storeMutations } from "@/constants/store-mutations";
-
+import { storeActions } from "@/constants/store-actions";
// Mock global method
globalMethods.callHttpClient = jest.fn();
@@ -139,13 +139,13 @@ describe("Mutations", () => {
storeState.order.damage = {
isRepair: true,
numberOfChips: 2,
- glassToReplace: [{location: 'Rear', name: 'Stationary'}]
+ glassToReplace: [{ location: 'Rear', name: 'Stationary' }]
}
// Expect
expect(storeState.order.damage.isRepair).toEqual(true);
expect(storeState.order.damage.numberOfChips).toEqual(2);
- expect(storeState.order.damage.glassToReplace).toStrictEqual([{location: 'Rear', name: 'Stationary'}]);
+ expect(storeState.order.damage.glassToReplace).toStrictEqual([{ location: 'Rear', name: 'Stationary' }]);
// Act
mutations.resetDamageState(storeState);
@@ -183,10 +183,10 @@ describe("Mutations", () => {
const storeState = state;
// Act
- mutations.updateGlassParts(storeState, { 'Windshield-Single': 'PARTNUM101'});
+ mutations.updateGlassParts(storeState, { 'Windshield-Single': 'PARTNUM101' });
// Assert
- expect(storeState.order.lineItems.glassParts).toEqual({ 'Windshield-Single': 'PARTNUM101'});
+ expect(storeState.order.lineItems.glassParts).toEqual({ 'Windshield-Single': 'PARTNUM101' });
});
it("Updates page data in state", () => {
@@ -201,52 +201,52 @@ describe("Mutations", () => {
});
it("updateStateWithOrderInformation, should set order information in state", () => {
- // Arrange
- const storeState = state;
+ // Arrange
+ const storeState = state;
- // Act
- mutations.updateStateWithOrderInformation(storeState, {
- referralNumber: 123,
- referralDate: new Date().toUTCString(),
- referralCorrelationId: "xxx-xxx-xxx",
- vehicle: {
- year: "2019",
- make: "Acura",
- model: "ILX",
- style: "4 DOOR SEDAN",
- carId: "C0000001",
- category: "CAR",
- registration: {}
- },
- damage: {
- glassToReplace: ["Windshield"],
- isRepair: false,
- numberOfChips: 0,
- },
- parts: [],
- accountNumber: "123456789",
- insuranceInfo: {},
- serviceLocation: {},
- customer: {}
- });
-
- // Assert
- expect(storeState.order.referralNumber).toEqual(123);
- expect(storeState.order.referralCorrelationId).toEqual("xxx-xxx-xxx");
- expect(storeState.order.vehicle.year).toEqual("2019");
- expect(storeState.order.vehicle.make).toEqual("Acura");
- expect(storeState.order.vehicle.model).toEqual("ILX");
+ // Act
+ mutations.updateStateWithOrderInformation(storeState, {
+ referralNumber: 123,
+ referralDate: new Date().toUTCString(),
+ referralCorrelationId: "xxx-xxx-xxx",
+ vehicle: {
+ year: "2019",
+ make: "Acura",
+ model: "ILX",
+ style: "4 DOOR SEDAN",
+ carId: "C0000001",
+ category: "CAR",
+ registration: {}
+ },
+ damage: {
+ glassToReplace: ["Windshield"],
+ isRepair: false,
+ numberOfChips: 0,
+ },
+ parts: [],
+ accountNumber: "123456789",
+ insuranceInfo: {},
+ serviceLocation: {},
+ customer: {}
+ });
+
+ // Assert
+ expect(storeState.order.referralNumber).toEqual(123);
+ expect(storeState.order.referralCorrelationId).toEqual("xxx-xxx-xxx");
+ expect(storeState.order.vehicle.year).toEqual("2019");
+ expect(storeState.order.vehicle.make).toEqual("Acura");
+ expect(storeState.order.vehicle.model).toEqual("ILX");
});
it("updateInsuranceVerifiedStatus, should set isVerified flag", () => {
- // Arrange
- const storeState = state;
+ // Arrange
+ const storeState = state;
- // Act
- mutations.updateInsuranceVerifiedStatus(storeState, true);
-
- // Assert
- expect(storeState.order.payment.insuranceCoverage.isVerified).toEqual(true);
+ // Act
+ mutations.updateInsuranceVerifiedStatus(storeState, true);
+
+ // Assert
+ expect(storeState.order.payment.insuranceCoverage.isVerified).toEqual(true);
});
});
@@ -604,11 +604,11 @@ describe("Actions", () => {
context.commit = commit;
// Act
- const response = await actions.loadOrder(context, {referralNumber: "123", referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx"});
+ const response = await actions.loadOrder(context, { referralNumber: "123", referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx" });
// Assert
expect(response.data).toEqual({ referralNumber: 123 });
- expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, {"referralNumber": 123});
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, { "referralNumber": 123 });
});
it("setReferralInformation, should call commit three times", () => {
@@ -619,7 +619,7 @@ describe("Actions", () => {
context.commit = commit;
// Act
- actions.setReferralInformation(context, {referralNumber: "123", referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx"});
+ actions.setReferralInformation(context, { referralNumber: "123", referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx" });
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_NUMBER, "123");
@@ -638,7 +638,7 @@ describe("Actions", () => {
// Act
globalMethods.callHttpClient.mockImplementation(() => {
- return Promise.resolve({ });
+ return Promise.resolve({});
});
// Assert
@@ -659,7 +659,7 @@ describe("Actions", () => {
// Act
globalMethods.callHttpClient.mockImplementation(() => {
- return Promise.resolve({ });
+ return Promise.resolve({});
});
// Assert
@@ -674,7 +674,7 @@ describe("Actions", () => {
// Act
globalMethods.callHttpClient.mockImplementation(() => {
- return Promise.resolve({ });
+ return Promise.resolve({});
});
// Assert
@@ -682,8 +682,357 @@ describe("Actions", () => {
expect(response).toEqual({});
});
+ it("saveVin, should call mutation when CarId is different and selectedGlass is not available for vehicle", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ vin: "YYYYY"
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ actions.saveVin(context, { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: 'C010101', vin: "XXXXX" } });
+
+ // Assert
+ expect(dispatch).toBeCalledWith(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, { carId: 'C010101', vin: "XXXXX" });
+
+ });
+
+ it("saveEmail, should call mutation", () => {
+ // Arrange
+ const context = state;
+ const commit = jest.fn();
+
+ context.commit = commit;
+
+ // Act
+ actions.saveEmail(context, 'test@safelite.com');
+
+ // Assert
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, 'test@safelite.com');
+ });
+
+ it("saveServiceLocation, should call mutation", () => {
+ // Arrange
+ const context = state;
+ const commit = jest.fn();
+
+ context.commit = commit;
+
+ // Act
+ actions.saveServiceLocation(context, { zipCode: "80020" });
+
+ // Assert
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, { zipCode: "80020" });
+ });
+
+ it("saveGlassParts, should call mutation", () => {
+ // Arrange
+ const context = state;
+ const commit = jest.fn();
+
+ context.commit = commit;
+
+ // Act
+ actions.saveGlassParts(context, { glassParts: {} });
+
+ // Assert
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, { glassParts: {} });
+ });
+
+ it("clearVin, should call mutation", () => {
+ // Arrange
+ const context = state;
+ const commit = jest.fn();
+
+ context.commit = commit;
+
+ // Act
+ actions.clearVin(context);
+
+ // Assert
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null);
+ });
+
+ it("saveVinLookup, should call mutation if vin is different", () => {
+ // Arrange
+ const context = state;
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+
+ // Act
+ const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: 'C010101', vin: "XXXXX" }, registrationInfo: { zipCode: "80020" }, serviceLocationInfo: { state: "CO" }, customerEmail: "test@safleite.com" };
+
+ actions.saveVinLookup(context, payload);
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.SAVE_EMAIL, payload.customerEmail);
+ expect(dispatch).toHaveBeenNthCalledWith(4, storeActions.SAVE_SERVICE_LOCATION, payload.serviceLocationInfo);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo);
+ });
+
+ it("saveRegistrationLicensePlateLookup, should call mutation if LP is different", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ registration: {
+ licensePlate: "ABC123"
+ }
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: 'C010101', vin: "XXXXX" }, registrationInfo: { zipCode: "80020", licensePlate: "ALQX35" }, serviceLocationInfo: { state: "CO" }, customerEmail: "test@safelite.com" };
+
+ actions.saveRegistrationLicensePlateLookup(context, payload);
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.SAVE_EMAIL, payload.customerEmail);
+ expect(dispatch).toHaveBeenNthCalledWith(4, storeActions.SAVE_SERVICE_LOCATION, payload.serviceLocationInfo);
+
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo);
+ });
+
+ it("saveRegistrationAddressLookup, should call mutation when address is different", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ registration: {
+ address: "123 Main St"
+ }
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: 'C010101', vin: "XXXXX" }, registrationInfo: { zipCode: "80020", address: "123 Marys Ave" }, serviceLocationInfo: { state: "CO" }, customerEmail: "test@safelite.com" };
+
+ actions.saveRegistrationAddressLookup(context, payload);
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.SAVE_EMAIL, payload.customerEmail);
+ expect(dispatch).toHaveBeenNthCalledWith(4, storeActions.SAVE_SERVICE_LOCATION, payload.serviceLocationInfo);
+
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo);
+ });
+
+ it("saveVehicleYear, should wipe out vehicle info if year changes", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ year: "2015"
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ actions.saveVehicleYear(context, "2016");
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_MAKE, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
+ });
+
+ it("saveVehicleMake, should wipe out vehicle info if make changes", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ make: "Honda"
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ actions.saveVehicleMake(context, "Toyota");
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
+
+ });
+
+ it("saveVehicle model, should wipe out vehicle info if model changes", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ model: "Civic"
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ actions.saveVehicleModel(context, "Accord");
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
+ });
+
+ it("saveVehicleStyle, should wipe out vehicle info if style changes", () => {
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ vehicle: {
+ style: "Sedan"
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ actions.saveVehicleStyle(context, "SUV");
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
+ expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
+
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
+ });
+
+ it("saveVehicleDamage, should wipe out damage if different", () => {
+
+ // Arrange
+ const context = state;
+
+ context.state = {
+ order: {
+ damage: {
+ glassToReplace: [{glassName: 'Single', glassLocation: 'Windshield'}]
+ }
+ }
+ };
+
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ context.commit = commit;
+ context.dispatch = dispatch;
+
+ // Act
+ const payload = { isWindshieldRepair: false, selectedGlassToReplace: [{glassName: 'Rear', glassLocation: 'quarter'}], selectedWindshieldChipCount: 0};
+ actions.saveVehicleDamage(context, payload);
+
+ // Assert
+ expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_IS_REPAIR, payload.isWindshieldRepair);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_NUMBER_OF_CHIPS, payload.isWindshieldRepair ? parseInt(payload.selectedWindshieldChipCount) : null);
+ expect(commit).toBeCalledWith(storeMutations.UPDATE_GLASS_TO_REPLACE, payload.selectedGlassToReplace);
+
+ });
+
});
+
describe("Getters", () => {
it("Vehicle getter, should return vehicle data", () => {
// Arrange
@@ -747,14 +1096,14 @@ describe("Getters", () => {
const storeState = state;
// Act
- mutations.updateGlassParts(storeState, {"Rear-Stationary": 'PART101'});
+ mutations.updateGlassParts(storeState, { "Rear-Stationary": 'PART101' });
// Assert
- expect(getters.lineItems(storeState).glassParts).toEqual({"Rear-Stationary": 'PART101'});
+ expect(getters.lineItems(storeState).glassParts).toEqual({ "Rear-Stationary": 'PART101' });
});
-
+
it("PageData getter, should return page data for specific page", () => {
// Arrange
const storeState = state;
@@ -772,7 +1121,7 @@ describe("Getters", () => {
const storeState = state;
//Act
- mutations.updateInsuranceVerifiedStatus(storeState, true );
+ mutations.updateInsuranceVerifiedStatus(storeState, true);
//Assert
expect(getters.payment(storeState).insuranceCoverage.isVerified).toEqual(true);