+
@@ -177,7 +177,7 @@ export default {
}
// Save parts to the store.
- store.commit(storeMutations.UPDATE_PARTS, matchedParts);
+ store.commit(storeMutations.UPDATE_GLASS_PARTS, matchedParts);
// Navigate to the next page.
this.$router.navigateAfterSave(
diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js
index 1c580f4a6..e782f345e 100644
--- a/src/layouts/vin-lookup/vin-lookup.spec.js
+++ b/src/layouts/vin-lookup/vin-lookup.spec.js
@@ -69,9 +69,38 @@ 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;
+ wrapper.vm.vin = "";
+ wrapper.vm.initialVin = "foo";
+
const vehicleLookupApiResponse = {
data: {
carId: 'new carId' // does not match the store value
@@ -138,14 +167,21 @@ describe("vin-lookup.vue", () => {
it("Should not call navigateForward() when forward button is clicked but lookupVehicle errors out.", async () => {
// Arrange
const { wrapper } = setupMocks({});
+ wrapper.vm.vinTouched = true;
+ wrapper.vm.vin = "foo";
+ wrapper.vm.initialVin = "!foo";
+
const vehicleLookupApiResponse = {
- data: {
+ status: {
carId: 'new carId' // does not match the store value
}
};
const vinPromise = Promise.reject(vehicleLookupApiResponse);
- wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise);
+ const response = {
+ status: 404
+ };
+ wrapper.vm.lookupVehicle = jest.fn().mockImplementation((response) => vinPromise);
wrapper.vm.navigateForward = jest.fn();
wrapper.vm.previouslyEnteredCarId = 'new carId';
diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue
index 33c192941..29aeda5e4 100644
--- a/src/layouts/vin-lookup/vin-lookup.vue
+++ b/src/layouts/vin-lookup/vin-lookup.vue
@@ -142,6 +142,7 @@ import { Form, defineRule } from "vee-validate";
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
+import { StatusCodes } from 'http-status-codes';
// DEFINE VALIDATION RULES
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
@@ -259,7 +260,7 @@ export default {
},
setupVinMask() {
const lastSixChars = this.initialVin.substring(11, this.initialVin.length);
- this.vinMask = `!X!X!X!X!X!X!X!X!X!X!X${lastSixChars}`;
+ this.vinMask = `!X!X!X!X!X!X!X!X!X!X!X${lastSixChars}`;
},
arePagePrerequisitesValid() {
return store.getters.vehicle.carId !== null;
@@ -304,26 +305,9 @@ export default {
}
},
async forwardButtonAction() {
- // If there is no change to the VIN entered then navigate forward without performing lookup.
- if (this.vinPopulatedOnPageLoad && this.vin == this.initialVin) {
- this.navigateForward();
- return;
- }
const zipValidation = this.validateZip(this.zip);
- const vehicleLookup = this.lookupVehicle(this.vin);
-
const zipValidationResponse = await zipValidation;
- const vehicleLookupResponse = await vehicleLookup.catch(() => {
- this.vinNotFound = true;
- this.$refs.funnelFooter.removeLoader();
- this.noServiceZip = false;
- return false;
- });
-
- if (!vehicleLookupResponse) {
- return;
- }
if (!zipValidationResponse.data.isServiceable) {
this.customAlertData.zip = this.zip;
@@ -333,6 +317,29 @@ export default {
return;
}
+ // If the user has clicked on the VIN field, either they are doing a new VIN lookup or changing the VIN previously matched.
+ // Therefore we need to do a VIN Lookup
+ let vehicleLookupResponse;
+ if (this.vinTouched && this.vin != this.initialVin) {
+ const vinToLookup = this.vinTouched ? this.vin : this.initialVin;
+ const vehicleLookup = this.lookupVehicle(vinToLookup);
+ vehicleLookupResponse = await vehicleLookup.catch((response) => {
+ if (response.status == StatusCodes.NOT_FOUND) {
+ this.vinNotFound = true;
+ this.$refs.funnelFooter.removeLoader();
+ this.noServiceZip = false;
+ return false;
+ }
+ });
+
+ if (!vehicleLookupResponse) {
+ return;
+ }
+ } else {
+ this.navigateForward();
+ return;
+ }
+
this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId;
if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) {
diff --git a/src/mixins/vin-pages-mixin.js b/src/mixins/vin-pages-mixin.js
index 8f33fdf92..383bcf237 100644
--- a/src/mixins/vin-pages-mixin.js
+++ b/src/mixins/vin-pages-mixin.js
@@ -19,7 +19,7 @@ export default {
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data);
}
else {
- store.commit(storeMutations.UPDATE_PARTS, result.data);
+ store.commit(storeMutations.UPDATE_GLASS_PARTS, result.data);
this.$refs.loadingModal.showModal();
navigateAfterSaveToHeritageFunnel(this.$route);
}
diff --git a/src/mixins/vin-pages-mixin.spec.js b/src/mixins/vin-pages-mixin.spec.js
index 747b62793..aef929d52 100644
--- a/src/mixins/vin-pages-mixin.spec.js
+++ b/src/mixins/vin-pages-mixin.spec.js
@@ -872,7 +872,7 @@ describe("vin-pages-mixin", () => {
// Assert
expect(store.commit).toHaveBeenCalledTimes(1);
- expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_PARTS, { partsOrQuestions })
+ expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_GLASS_PARTS, { partsOrQuestions })
expect(wrapper.vm.$refs.loadingModal.showModal).toHaveBeenCalledTimes(1);
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalledTimes(1);
});
diff --git a/src/router/index.js b/src/router/index.js
index 74ee110de..2b2d09859 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -46,6 +46,7 @@ const routes = [
// If the saved session has timed out, clear the session, execute 404 logic.
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
+ await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
await GoToFunnelStartOn404(next);
}
diff --git a/src/store/index.js b/src/store/index.js
index c3e54d27b..5730adf53 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -111,7 +111,7 @@ export const mutations = {
updateGlassToReplace(state, glassToReplace) {
state.order.damage.glassToReplace = glassToReplace;
},
- updateParts(state, partsData) {
+ updateGlassParts(state, partsData) {
state.order.lineItems.glassParts = partsData;
},
updatePageData(state, pageData) {
@@ -212,9 +212,8 @@ export const mutations = {
state.order.vehicle.registration.firstName = null;
state.order.vehicle.registration.lastName = null;
},
- resetPartsState(state) {
+ resetGlassPartsState(state) {
state.order.lineItems.glassParts = null;
- state.order.lineItems.otherParts = null;
},
resetState(state) {
Object.assign(state, getDefaultState());
@@ -400,14 +399,14 @@ export const actions = {
},
resetDamageAndDependencies(context) {
context.commit(storeMutations.RESET_DAMAGE_STATE);
- context.commit(storeMutations.RESET_PARTS_STATE);
+ context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
},
resetRegistrationAndDependencies(context) {
context.commit(storeMutations.RESET_REGISTRATION_STATE);
- context.commit(storeMutations.RESET_PARTS_STATE)
+ context.commit(storeMutations.RESET_GLASS_PARTS_STATE)
},
resetPartsAndDependencies(context) {
- context.commit(storeMutations.RESET_PARTS_STATE);
+ context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
},
resetState(context) {
context.commit(storeMutations.RESET_STATE);
diff --git a/src/store/store.spec.js b/src/store/store.spec.js
index bdb49ece7..c70629296 100644
--- a/src/store/store.spec.js
+++ b/src/store/store.spec.js
@@ -183,7 +183,7 @@ describe("Mutations", () => {
const storeState = state;
// Act
- mutations.updateParts(storeState, { 'Windshield-Single': 'PARTNUM101'});
+ mutations.updateGlassParts(storeState, { 'Windshield-Single': 'PARTNUM101'});
// Assert
expect(storeState.order.lineItems.glassParts).toEqual({ 'Windshield-Single': 'PARTNUM101'});
@@ -446,7 +446,7 @@ describe("Actions", () => {
await actions.resetDamageAndDependencies(context)
expect(commit).toBeCalledWith(storeMutations.RESET_DAMAGE_STATE);
- expect(commit).toBeCalledWith(storeMutations.RESET_PARTS_STATE);
+ expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE);
});
@@ -462,7 +462,7 @@ describe("Actions", () => {
await actions.resetRegistrationAndDependencies(context)
expect(commit).toBeCalledWith(storeMutations.RESET_REGISTRATION_STATE);
- expect(commit).toBeCalledWith(storeMutations.RESET_PARTS_STATE);
+ expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE);
});
@@ -477,7 +477,7 @@ describe("Actions", () => {
// Act
await actions.resetPartsAndDependencies(context)
- expect(commit).toBeCalledWith(storeMutations.RESET_PARTS_STATE);
+ expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE);
});
@@ -747,7 +747,7 @@ describe("Getters", () => {
const storeState = state;
// Act
- mutations.updateParts(storeState, {"Rear-Stationary": 'PART101'});
+ mutations.updateGlassParts(storeState, {"Rear-Stationary": 'PART101'});
// Assert
expect(getters.lineItems(storeState).glassParts).toEqual({"Rear-Stationary": 'PART101'});
diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.vue b/src/ux-components/list-button-horizontal/list-button-horizontal.vue
index eef4be443..dfd322cb3 100644
--- a/src/ux-components/list-button-horizontal/list-button-horizontal.vue
+++ b/src/ux-components/list-button-horizontal/list-button-horizontal.vue
@@ -78,6 +78,10 @@ export default {
validationRules: String,
selectedValues: [Array, String],
hasError: Boolean,
+ clearOnUnmount: {
+ type: Boolean,
+ default: true
+ }
},
data() {
return {
@@ -92,9 +96,11 @@ export default {
: this.selectedValues[0];
}
},
- unmounted() { // needed to clear this button's selectedValues if it is removed
- this.checkValue = false;
- this.handleCheckChange();
+ unmounted() { // needed to clear this button's selectedValues if it is removed to keep validation in sync
+ if (this.clearOnUnmount) {
+ this.checkValue = false;
+ this.handleCheckChange();
+ }
},
methods: {
displayLoader() {
diff --git a/src/ux-components/list-button/list-button.vue b/src/ux-components/list-button/list-button.vue
index f09384934..861619093 100644
--- a/src/ux-components/list-button/list-button.vue
+++ b/src/ux-components/list-button/list-button.vue
@@ -78,6 +78,10 @@ export default {
validationRules: String,
selectedValues: [Array, String],
hasError: Boolean,
+ clearOnUnmount: {
+ type: Boolean,
+ default: true
+ }
},
data() {
return {
@@ -92,9 +96,11 @@ export default {
: this.selectedValues[0];
}
},
- unmounted() { // needed to clear this button's selectedValues if it is removed
- this.checkValue = false;
- this.handleCheckChange();
+ unmounted() { // needed to clear this button's selectedValues if it is removed to keep validation in sync
+ if (this.clearOnUnmount) {
+ this.checkValue = false;
+ this.handleCheckChange();
+ }
},
methods: {
displayLoader() {
diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue
index 264d7c299..88aad0b6a 100644
--- a/src/ux-components/list-card/list-card.vue
+++ b/src/ux-components/list-card/list-card.vue
@@ -86,6 +86,10 @@ export default {
selectedValues: [Array, String],
modelValue: Object,
hasError: Boolean,
+ clearOnUnmount: {
+ type: Boolean,
+ default: true
+ }
},
data() {
return {
@@ -99,9 +103,11 @@ export default {
: this.selectedValues[0];
}
},
- unmounted() { // needed to clear this button's selectedValues if it is removed
- this.checkValue = false;
- this.handleCheckChange();
+ unmounted() { // needed to clear this button's selectedValues if it is removed to keep validation in sync
+ if (this.clearOnUnmount) {
+ this.checkValue = false;
+ this.handleCheckChange();
+ }
},
computed: {
getLabelClasses() {