@@ -42,13 +50,13 @@
class="my-3"
:manualHeadline="NoServiceZipHeader"
:manualCopy="NoServiceZipBody"
- v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent"
+ v-if="!isRegistrationZipServiceable && isVinValid && !isCarIdDifferent"
alertClass="alert-danger"
/>
-
-
+
-
diff --git a/src/layouts/vehicle-style/vehicle-style.vue b/src/layouts/vehicle-style/vehicle-style.vue
index 64409adbd..370fdb213 100644
--- a/src/layouts/vehicle-style/vehicle-style.vue
+++ b/src/layouts/vehicle-style/vehicle-style.vue
@@ -93,22 +93,13 @@ export default {
}
return false;
},
- resetDependentState() {
- // Invokes
- store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
- store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
- store.commit(storeMutations.UPDATE_IS_REPAIR, null);
- store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, null);
- store.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, []);
- store.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
- },
},
watch: {
selectedStyle(style) {
- this.$store.commit(this.storeMutations.UPDATE_STYLE, style);
+ this.dispatchStoreAction(storeActions.SAVE_VEHICLE_STYLE, style, false);
this.setVehicle().then(() => {
- this.$router.navigateAfterSave(
+ this.$router.navigate(
this.navigationScenarios.SELECTED_STYLE,
this.$route
);
diff --git a/src/layouts/vehicle-year/vehicle-year.spec.js b/src/layouts/vehicle-year/vehicle-year.spec.js
index 3c54f723d..8dde9a01c 100644
--- a/src/layouts/vehicle-year/vehicle-year.spec.js
+++ b/src/layouts/vehicle-year/vehicle-year.spec.js
@@ -74,34 +74,6 @@ describe("vehicle-year.vue", () => {
});
});
-describe("vehicle-year.vue", () => {
- test("Year set, call invalidation, make, model, style, carId, category should be null", async () => {
-
- //Arrange
- const { wrapper } = setupMocks({});
-
- //Act
- vehicleYear.beforeRouteEnter.call(
- wrapper.vm,
- { query: { fmgPage: "vehicle-year" } },
- undefined,
- (c) => c(wrapper.vm)
- );
-
- wrapper.vm.resetDependentState();
-
- //Assert
- expect(store.commit).toBeCalledWith(storeMutations.UPDATE_MAKE, null)
- expect(store.commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null)
- expect(store.commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null)
- expect(store.commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null)
- expect(store.commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null)
-
- expect(store.dispatch).toBeCalledWith(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES)
- expect(store.dispatch).toBeCalledWith(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES)
-
- });
-});
function setupMocks({
vehicleYearQuestionCmsContent = {},
yearQuestionInitialData = {},
diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue
index 1041f82ae..4ef506eef 100644
--- a/src/layouts/vehicle-year/vehicle-year.vue
+++ b/src/layouts/vehicle-year/vehicle-year.vue
@@ -28,13 +28,11 @@ 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 { experimentUniverses } from "@/constants/experiments";
import { getDeviceIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
import baseMixin from "@/mixins/base-mixin";
-import store from "@/store";
export default {
name: "vehicle-year",
@@ -89,8 +87,8 @@ export default {
watch: {
selectedYear(year) {
const parsedYear = parseInt(year);
- this.$store.commit(this.storeMutations.UPDATE_YEAR, parsedYear);
- this.$router.navigateAfterSave(
+ this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
+ this.$router.navigate(
this.navigationScenarios.SELECTED_YEAR,
this.$route
);
@@ -100,22 +98,6 @@ export default {
arePagePrerequisitesValid() {
return true;
},
- resetDependentState() {
- // Set
- store.commit(storeMutations.UPDATE_MAKE, null);
- store.commit(storeMutations.UPDATE_MODEL, null);
- store.commit(storeMutations.UPDATE_STYLE, null);
- store.commit(storeMutations.UPDATE_CAR_ID, null);
- store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
- store.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
- store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
- store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
- store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
-
- // Invokes
- store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
- store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
- },
},
components: {
yearQuestion,
diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js
index d910c90fd..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';
@@ -200,7 +155,7 @@ describe("vin-lookup.vue", () => {
const { wrapper } = setupMocks({
customMountOptions: {
router: {
- navigateAfterSave: jest.fn()
+ navigate: jest.fn()
}
}
});
@@ -214,8 +169,8 @@ describe("vin-lookup.vue", () => {
await wrapper.vm.navigateForward();
//Assert
- expect(wrapper.vm.$router.navigateAfterSave).toBeCalledTimes(1);
- expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, wrapper.vm.$route, expect.anything(), expect.anything(), expect.anything());
+ 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());
})
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 214899d31..1ba6fb336 100644
--- a/src/layouts/vin-lookup/vin-lookup.vue
+++ b/src/layouts/vin-lookup/vin-lookup.vue
@@ -59,13 +59,6 @@
/>