Merge remote-tracking branch 'origin/feature/CSR-297' into feature/CSR-335
This commit is contained in:
commit
9e1dc3db61
4 changed files with 255 additions and 52 deletions
9
src/constants/damage-locations-cms.js
Normal file
9
src/constants/damage-locations-cms.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
const damageLocationsCms = {
|
||||
WINDSHIELD: "WINDSHIELD",
|
||||
SIDEDOOR: "SIDEDOOR",
|
||||
REARWINDOW: "REARWINDOW",
|
||||
DRIVERSIDE: "DRIVERSIDE",
|
||||
PASSENGERSIDE: "PASSENGERSIDE",
|
||||
};
|
||||
|
||||
export { damageLocationsCms };
|
||||
8
src/constants/damage-locations-parts.js
Normal file
8
src/constants/damage-locations-parts.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
const damageLocationsParts = {
|
||||
WINDSHIELD: "Windshield",
|
||||
DRIVER: "Driver",
|
||||
PASSENGER: "Passenger",
|
||||
REAR: "Rear",
|
||||
};
|
||||
|
||||
export { damageLocationsParts };
|
||||
|
|
@ -146,28 +146,6 @@ describe("vehicle-damage.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("Call invalidation, ResetPartsAndDeps should be called", async () => {
|
||||
|
||||
//Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
wrapper.vm.resetDependentState();
|
||||
|
||||
//Assert
|
||||
expect(store.dispatch).toBeCalledWith(storeActions.RESET_PARTS_STATE)
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("BackButtonAction triggers a router.navigate change", async () => {
|
||||
|
||||
|
|
@ -191,8 +169,7 @@ describe("vehicle-damage.vue", () => {
|
|||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("ForwardButtonAction triggers a router.navigate change and saves selections to store", async () => {
|
||||
|
||||
test("Replace several pieces of glass on ForwardButtonAction triggers a router.navigateAfterSave and saves selections to store", async () => {
|
||||
//Arrange
|
||||
const partsData = {
|
||||
partsOrQuestions: [{
|
||||
|
|
@ -238,17 +215,23 @@ describe("vehicle-damage.vue", () => {
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount: null,
|
||||
selectedWindshieldReplaceOptions: ["Single"],
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield", "SideDoor", "RearWindow"];
|
||||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount : null,
|
||||
selectedWindshieldReplaceOptions : ["Single"],
|
||||
selectedWindshieldDamageType: ["Replace"]
|
||||
};
|
||||
|
||||
wrapper.vm.sideDoorOptionsData = {
|
||||
selectedDoorSides: ["DriverSide", "PassengerSide"],
|
||||
selectedDriverSideReplaceOptions: ["Back"],
|
||||
selectedPassengerSideReplaceOptions: ["Quarter"]
|
||||
};
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield"];
|
||||
wrapper.vm.selectedRearReplaceOptions = ["Stationary"];
|
||||
|
||||
const expectedGlassToReplace = [{ location: "Windshield", name: "Single" }];
|
||||
const expectedGlassToReplace = [{location: "Windshield", name: "Single"}, {location: "Driver", name: "Back"},
|
||||
{location: "Passenger", name: "Quarter"}, {location: "Rear", name: "Stationary"}];
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
|
|
@ -257,7 +240,7 @@ describe("vehicle-damage.vue", () => {
|
|||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
|
|
@ -268,6 +251,177 @@ describe("vehicle-damage.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("Windshield replace with single part on ForwardButtonAction triggers a router.navigateAfterSave and saves selections to store", async () => {
|
||||
//Arrange
|
||||
const partsData = { partsOrQuestions: [
|
||||
{
|
||||
glassLocation: "Windshield",
|
||||
glassName: "Single",
|
||||
partQuestions: null,
|
||||
parts: [
|
||||
{
|
||||
color: "Green Tint, Green Shade",
|
||||
description: "rain sensor, solar",
|
||||
partNumber: "FW02728GGYN",
|
||||
requiresCapabilityQuestions: false,
|
||||
requiresRecalibration: false
|
||||
}
|
||||
]}]};
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
pageHeaderWidgetHeaderText: "",
|
||||
mountOptionsMockData: {
|
||||
router: { navigateAfterSave: jest.fn(), },
|
||||
actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },],},
|
||||
});
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield"];
|
||||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount : null,
|
||||
selectedWindshieldReplaceOptions : ["Single"],
|
||||
selectedWindshieldDamageType: ["Replace"]
|
||||
};
|
||||
|
||||
const expectedGlassToReplace = [{location: "Windshield", name: "Single"},];
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$router.navigateAfterSave).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);
|
||||
expect(store.commit).toBeCalledWith(storeMutations.UPDATE_PARTS, partsData.partsOrQuestions[0].parts);
|
||||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("Windshield replace with multiple parts on ForwardButtonAction triggers a router.navigateAfterSave and saves selections to store", async () => {
|
||||
//Arrange
|
||||
const partsData = { partsOrQuestions: [
|
||||
{
|
||||
glassLocation: "Windshield",
|
||||
glassName: "Single",
|
||||
partQuestions: null,
|
||||
parts: [
|
||||
{
|
||||
color: "Green Tint, Green Shade",
|
||||
description: "rain sensor, solar",
|
||||
partNumber: "FW02728GGYN",
|
||||
requiresCapabilityQuestions: false,
|
||||
requiresRecalibration: false
|
||||
},
|
||||
{
|
||||
color: "Green Tint, Green Shade",
|
||||
description: "rain sensor, solar, hydrophobic coating",
|
||||
partNumber: "FW02760GGYN",
|
||||
requiresCapabilityQuestions: false,
|
||||
requiresRecalibration: false
|
||||
}
|
||||
]},
|
||||
{
|
||||
glassName: "Stationary",
|
||||
glassLocation: "Rear",
|
||||
parts: [
|
||||
{
|
||||
partNumber: "DB09626GTYN",
|
||||
description: "heated glass, solar, antenna",
|
||||
color: "Green Tint",
|
||||
requiresRecalibration: false,
|
||||
requiresCapabilityQuestions: false,
|
||||
childParts: null
|
||||
},
|
||||
{
|
||||
partNumber: "DB09821GTYN",
|
||||
description: "heated glass, solar, antenna, onstar",
|
||||
color: "Green Tint",
|
||||
requiresRecalibration: false,
|
||||
requiresCapabilityQuestions: false,
|
||||
childParts: null
|
||||
}
|
||||
],
|
||||
"partQuestions": null
|
||||
}
|
||||
]};
|
||||
|
||||
const { wrapper } = setupMocks({
|
||||
pageHeaderWidgetHeaderText: "",
|
||||
mountOptionsMockData: {
|
||||
router: { navigateAfterSave: jest.fn(), },
|
||||
actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },],},
|
||||
});
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield"];
|
||||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount : null,
|
||||
selectedWindshieldReplaceOptions : ["Single"],
|
||||
selectedWindshieldDamageType: ["Replace"]
|
||||
};
|
||||
|
||||
const expectedGlassToReplace = [{location: "Windshield", name: "Single"},];
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$router.navigateAfterSave).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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("Windshield repair on ForwardButtonAction triggers a router.navigateAfterSave and saves selection to store", async () => {
|
||||
//Arrange
|
||||
const partsData = { partsOrQuestions: []};
|
||||
const { wrapper } = setupMocks({
|
||||
pageHeaderWidgetHeaderText: "",
|
||||
mountOptionsMockData: {
|
||||
router: { navigateAfterSave: jest.fn(), },
|
||||
actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: partsData, },],},
|
||||
});
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield"];
|
||||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount : [2],
|
||||
selectedWindshieldDamageType: ["Repair"]
|
||||
};
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
|
||||
expect(store.commit).toBeCalledWith(storeMutations.UPDATE_IS_REPAIR, true);
|
||||
expect(store.commit).toBeCalledWith(storeMutations.UPDATE_NUMBER_OF_CHIPS, 2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("isWindshieldDamageLocation is true when windshield is selected", async () => {
|
||||
|
||||
|
|
@ -347,13 +501,35 @@ describe("vehicle-damage.vue", () => {
|
|||
);
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield"];
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: ["Repair"] };
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: ["Repair"]};
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isWindshieldRepair).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("isWindshieldRepair is false if windshield damage is not selected", async () => {
|
||||
|
||||
//Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "vehicle-damage" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["SideDoor"];
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: ["Repair"]};
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isWindshieldRepair).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("isDriverSideReplace is true if side door driver is selected", async () => {
|
||||
|
||||
|
|
@ -369,7 +545,7 @@ describe("vehicle-damage.vue", () => {
|
|||
);
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Sidedoor"];
|
||||
wrapper.vm.sideDoorOptionsData = { selectedDoorSides: ["DriverSide"] };
|
||||
wrapper.vm.sideDoorOptionsData = { selectedDoorSides: ["DriverSide"]};
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isDriverSideReplace).toEqual(true);
|
||||
|
|
@ -391,7 +567,7 @@ describe("vehicle-damage.vue", () => {
|
|||
);
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Sidedoor"];
|
||||
wrapper.vm.sideDoorOptionsData = { selectedDoorSides: ["PassengerSide"] };
|
||||
wrapper.vm.sideDoorOptionsData = { selectedDoorSides: ["PassengerSide"]};
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isPassengerSideReplace).toEqual(true);
|
||||
|
|
@ -399,7 +575,7 @@ describe("vehicle-damage.vue", () => {
|
|||
});
|
||||
|
||||
describe("vehicle-damage.vue", () => {
|
||||
test("Call invalidation, ResetPartsAndDeps should be called", async () => {
|
||||
test("Call invalidation, ResetPartsAndState should be called", async () => {
|
||||
|
||||
//Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
|
|
|||
|
|
@ -41,12 +41,13 @@ import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/winds
|
|||
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
||||
|
||||
// Supporting files
|
||||
import { routerParameterKeys } from "@/router/router-constants/router-parameter-keys";
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import store from "@/store";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
import { damageLocationsParts } from "@/constants/damage-locations-parts.js";
|
||||
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
||||
|
||||
|
||||
export default {
|
||||
|
|
@ -144,7 +145,7 @@ export default {
|
|||
|
||||
var partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(this.storeActions.GET_PARTS_OR_QUESTIONS,
|
||||
{ carId: store.getters.vehicle.carId, glassArray: this.selectedGlassToReplace()}, false);
|
||||
|
||||
|
||||
this.navigateForward(partsData);
|
||||
},
|
||||
|
||||
|
|
@ -155,14 +156,23 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
//found multiple parts
|
||||
if (partsData.data.partsOrQuestions.some(pq => pq.parts !== null && pq.parts.length > 1)){
|
||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_MULTIPLE_PARTS, this.$route, {}, {}, partsData.data);
|
||||
return;
|
||||
//found multiple parts for a single glass location (Windshield, Driver, Passenger, Rear)
|
||||
if (partsData.data.partsOrQuestions){
|
||||
var multiParts = false;
|
||||
partsData.data.partsOrQuestions.forEach(pq => {
|
||||
if (pq.parts != null && pq.parts.length > 1){
|
||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_MULTIPLE_PARTS, this.$route, {}, {}, partsData.data);
|
||||
multiParts = true;
|
||||
}
|
||||
});
|
||||
if (multiParts) return;
|
||||
}
|
||||
|
||||
//should only be 1 part and no problem questions at this point so save the part to the store
|
||||
store.commit(this.storeMutations.UPDATE_PARTS, partsData.data.partsOrQuestions[0].parts);
|
||||
//if not a repair then there should only be 1 part and no problem questions at this point so save the part to the store.
|
||||
if (!this.isWindshieldRepair){
|
||||
store.commit(this.storeMutations.UPDATE_PARTS, partsData.data.partsOrQuestions[0].parts);
|
||||
}
|
||||
|
||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART, this.$route);
|
||||
},
|
||||
|
||||
|
|
@ -170,25 +180,25 @@ export default {
|
|||
var selectedGlassToReplace = [];
|
||||
if (this.isWindshieldDamageLocation && !this.isWindshieldRepair){
|
||||
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach(wsItem => {
|
||||
selectedGlassToReplace.push({ location: "Windshield", name: wsItem});
|
||||
selectedGlassToReplace.push({ location: damageLocationsParts.WINDSHIELD, name: wsItem});
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isDriverSideReplace){
|
||||
this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach(driverItem => {
|
||||
selectedGlassToReplace.push({ location: "Driver", name: driverItem});
|
||||
selectedGlassToReplace.push({ location: damageLocationsParts.DRIVER, name: driverItem});
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isPassengerSideReplace){
|
||||
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach(passengerItem => {
|
||||
selectedGlassToReplace.push({ location: "Passenger", name: passengerItem});
|
||||
selectedGlassToReplace.push({ location: damageLocationsParts.PASSENGER, name: passengerItem});
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isRearWindowDamageLocation) {
|
||||
this.selectedRearReplaceOptions.forEach(rearItem => {
|
||||
selectedGlassToReplace.push({ location: "Rear", name: rearItem});
|
||||
selectedGlassToReplace.push({ location: damageLocationsParts.REAR, name: rearItem});
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -199,19 +209,19 @@ export default {
|
|||
isWindshieldDamageLocation() {
|
||||
return this.selectedDamageLocations.some(selectedDamages =>
|
||||
{
|
||||
return selectedDamages.toUpperCase() === "WINDSHIELD";
|
||||
return selectedDamages.toUpperCase() === damageLocationsCms.WINDSHIELD;
|
||||
});
|
||||
},
|
||||
isSideDoorDamageLocation() {
|
||||
return this.selectedDamageLocations.some(selectedDamages =>
|
||||
{
|
||||
return selectedDamages.toUpperCase() === "SIDEDOOR";
|
||||
return selectedDamages.toUpperCase() === damageLocationsCms.SIDEDOOR;
|
||||
});
|
||||
},
|
||||
isRearWindowDamageLocation() {
|
||||
return this.selectedDamageLocations.some(selectedDamages =>
|
||||
{
|
||||
return selectedDamages.toUpperCase() === "REARWINDOW";
|
||||
return selectedDamages.toUpperCase() === damageLocationsCms.REARWINDOW;
|
||||
});
|
||||
},
|
||||
isWindshieldRepair() {
|
||||
|
|
@ -227,7 +237,7 @@ export default {
|
|||
|
||||
return this.sideDoorOptionsData.selectedDoorSides.some(selectedDriverSide =>
|
||||
{
|
||||
return selectedDriverSide.toUpperCase() === "DRIVERSIDE";
|
||||
return selectedDriverSide.toUpperCase() === damageLocationsCms.DRIVERSIDE;
|
||||
});
|
||||
},
|
||||
isPassengerSideReplace() {
|
||||
|
|
@ -235,7 +245,7 @@ export default {
|
|||
|
||||
return this.sideDoorOptionsData.selectedDoorSides.some(selectedPassengerSide =>
|
||||
{
|
||||
return selectedPassengerSide.toUpperCase() === "PASSENGERSIDE";
|
||||
return selectedPassengerSide.toUpperCase() === damageLocationsCms.PASSENGERSIDE;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue