+
@@ -131,7 +130,7 @@ export default {
name: "estimate",
data() {
return {
- selectedVinLookupMethod: "",
+ selectedVinLookupMethod: null,
serviceZipCode: this.getZipFromStore(),
emailAddress: this.getEmailFromStore(),
displayInvalidZipAlert: false,
diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js
index 8bdace584..aa6ecb06d 100644
--- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js
+++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js
@@ -36,7 +36,7 @@ describe("replace-options-question.vue", () => {
});
describe("replace-options-question.vue", () => {
- test("when updateSelectedValues method is called with a single answerToDisplay it will call to update this.selectedValues", async () => {
+ test("when updateSelectedValues method is called with a single answerToDisplay it will call to update this.selectedReplaceOptions", async () => {
//Arrange
const { wrapper, cmsContent, replaceOptions
diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue
index bb164f1bc..503c30cb8 100644
--- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue
+++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue
@@ -11,7 +11,7 @@
v-model="selectedValues"
:validationRules="validationRules"
:suppressError="suppressError"
- :isRequired=isRequired
+ :isRequired="isRequired"
/>
@@ -25,14 +25,14 @@ export default ({
name: "replaceOptionsQuestion",
data(){
return {
- replaceOptions: [],
+ replaceOptions: this.isMultiSelect ? [] : "",
}
},
props: {
isAvailable: Boolean,
filterByVehicleCategory: Boolean,
groupName: String,
- modelValue: Array,
+ modelValue: [Array, String, Number],
isMultiSelect: Boolean,
validationRules: String,
suppressError: Boolean,
@@ -46,7 +46,7 @@ export default ({
updateSelectedValues() {
// UPDATE SELECTEDVALUES IF ONLY ONE ANSWER
if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1) {
- this.selectedValues = [this.answersToDisplay[0].Name];
+ this.selectedValues = this.isMultiSelect ? [this.answersToDisplay[0].Name] : this.answersToDisplay[0].Name;
}
},
},
@@ -91,7 +91,7 @@ export default ({
},
shouldDisplayReplaceOptionsQuestion(shouldDisplayReplaceOptionsQuestion) {
if (!shouldDisplayReplaceOptionsQuestion) {
- this.selectedValues = [];
+ this.selectedValues = this.isMultiSelect ? [] : "";
}
}
},
diff --git a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue
index c1c9ba3b3..99f644d6f 100644
--- a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue
+++ b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue
@@ -57,7 +57,7 @@ export default ({
name: "sideDoorOptions",
props: {
groupName: String,
- modelValue: Array,
+ modelValue: Object,
selectedDamageLocations: Array,
cmsWidgetName: String,
},
diff --git a/src/layouts/vehicle-damage/vehicle-damage.spec.js b/src/layouts/vehicle-damage/vehicle-damage.spec.js
index 27778feed..cc6d9011f 100644
--- a/src/layouts/vehicle-damage/vehicle-damage.spec.js
+++ b/src/layouts/vehicle-damage/vehicle-damage.spec.js
@@ -129,20 +129,20 @@ describe("vehicle-damage.vue", () => {
},
});
- 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.selectedRearReplaceOptions = ["Stationary"];
+ wrapper.setData({
+ selectedDamageLocations: ["Windshield", "SideDoor", "RearWindow"],
+ selectedWindshieldOptions: {
+ selectedWindshieldChipCount: null,
+ selectedWindshieldReplaceOptions: ["Single"],
+ selectedWindshieldDamageType: "Replace"
+ },
+ sideDoorOptionsData: {
+ selectedDoorSides: ["DriverSide", "PassengerSide"],
+ selectedDriverSideReplaceOptions: ["Back"],
+ selectedPassengerSideReplaceOptions: ["Quarter"]
+ },
+ selectedRearReplaceOptions: "Stationary",
+ })
const expectedGlassToReplace = [{ location: "Windshield", name: "Single" }, { location: "Driver", name: "Back" },
{ location: "Passenger", name: "Quarter" }, { location: "Rear", name: "Stationary" }];
@@ -519,19 +519,19 @@ describe("vehicle-damage.vue", () => {
const storeWindshieldOptions = [[1, false, "Windshield", "Single", {
selectedWindshieldDamageType: damageLocationsSelected.REPLACE,
- selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: [damageLocationsSelected.SINGLE]
+ selectedWindshieldChipCount: null, selectedWindshieldReplaceOptions: [damageLocationsSelected.SINGLE]
}],
[2, false, "Windshield", "Driver", {
selectedWindshieldDamageType: damageLocationsSelected.REPLACE,
- selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: [damageLocationsSelected.DRIVER]
+ selectedWindshieldChipCount: null, selectedWindshieldReplaceOptions: [damageLocationsSelected.DRIVER]
}],
[3, false, "Windshield", "Passenger", {
selectedWindshieldDamageType: damageLocationsSelected.REPLACE,
- selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: [damageLocationsSelected.PASSENGER]
+ selectedWindshieldChipCount: null, selectedWindshieldReplaceOptions: [damageLocationsSelected.PASSENGER]
}],
[4, true, "", "", {
selectedWindshieldDamageType: damageLocationsSelected.REPAIR,
- selectedWindshieldChipCount: [2], selectedWindshieldReplaceOptions: []
+ selectedWindshieldChipCount: 2, selectedWindshieldReplaceOptions: []
}]
];
test.each(storeWindshieldOptions)("getWindshieldOptionsFromStore test #%s", async (testNum, isRepair, damageLocation, damageName, expectedWindshieldOptions) => {
@@ -618,8 +618,8 @@ describe("vehicle-damage.vue", () => {
expect(glassSelections).toEqual(expectedGlass);
});
- const rearReplaceOptions = [["Rear", "Stationary", [damageLocationsSelected.STATIONARY]],
- ["Rear", "Slider", [damageLocationsSelected.SLIDER]]
+ const rearReplaceOptions = [["Rear", "Stationary", damageLocationsSelected.STATIONARY],
+ ["Rear", "Slider", damageLocationsSelected.SLIDER]
];
test.each(rearReplaceOptions)("getRearReplaceOptionsFromStore for %s-%s returns expected %s", async (damageLocation, damageName, expectedGlass) => {
diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue
index f729b8b1a..86435e8e4 100644
--- a/src/layouts/vehicle-damage/vehicle-damage.vue
+++ b/src/layouts/vehicle-damage/vehicle-damage.vue
@@ -196,11 +196,15 @@ export default {
},
getWindshieldOptionsFromStore() {
- var windShieldOptions = { selectedWindshieldDamageType: "", selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: []};
+ var windShieldOptions = { selectedWindshieldDamageType: "", selectedWindshieldChipCount: null, selectedWindshieldReplaceOptions: []};
if (store.getters.damage.isRepair === undefined) return windshieldOptions;
- if (!store.getters.damage.isRepair) {
+ if (store.getters.damage.isRepair) {
+ windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
+ windShieldOptions.selectedWindshieldChipCount = store.getters.damage.numberOfChips;
+ }
+ else {
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
glass.name === damageLocationsSelected.SINGLE })) {
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
@@ -220,13 +224,7 @@ export default {
}
}
- if (store.getters.damage.isRepair) {
- windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
- windShieldOptions.selectedWindshieldChipCount.push(store.getters.damage.numberOfChips);
- }
-
return windShieldOptions;
-
},
getDoorSidesFromStore() {
@@ -265,15 +263,9 @@ export default {
return passengerSideReplaceOptions;
},
-
- getRearReplaceOptionsFromStore(){
- var rearReplaceOptions = [];
-
- store.getters.damage.glassToReplace?.forEach(glass => {
- if (glass.location === damageLocationsSelected.REAR){
- rearReplaceOptions.push(glass.name);
- }
- });
+
+ getRearReplaceOptionsFromStore() {
+ var rearReplaceOptions = store.getters.damage.glassToReplace?.filter(glass => glass.location === damageLocationsSelected.REAR)[0]?.name;
return rearReplaceOptions;
},
@@ -290,7 +282,6 @@ export default {
},
navigateForward(){
-
// If vin already exists, navigate directly to vin-lookup
if(store.getters.vehicle.vin) {
this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, this.$route);
@@ -321,9 +312,7 @@ export default {
}
if (this.isRearWindowDamageLocation) {
- this.selectedRearReplaceOptions.forEach(rearItem => {
- selectedGlassToReplace.push({ location: damageLocationsSelected.REAR, name: rearItem});
- })
+ selectedGlassToReplace.push({ location: damageLocationsSelected.REAR, name: this.selectedRearReplaceOptions});
}
return selectedGlassToReplace;
@@ -373,15 +362,15 @@ export default {
hasSplitSingleConflict() {
if (!this.selectedDamageLocations?.includes("Windshield") || this.selectedWindshieldOptions.selectedWindshieldDamageType === damageLocationsSelected.REPAIR || !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions) return false;
- return this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.some(selectedSingleWindshield =>
+ return this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(selectedSingleWindshield =>
{
return selectedSingleWindshield.toUpperCase() === damageLocationsSelected.SINGLE.toUpperCase();
}) &&
- (this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.some(selectedDriverWindshield =>
+ (this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(selectedDriverWindshield =>
{
return selectedDriverWindshield.toUpperCase() === damageLocationsSelected.DRIVER.toUpperCase();
}) ||
- this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.some(selectedPassengerWindshield =>
+ this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(selectedPassengerWindshield =>
{
return selectedPassengerWindshield.toUpperCase() === damageLocationsSelected.PASSENGER.toUpperCase();
})
diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js
index c05d97d2f..902e0808a 100644
--- a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js
+++ b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.spec.js
@@ -1,78 +1,81 @@
import { shallowMount } from "@vue/test-utils";
import windshieldChipCountQuestion from "@/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
-import { nextTick } from "vue";
import store from "@/store";
-jest.mock("@/store", () => { return {}; }, {virtual: true});
+jest.mock(
+ "@/store",
+ () => {
+ return {};
+ },
+ { virtual: true }
+);
describe("windshield-chip-count-question.vue", () => {
test("Selected chip count is emitted upon selection.", async () => {
- //Arrange
- const { wrapper } = setupMocks({modelValueProp: ["One"]});
-
- //Act
- wrapper.setValue({ modelValue: ["Two"] });
- await wrapper.vm.$nextTick();
-
- //Assert
- expect(wrapper.vm.selectedChipCountValues).toEqual(["One"]);
- expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Two"] }]);
+ //Arrange
+ const { wrapper } = setupMocks({ modelValueProp: 1 });
+
+ //Act
+ wrapper.vm.selectedValue = "2";
+
+ //Assert
+ expect(wrapper.emitted()["update:modelValue"][0]).toEqual([2]);
});
- });
- describe("Windshield-chip-count-question.vue", () => {
- test("Should display question and answers from api.", async () => {
- //Arrange
- const { wrapper } = setupMocks({modelValueProp: ["One"]});
+ test("selectedValue matches modelValue", () => {
+ // Arrange/Act
+ const { wrapper } = setupMocks({ modelValueProp: 2 });
- //Act
- wrapper.setProps({isAvailable: true});
- wrapper.vm.updateSelectedValues = jest.fn();
- await wrapper.vm.$nextTick();
+ // Assert
+ expect(wrapper.vm.selectedValue).toBe(2);
+ });
+});
- //Assert
- expect(wrapper.vm.updateSelectedValues).toBeCalled();
- });
- });
-
- function setupMocks({
+function setupMocks({
modelValueProp = ["Two"],
groupName = "WindshieldChipCountQuestion",
cmsQuestionText = "How many chips are we repairing?",
- cmsAnswers = [{Name: "One"}, {Name: "Two"}, {Name: "Three"}],
+ cmsAnswers = [{ Name: "One" }, { Name: "Two" }, { Name: "Three" }],
dataFromStoreApi = [],
- }) {
-
+}) {
//Mock store
store.dispatch = jest.fn(() => dataFromStoreApi);
- store.getters = { vehicle: {year: 2019, make: 'honda', model: 'civc', style: '2 Door', category: 'CAR'} };
+ store.getters = {
+ vehicle: {
+ year: 2019,
+ make: "honda",
+ model: "civc",
+ style: "2 Door",
+ category: "CAR",
+ },
+ };
const mountOptions = getMountOptions({
- store: {
- dispatch: store.dispatch,
- getters: store.getters,
- },
+ store: {
+ dispatch: store.dispatch,
+ getters: store.getters,
+ },
});
-
+
//Mock props
const mockMixin = {
- methods: {
- getCmsContent: jest.fn()
- }
- }
+ methods: {
+ getCmsContent: jest.fn(),
+ },
+ };
mountOptions.propsData = {
- modelValue: modelValueProp
+ modelValue: modelValueProp,
};
mountOptions.mixins = [mockMixin];
-
+
const wrapper = shallowMount(windshieldChipCountQuestion, mountOptions);
-
+
//Mock CMS content
const cmsContent = {
- groupName: groupName,
- QuestionText: cmsQuestionText,
- Answers: cmsAnswers,
+ groupName: groupName,
+ QuestionText: cmsQuestionText,
+ Answers: cmsAnswers,
};
const damageOptions = dataFromStoreApi;
return { wrapper, cmsContent, damageOptions };
- }
\ No newline at end of file
+}
diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue
index 31a681857..fc26c1d8c 100644
--- a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue
+++ b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue
@@ -7,7 +7,7 @@
:groupName="groupName"
buttonType="listButtonHorizontal"
useTextForValue
- v-model="selectedChipCountValues"
+ v-model="selectedValue"
:validationRules="validationRules"
isRequired
/>
@@ -21,20 +21,12 @@ import buttonQuestion from "@/common-components/button-question/button-question"
export default ({
name: "windshieldOptions",
props: {
- modelValue: Array,
+ modelValue: [String, Number],
groupName: String,
isAvailable: Boolean,
validationRules: String,
cmsWidgetName: String,
},
- methods: {
- updateSelectedValues() {
- // UPDATE SELECTEDVALUES IF ONLY ONE ANSWER
- if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1 && this.selectedValues) {
- this.selectedValues = [this.answersToDisplay[0].Name];
- }
- },
- },
computed: {
questionText(){
return this.getCmsContent(this.cmsWidgetName, 'QuestionText');
@@ -42,7 +34,7 @@ export default ({
answersFromCms(){
return this.getCmsContent(this.cmsWidgetName, 'Answers');
},
- selectedChipCountValues: {
+ selectedValue: {
get: function() {
return this.modelValue;
},
@@ -52,12 +44,6 @@ export default ({
}
},
},
- watch: {
- isAvailable(val) {
- // CHECK TO UPDATE SELECTED VALUES WHEN ISAVAILABLE IS TRUE
- val && this.updateSelectedValues();
- }
- },
components: {
buttonQuestion,
}
diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js b/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js
index da19f5308..4b247d705 100644
--- a/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js
+++ b/src/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question.spec.js
@@ -6,22 +6,22 @@ import store from "@/store";
jest.mock("@/store", () => { return {}; }, {virtual: true});
describe("windshield-damage-type-question.vue", () => {
- test("Selected chip count is emitted upon selection.", async () => {
+ test("Selected windshield damage is emitted upon selection.", async () => {
//Arrange
- const { wrapper } = setupMocks({modelValueProp: ["Repair"]});
+ const { wrapper } = setupMocks({modelValueProp: "Repair"});
//Act
- wrapper.setValue({ modelValue: ["Replace"] });
+ wrapper.setValue({ modelValue: "Replace" });
await wrapper.vm.$nextTick();
//Assert
- expect(wrapper.vm.selectedValues).toEqual(["Repair"]);
- expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Replace"] }]);
+ expect(wrapper.vm.selectedValues).toEqual("Repair");
+ expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: "Replace" }]);
});
});
function setupMocks({
- modelValueProp = ["Two"],
+ modelValueProp = "",
groupName = "WindshieldDamageTypeQuestion",
cmsQuestionText = "What's your windshield damage?",
cmsAnswers = [{Name: "Repair"}, {Name: "Replace"}],
diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue
index e3524e3f0..8081bb2b2 100644
--- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue
+++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue
@@ -57,8 +57,8 @@ defineRule("windshield-replace-options-required", required(errorMessages.WINSHIE
defineRule("check-for-repair-and-replace", (selectedWindshieldDamageType, selectedDamageLocations) => {
return selectedWindshieldDamageType.toString() != damageLocationsSelected.REPAIR ||
- !selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) ||
- selectedDamageLocations.length === 1;
+ (!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) && !selectedDamageLocations[0]?.includes(damageLocationsSelected.WINDSHIELD)) ||
+ (selectedDamageLocations[0].length === 1);
});
defineRule("repair-only", (value) => {
return value.toString() === damageLocationsSelected.REPAIR;
@@ -83,7 +83,7 @@ export default ({
},
props: {
- modelValue: String,
+ modelValue: Object,
selectedDamageLocations: Array,
hasRepairReplaceConflict: Boolean,
hasSplitSingleConflict: Boolean,
@@ -114,7 +114,7 @@ export default ({
},
selectedWindshieldDamageTypeValue: {
get: function() {
- return this.selectedValues.selectedWindshieldDamageType;
+ return this.selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) ? this.selectedValues.selectedWindshieldDamageType : null;
},
set: function(newValue) {
this.selectedValues = this.getWindshieldOptions(newValue, null, null);
diff --git a/src/layouts/vehicle-make/make-question/make-question.vue b/src/layouts/vehicle-make/make-question/make-question.vue
index d0046fe30..28246814f 100644
--- a/src/layouts/vehicle-make/make-question/make-question.vue
+++ b/src/layouts/vehicle-make/make-question/make-question.vue
@@ -23,7 +23,7 @@ export default {
name: "make-question",
data() {
return {
- makes: Array,
+ makes: [],
};
},
props: {
diff --git a/src/layouts/vehicle-make/vehicle-make.spec.js b/src/layouts/vehicle-make/vehicle-make.spec.js
index c5ec3cba9..c533516ce 100644
--- a/src/layouts/vehicle-make/vehicle-make.spec.js
+++ b/src/layouts/vehicle-make/vehicle-make.spec.js
@@ -5,150 +5,224 @@ import { settleAllPromises } from "@/helpers/layout-helper.js";
import { nextTick } from "vue";
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import baseMixin from "@/mixins/base-mixin.js";
+import store from "@/store";
// Components
import vehicleMake from "@/layouts/vehicle-make/vehicle-make.vue";
import makeQuestion from "@/layouts/vehicle-make/make-question/make-question";
jest.mock("@/store", () => ({
- commit: jest.fn(),
- dispatch: jest.fn(),
- getters: {
- vehicle: {
- year: 2019,
- },
- },
+ commit: jest.fn(),
+ dispatch: jest.fn(),
+ // getters: jest.fn().mockImplementation(() => ({
+ // vehicle: {
+ // year: 2019,
+ // },
+ // })),
}));
// Mock fetchCmsContentForPage
jest.mock("@/helpers/cms-content-helper", () => ({
- fetchCmsContentForPage: jest.fn(),
+ fetchCmsContentForPage: jest.fn(),
}));
// Mock our module for promises.
jest.mock("@/helpers/layout-helper.js", () => ({
- settleAllPromises: jest.fn(),
+ settleAllPromises: jest.fn(),
}));
-
describe("vehicle-make.vue", () => {
- test("Make question component is initized with api data", async (done) => {
- //Arrange
- const makeQuestionInitialData = ["honda", "ford", "dodge"];
- const { wrapper, apiPromise } = setupMocks({
- makeQuestionInitialData: makeQuestionInitialData,
- });
+ test("Make question component is initized with api data", async (done) => {
+ //Arrange
+ const makeQuestionInitialData = ["honda", "ford", "dodge"];
+ const { wrapper, apiPromise } = setupMocks({
+ makeQuestionInitialData: makeQuestionInitialData,
+ });
- //Act
- vehicleMake.beforeRouteEnter.call(
- wrapper.vm,
- { query: { fmgPage: "vehicle-make" } },
- undefined,
- (c) => c(wrapper.vm)
- );
+ //Act
+ vehicleMake.beforeRouteEnter.call(
+ wrapper.vm,
+ { query: { fmgPage: "vehicle-make" } },
+ undefined,
+ (c) => c(wrapper.vm)
+ );
- //Assert
- apiPromise.finally(() => {
- expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith(
- makeQuestionInitialData
- );
- done();
+ //Assert
+ apiPromise.finally(() => {
+ expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith(
+ makeQuestionInitialData
+ );
+ done();
+ });
});
- });
});
describe("vehicle-make.vue", () => {
- test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => {
- //Arrange
- const { wrapper, apiPromise } = setupMocks({
- pageHeaderWidgetHeaderText: "Select a make to get started",
- mountOptionsMockData: {
- router: {
- navigate: jest.fn(),
- navigateWithoutSaving: jest.fn(),
- },
- },
- });
+ test("BackButtonAction triggers a router.navigateWithoutSaving change", async (done) => {
+ //Arrange
+ const { wrapper, apiPromise } = setupMocks({
+ pageHeaderWidgetHeaderText: "Select a make to get started",
+ mountOptionsMockData: {
+ router: {
+ navigate: jest.fn(),
+ navigateWithoutSaving: jest.fn(),
+ },
+ },
+ });
- //Act
- vehicleMake.beforeRouteEnter.call(
- wrapper.vm,
- { query: { fmgPage: "vehicle-make" } },
- undefined,
- (c) => c(wrapper.vm)
- );
- wrapper.vm.backButtonAction();
- await nextTick();
+ //Act
+ vehicleMake.beforeRouteEnter.call(
+ wrapper.vm,
+ { query: { fmgPage: "vehicle-make" } },
+ undefined,
+ (c) => c(wrapper.vm)
+ );
+ wrapper.vm.backButtonAction();
+ await nextTick();
- //Assert
- apiPromise.finally(() => {
- expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
- done();
+ //Assert
+ apiPromise.finally(() => {
+ expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
+ done();
+ });
});
- });
});
describe("vehicle-make.vue", () => {
- test("Year set, arePagePrerequisitesValid should be true ", async () => {
- //Arrange
- const { wrapper } = setupMocks({});
+ describe("arePagePrerequisitesValue", () => {
+ test("Year set, arePagePrerequisitesValid should be true", async () => {
+ //Arrange
+ const { wrapper } = setupMocks({
+ vehicleData: {
+ year: 2019
+ }
+ });
- //Act
- vehicleMake.beforeRouteEnter.call(
- wrapper.vm,
- { query: { fmgPage: "vehicle-make" } },
- undefined,
- (c) => c(wrapper.vm)
- );
+ //Act
+ vehicleMake.beforeRouteEnter.call(
+ wrapper.vm,
+ { query: { fmgPage: "vehicle-make" } },
+ undefined,
+ (c) => c(wrapper.vm)
+ );
- let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
+ let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
- //Assert
- expect(arePagePrerequisitesValid).toBe(true);
- });
+ //Assert
+ expect(arePagePrerequisitesValid).toBe(true);
+ });
+
+ test("Year not set, arePagePrerequisitesValid should be false", async () => {
+ //Arrange
+ store.getters.vehicle.year = jest.fn().mockReturnValueOnce(undefined);
+ const { wrapper } = setupMocks({});
+
+ //Act
+ let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
+
+ //Assert
+ expect(arePagePrerequisitesValid).toBe(false);
+ });
+ });
+
+ test("selectedMake changes => save make in store", async () => {
+ //Arrange
+ const { wrapper } = setupMocks({
+ mountOptionsMockData: {
+ router: {
+ navigate: jest.fn(),
+ navigateWithSaving: jest.fn(),
+ },
+ }
+ });
+
+ // Act
+ await wrapper.setData({
+ selectedMake: "Make",
+ });
+ await wrapper.vm.$nextTick();
+
+ // Assert
+ expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledTimes(1);
+ expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith(
+ "saveVehicleMake",
+ "Make",
+ false
+ );
+ });
+
+ test("selectedMake changes => navigate with saving", async () => {
+ //Arrange
+ const { wrapper } = setupMocks({
+ mountOptionsMockData: {
+ router: {
+ navigate: jest.fn(),
+ navigateWithSaving: jest.fn(),
+ },
+ route: {
+ fmgPage: "test",
+ },
+ },
+ });
+
+ // Act
+ await wrapper.setData({
+ selectedMake: "Make",
+ });
+
+ // Assert
+ expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1);
+ expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(
+ "SELECTED_MAKE",
+ expect.anything()
+ );
+ });
});
-
function setupMocks({
- vehicleMakeQuestionCmsContent = {},
- makeQuestionInitialData = {},
- pageHeaderWidgetHeaderText = {},
- mountOptionsMockData = {},
+ vehicleMakeQuestionCmsContent = {},
+ makeQuestionInitialData = {},
+ pageHeaderWidgetHeaderText = {},
+ mountOptionsMockData = {},
+ vehicleData = {}
}) {
- //Mock api responses
- const apiResponses = {
- cmsContent: {
- FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
- VehicleMakeQuestion: vehicleMakeQuestionCmsContent,
- VehicleBannerWidget: {
- GenericVehicleImage:
- "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
- },
- FunnelHeaderWidget: {
- LogoImage:
- "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3",
- },
- },
- makeQuestionInitialData: makeQuestionInitialData,
- };
+ //Mock api responses
+ const apiResponses = {
+ cmsContent: {
+ FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
+ VehicleMakeQuestion: vehicleMakeQuestionCmsContent,
+ VehicleBannerWidget: {
+ GenericVehicleImage:
+ "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
+ },
+ FunnelHeaderWidget: {
+ LogoImage:
+ "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3",
+ },
+ },
+ makeQuestionInitialData: makeQuestionInitialData,
+ };
- const apiPromise = Promise.resolve(apiResponses);
+ const apiPromise = Promise.resolve(apiResponses);
- fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
- settleAllPromises.mockImplementation(() => apiPromise);
+ store.getters = {
+ vehicle: vehicleData
+ }
- //Mock make question methods
- makeQuestion.methods = {
- loadInitialData: jest.fn(),
- initializeComponent: jest.fn(),
- };
+ fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
+ settleAllPromises.mockImplementation(() => apiPromise);
- const mountOptions = getMountOptions(mountOptionsMockData);
- const wrapper = shallowMount(vehicleMake, mountOptions);
- const makeQuestionWrapper = wrapper.findComponent({ name: "makeQuestion" });
- makeQuestionWrapper.vm.initializeComponent =
- makeQuestion.methods.initializeComponent;
+ //Mock make question methods
+ makeQuestion.methods = {
+ loadInitialData: jest.fn(),
+ initializeComponent: jest.fn(),
+ };
+
+ const mountOptions = getMountOptions(mountOptionsMockData);
+ const wrapper = shallowMount(vehicleMake, mountOptions);
+ const makeQuestionWrapper = wrapper.findComponent({ name: "makeQuestion" });
+ makeQuestionWrapper.vm.initializeComponent = makeQuestion.methods.initializeComponent;
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
- return { wrapper, apiPromise };
+ return { wrapper, apiPromise };
}
diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue
index f5a42eefe..2bd49498f 100644
--- a/src/layouts/vehicle-make/vehicle-make.vue
+++ b/src/layouts/vehicle-make/vehicle-make.vue
@@ -3,14 +3,21 @@
@@ -26,7 +33,6 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
// Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
-import { storeMutations } from "@/constants/store-mutations";
import { storeActions } from "@/constants/store-actions";
import store from "@/store";
@@ -75,7 +81,7 @@ export default {
);
},
arePagePrerequisitesValid() {
- if (store.getters.vehicle.year){
+ if (store.getters.vehicle.year) {
return true;
}
return false;
@@ -84,7 +90,7 @@ export default {
watch: {
selectedMake(make) {
- this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MAKE, make, false);
+ this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MAKE, make, false);
this.$router.navigateWithSaving(
this.navigationScenarios.SELECTED_MAKE,
this.$route
diff --git a/src/layouts/vehicle-model/model-question/model-question.vue b/src/layouts/vehicle-model/model-question/model-question.vue
index 096f4d70c..bc20bdc6a 100644
--- a/src/layouts/vehicle-model/model-question/model-question.vue
+++ b/src/layouts/vehicle-model/model-question/model-question.vue
@@ -23,7 +23,7 @@ export default {
name: "model-question",
data() {
return {
- models: Array,
+ models: [],
};
},
props: {
diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js
index 2acf1d87d..c4b2bbd22 100644
--- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js
+++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js
@@ -19,7 +19,6 @@ const featureListData = {
}
describe("glass-part-question.vue", () => {
-
test("Part data passed in, should map data for ButtonQuestion (radio type)", async () => {
//Arrange
diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue
index 8154f2ca4..79d9d147d 100644
--- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue
+++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue
@@ -13,9 +13,7 @@
altText=""
isRequired
:groupName="`${location}-${name}`"
- @isCheckedChanged="ResetTintAndPartSelections"
- :validationRules="tintValidationRules"
- >
+ :validationRules="tintValidationRules">
@@ -64,7 +62,10 @@ export default {
location: String,
colorAnswers: Array,
modelValue: Object,
- alreadyPopulatedPartsData: Array
+ alreadyPopulatedPartsData: {
+ type: Array,
+ default: () => [],
+ },
},
mounted() {
this.LoadPreselectedValues();
@@ -75,12 +76,21 @@ export default {
computed: {
tintValidationRules() {
const validationRuleName = `${this.location}-${this.name}-tint-required`;
- defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED));
+
+ defineRule(
+ validationRuleName,
+ required(errorMessages.OPTION_REQUIRED)
+ );
+
return validationRuleName;
},
partValidationRules() {
const validationRuleName = `${this.location}-${this.name}-part-required`;
- defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED));
+
+ defineRule(
+ validationRuleName,
+ required(errorMessages.OPTION_REQUIRED)
+ );
return validationRuleName;
},
colorQuestionText() {
@@ -95,9 +105,9 @@ export default {
Object.keys(this.featureListData).forEach((tintOption) => {
tintOptions.push({
- Name: tintOption,
- Text: tintOption,
- AnswerImageUrl: require(`@/assets/img/tints/${this.getTintSourceImage(
+ value: tintOption,
+ buttonLabel: tintOption,
+ buttonImage: require(`@/assets/img/tints/${this.getTintSourceImage(
this.location,
tintOption
)}`),
@@ -112,16 +122,29 @@ export default {
return this.modelValue?.partNumber;
},
set(newValue) {
- this.$emit("update:modelValue", this.partsForSelectedTint.filter(part => part.partNumber == newValue)[0]);
+ this.$emit(
+ "update:modelValue",
+ this.partsForSelectedTint.filter(
+ (part) => part.partNumber == newValue
+ )[0]
+ );
},
},
partsForSelectedTint() {
- const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(dataForlocationAndName =>
- dataForlocationAndName.name == this.name &&
- dataForlocationAndName.location == this.location);
- const matchingGlassParts = matchingGlass?.length == 1 ? matchingGlass[0].parts : [];
- return matchingGlassParts.filter(part => part.color == this.selectedTint) ?? [];
+ const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(
+ (dataForGlassLocationAndName) =>
+ dataForGlassLocationAndName.name == this.name &&
+ dataForGlassLocationAndName.location ==
+ this.location
+ );
+ const matchingGlassParts =
+ matchingGlass?.length == 1 ? matchingGlass[0].parts : [];
+ return (
+ matchingGlassParts.filter(
+ (part) => part.color == this.selectedTint
+ ) ?? []
+ );
},
// Creates a map of the feature list data in the correct Name/Value
@@ -153,7 +176,9 @@ export default {
},
PartDataFromApi() {
- return this.$store.getters.pageData(this.$route.query.fmgPage) ?? {};
+ return (
+ this.$store.getters.pageData(this.$route.query.fmgPage) ?? {}
+ );
},
},
methods: {
@@ -190,7 +215,8 @@ export default {
// Check if only a single part is present for the tint and set the v-model if it is.
AutoSelectIfSinglePart() {
if (this.partsForSelectedTint?.length == 1) {
- this.selectedPartNumber = this.partsForSelectedTint[0].partNumber;
+ this.selectedPartNumber =
+ this.partsForSelectedTint[0].partNumber;
}
},
@@ -199,7 +225,7 @@ export default {
this.$nextTick(() => {
if (this.modelValue !== undefined) {
// Populate button-question model-value if parts data already exists in VueX
- this.selectedTint = this.alreadyPopulatedPartsData?.filter(part => part.partNumber === this.selectedPartNumber)[0]?.color;
+ this.selectedTint = this.modelValue?.color
}
});
},
@@ -207,8 +233,8 @@ export default {
watch: {
selectedTint() {
this.AutoSelectIfSinglePart();
- }
- }
+ },
+ },
};
diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js
index 3f54b300c..c736701da 100644
--- a/src/layouts/vehicle-parts/vehicle-parts.spec.js
+++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js
@@ -183,7 +183,16 @@ describe("vehicle-parts.vue", () => {
await nextTick();
//Assert
- expect(wrapper.vm.selectedGlassParts).toEqual({ "Rear-Stationary": { "Rear": ['DB12209YPYNOEM'] } });
+ expect(wrapper.vm.selectedGlassParts).toEqual({
+ "Rear-Stationary": {
+ partNumber: "DB12209YPYNOEM",
+ description: "heated glass, solar, 1 hole",
+ color: "Gray Tint Privacy",
+ requiresRecalibration: false,
+ requiresCapabilityQuestions: false,
+ childParts: null
+ }
+ });
});
test("User had part questions > BackButtonAction triggers a router.navigateWithoutSaving change with correct scenario", async () => {
@@ -509,6 +518,8 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {}
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
+ // wrapper.vm.$refs.onSubmit = jest.fn();
+ // wrapper.vm.$refs.onInvalidSubmit = jest.fn();
return { wrapper, apiPromise };
}
diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue
index 2c4583685..56c1b9da0 100644
--- a/src/layouts/vehicle-parts/vehicle-parts.vue
+++ b/src/layouts/vehicle-parts/vehicle-parts.vue
@@ -1,52 +1,45 @@
-