diff --git a/src/common-components/base-input-button/base-input-button.vue b/src/digital-components/base-input-button/base-input-button.vue
similarity index 98%
rename from src/common-components/base-input-button/base-input-button.vue
rename to src/digital-components/base-input-button/base-input-button.vue
index f67ead49..8768bb8c 100644
--- a/src/common-components/base-input-button/base-input-button.vue
+++ b/src/digital-components/base-input-button/base-input-button.vue
@@ -30,7 +30,7 @@ import {
handleButtonComponentFocus,
handleInputComponentBlur,
} from "@/helpers/button-question-focus-helper";
-import { inputButtonProps } from "@/common-components/base-input-button/button-functionality-props";
+import { inputButtonProps } from "@/digital-components/base-input-button/button-functionality-props";
export default {
name: "base-input-button",
diff --git a/src/common-components/base-input-button/button-functionality-props.js b/src/digital-components/base-input-button/button-functionality-props.js
similarity index 100%
rename from src/common-components/base-input-button/button-functionality-props.js
rename to src/digital-components/base-input-button/button-functionality-props.js
diff --git a/src/common-components/button-question/button-question.spec.js b/src/digital-components/button-question/button-question.spec.js
similarity index 99%
rename from src/common-components/button-question/button-question.spec.js
rename to src/digital-components/button-question/button-question.spec.js
index b958da8c..427faa99 100644
--- a/src/common-components/button-question/button-question.spec.js
+++ b/src/digital-components/button-question/button-question.spec.js
@@ -1,5 +1,5 @@
import { shallowMount } from "@vue/test-utils";
-import buttonQuestion from "@/common-components/button-question/button-question";
+import buttonQuestion from "@/digital-components/button-question/button-question";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
describe("buttonQuestion.vue", () => {
diff --git a/src/common-components/button-question/button-question.vue b/src/digital-components/button-question/button-question.vue
similarity index 100%
rename from src/common-components/button-question/button-question.vue
rename to src/digital-components/button-question/button-question.vue
diff --git a/src/common-components/dropdown-question/dropdown-question.spec.js b/src/digital-components/dropdown-question/dropdown-question.spec.js
similarity index 100%
rename from src/common-components/dropdown-question/dropdown-question.spec.js
rename to src/digital-components/dropdown-question/dropdown-question.spec.js
diff --git a/src/common-components/dropdown-question/dropdown-question.vue b/src/digital-components/dropdown-question/dropdown-question.vue
similarity index 100%
rename from src/common-components/dropdown-question/dropdown-question.vue
rename to src/digital-components/dropdown-question/dropdown-question.vue
diff --git a/src/common-components/modal/modal.spec.js b/src/digital-components/modal/modal.spec.js
similarity index 100%
rename from src/common-components/modal/modal.spec.js
rename to src/digital-components/modal/modal.spec.js
diff --git a/src/common-components/modal/modal.vue b/src/digital-components/modal/modal.vue
similarity index 100%
rename from src/common-components/modal/modal.vue
rename to src/digital-components/modal/modal.vue
diff --git a/src/common-components/question-chain/question-chain.spec.js b/src/digital-components/question-chain/question-chain.spec.js
similarity index 99%
rename from src/common-components/question-chain/question-chain.spec.js
rename to src/digital-components/question-chain/question-chain.spec.js
index 64260ddf..e0e2fb15 100644
--- a/src/common-components/question-chain/question-chain.spec.js
+++ b/src/digital-components/question-chain/question-chain.spec.js
@@ -1,5 +1,5 @@
import { shallowMount } from "@vue/test-utils";
-import questionChain from "@/common-components/question-chain/question-chain.vue";
+import questionChain from "@/digital-components/question-chain/question-chain.vue";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { nextTick } from "vue";
diff --git a/src/common-components/question-chain/question-chain.vue b/src/digital-components/question-chain/question-chain.vue
similarity index 98%
rename from src/common-components/question-chain/question-chain.vue
rename to src/digital-components/question-chain/question-chain.vue
index 11874670..c66d4dcd 100644
--- a/src/common-components/question-chain/question-chain.vue
+++ b/src/digital-components/question-chain/question-chain.vue
@@ -17,7 +17,7 @@
-
\ No newline at end of file
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue b/src/layouts/license-plate-lookup/license-plate-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue
deleted file mode 100644
index 1d258f06..00000000
--- a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue b/src/layouts/license-plate-lookup/license-plate-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue
deleted file mode 100644
index 9c837fbf..00000000
--- a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
\ No newline at end of file
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 784e75d3..65addf33 100644
--- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js
+++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js
@@ -1,49 +1,81 @@
// Components
import licensePlateLookup from "@/layouts/license-plate-lookup/license-plate-lookup.vue";
-// Supporting files
-import { shallowMount } from '@vue/test-utils';
+// Supporting Files
import { settleAllPromises } from "@/helpers/layout-helper.js";
-import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
-import baseMixin from "@/mixins/base-mixin.js";
+import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
-import { nextTick } from "vue";
import { useMainStore } from "@/store";
-import { applicationConfig } from "@/constants/application-config";
+import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
+
+jest.mock("@/helpers/damage-helper", () => ({
+ isGlassAvailableForCarId: jest.fn().mockImplementation(() => true),
+ getDamageString: jest.fn(),
+}));
// Mock our module for promises.
jest.mock("@/helpers/layout-helper.js", () => ({
- settleAllPromises: jest.fn(),
+ settleAllPromises: jest.fn(),
}));
-
+
// Mock fetchCmsContentForPage
jest.mock("@/helpers/cms-content-helper", () => ({
- fetchCmsContentForPage: jest.fn(),
+ fetchCmsContentForPage: jest.fn(),
}));
describe("license-plate-lookup.vue", () => {
- test("Vehicle make set, arePagePrerequisitesValid should be true", () => {
- //Arrange
- const { wrapper } = setupMocks({});
- useMainStore().order.vehicle.carId = "CR00000395";
+ describe("page level alerts", () => {
+ test("If license plate matches a different vehicle, display MatchedDifferentVehicleAlert", async () => {
+ // Arrange
+ const mockRegistrationLicensePlate = {
+ licensePlate: "UTN990",
+ };
- //Act
- licensePlateLookup.beforeRouteEnter.call(
- wrapper.vm,
- { query: { issPage: "license-plate-lookup" } },
- undefined,
- (c) => c(wrapper.vm)
- );
+ const { wrapper } = setupMocks({});
- let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
+ useMainStore().order.vehicle.carId = "TESTCARID";
- //Assert
- expect(arePagePrerequisitesValid).toBe(true);
+ await wrapper.setData({
+ licensePlate: mockRegistrationLicensePlate
+ });
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.findComponent({ ref: "alertMatchedDifferentVehicle" }).isVisible()).toBe(
+ true
+ );
});
-});
-describe("navigation", () => {
- test("BackButtonAction triggers a router.navigate change", async () => {
+ test("If no vehicles found, display VinNotFound alert", async () => {
+ // Arrange
+ const mockRegistrationLicensePlate = {
+ licensePlate: "TEST1234",
+ };
+
+ const { wrapper } = setupMocks({
+ vinLookupResponseError: "vin not found error"
+ });
+
+ useMainStore().order.vehicle.carId = "TESTCARID";
+
+ await wrapper.setData({
+ licensePlate: mockRegistrationLicensePlate
+ });
+
+ wrapper.vm.navigateForward = jest.fn();
+
+ // Act
+ await wrapper.vm.forwardButtonAction();
+
+ // Assert
+ expect(wrapper.findComponent({ ref: "alertVinNotFound" }).isVisible()).toBe(true);
+ });
+ });
+
+ describe("navigation", () => {
+ test("Clicking back button navigates back", async () => {
//Arrange
const { wrapper, apiPromise } = setupMocks({
mountOptionsMockData: {
@@ -59,86 +91,172 @@ describe("navigation", () => {
undefined,
(c) => c(wrapper.vm)
);
- wrapper.vm.backButtonAction();
- await nextTick();
-
+ await wrapper.vm.backButtonAction();
+
//Assert
- return apiPromise.finally(() => {
- try {
- expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
- }
- catch (e) {
- throw e
- }
- });
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
});
- // TODO: Create test for navigating forward when user clicks Continue
- // and information entered is correct (no alerts)
-
- // TODO: Create test for license-plate-question component emitting value when user clicks Continue
- // and information entered is correct (no alerts)
+ test("License plate found and matches entered vehicle => navigateForwardWithSingleCarMatch", async () => {
+ // Arrange
+ const vehicleFound = {
+ carId: "C0000",
+ };
- // TODO: Create test for zip-question component emitting value when user clicks Continue
- // and information entered is correct (no alerts)
-
- // *The above will be completed when navigation from page is complete (SSR-179)
+ const { wrapper } = setupMocks({});
+ wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
+
+ useMainStore().order.vehicle.carId = "C0000";
+
+ // Act
+ wrapper.vm.navigateForward(vehicleFound);
+
+ // Assert
+ expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1);
+ });
+
+ test("if a different vehicle is found than the one entered and the selected glass is not available for that vehicle, navigate back to vehicle-damage page", async () => {
+ // Arrange
+ const mockRegistrationLicensePlate = {
+ licensePlate: "TEST1234",
+ };
+
+ const { wrapper } = setupMocks({});
+
+ await wrapper.setData({
+ licensePlate: mockRegistrationLicensePlate,
+ isCarIdDifferent: true,
+ isSelectedGlassAvailableForVehicle: false,
+ });
+
+ useMainStore().order.vehicle.carId = "CARID";
+
+ let carsFound = [
+ {
+ vin: "TEST_VIN2",
+ vehicle: {
+ carId: "C0000",
+ },
+ },
+ ];
+
+ // Act
+ await wrapper.vm.navigateForward(carsFound);
+
+ // Assert
+ expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
+ navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
+ undefined,
+ {},
+ { displayVehicleChangeAlert: true }
+ );
+ });
});
+ describe("miscellaneous", () => {
+ test("Vehicle make set, arePagePrerequisitesValid should be true", () => {
+ // Arrange
+ const { wrapper } = setupMocks({});
+ useMainStore().order.vehicle.carId = "CR00000395";
+
+ // Act
+ licensePlateLookup.beforeRouteEnter.call(
+ wrapper.vm,
+ { query: { issPage: "license-plate-lookup" } },
+ undefined,
+ (c) => c(wrapper.vm)
+ );
+
+ let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
+
+ // Assert
+ expect(arePagePrerequisitesValid).toBe(true);
+ });
+ });
+});
+
function setupMocks({
- pageHeaderWidgetHeaderText = {},
- pageFooterWidgetCmsContent = {},
- mountOptionsMockData = {},
- //Values to set in the state store
- carId = null,
- registrationZipCode = null, //"55555",
- licensePlate = null, //"TESTPLATE",
+ isZipValid = true,
+ isZipServiceable = true,
+ lookupVinByPlateResponse,
+ partsOrQuestions = [],
+ vehicle = {},
+ vin = null,
+ carId = "C0000",
+ vinLookupResponseError = null,
+ route = null,
}) {
- //Mock api responses
- const apiResponses = {
- cmsContent: {
- SiteSubHeaderWidget: pageHeaderWidgetHeaderText,
- VehicleBannerWidget: {
- GenericVehicleImage:
- `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/blurred-image.jpg`,
- },
- SiteHeaderWidget: {
- LogoImage:
- `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`,
- },
- SiteFooterWidget: pageFooterWidgetCmsContent,
-
+ useMainStore().validateZip = jest.fn().mockImplementation(() => {
+ return Promise.resolve({
+ data: {
+ isValid: isZipValid,
+ isServiceable: isZipServiceable,
},
- };
-
- mountOptionsMockData = {
- ...mountOptionsMockData,
- router: {
- navigate: jest.fn(),
+ })
+ });
+
+ useMainStore().lookupVinByPlate = jest.fn().mockImplementation(() => {
+ return Promise.resolve({
+ data: lookupVinByPlateResponse
+ ? lookupVinByPlateResponse : {
+ vin: "TEST_VIN",
+ vehicle: {
+ carId: "CARID"
+ },
},
- store: {
- getters: {
- vehicle: {
- registration: {
- licensePlate: licensePlate,
- zipCode: registrationZipCode,
- },
- carId: carId,
- },
+ })
+ });
+
+ useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => {
+ return Promise.resolve({
+ data: {
+ partsOrQuestions: partsOrQuestions,
+ },
+ })
+ });
+
+ const wrapper = shallowMount(
+ licensePlateLookup,
+ getMountOptions({
+ route: route ? route : undefined,
+ router: {
+ navigate: jest.fn(),
+ },
+ mainStore: {
+ order: {
+ vehicle: {
+ carId: carId,
+ registration: {
+ licensePlate: "TESTPLATE",
+ zipCode: "12345",
},
+ },
},
- };
+ },
- const apiPromise = Promise.resolve(apiResponses);
-
- settleAllPromises.mockImplementation(() => apiPromise);
- fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
-
- const mountOptions = getMountOptions(mountOptionsMockData);
+ })
+ );
- const wrapper = shallowMount(licensePlateLookup, mountOptions);
+ const apiResponses = {
+ serviceZipValidationResponse: {
+ isValid: isZipValid,
+ isServiceable: isZipServiceable,
+ },
+ vinLookupResponse: {
+ vin: vin,
+ vehicle: vehicle,
+ error: vinLookupResponseError,
+ },
+ };
- wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
-
- return { wrapper, apiPromise };
+ settleAllPromises.mockImplementation(() => apiResponses);
+
+ wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
+ wrapper.vm.setCmsContent = jest.fn();
+ wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
+ wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
+ wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn();
+ wrapper.vm.$refs.siteFooter.enableForwardButton = jest.fn();
+
+ return { wrapper };
}
\ No newline at end of file
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue
index 7d417eee..703096a2 100644
--- a/src/layouts/license-plate-lookup/license-plate-lookup.vue
+++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue
@@ -10,26 +10,38 @@
:display-generic-vehicle-image="false" />
-
+
+
-
+
+ validationRules="state-required"
+ class="mt-4" />
diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue
index 155d8552..bdf3e956 100644
--- a/src/layouts/molding-questions/molding-questions.vue
+++ b/src/layouts/molding-questions/molding-questions.vue
@@ -37,10 +37,10 @@ import { settleAllPromises } from '@/helpers/layout-helper';
// Import Component
import baseFormMixin from '@/mixins/base-form-mixin';
import { Form } from 'vee-validate';
-import siteFooter from '@/common-components/site-footer/site-footer.vue';
-import siteHeader from '@/common-components/site-header/site-header.vue';
-import siteSubHeader from '@/common-components/site-sub-header/site-sub-header.vue';
-import vehicleBanner from '@/common-components/vehicle-banner/vehicle-banner.vue';
+import siteFooter from '@/iss-components/site-footer/site-footer.vue';
+import siteHeader from '@/iss-components/site-header/site-header.vue';
+import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
+import vehicleBanner from '@/iss-components/vehicle-banner/vehicle-banner.vue';
export default {
name: 'molding-questions',
diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue
index 0281b740..58a60621 100644
--- a/src/layouts/part-questions/part-questions.vue
+++ b/src/layouts/part-questions/part-questions.vue
@@ -16,7 +16,7 @@