diff --git a/src/digital-components/textbox-question/textbox-question.vue b/src/digital-components/textbox-question/textbox-question.vue
index 6e047100..d6b8e5bb 100644
--- a/src/digital-components/textbox-question/textbox-question.vue
+++ b/src/digital-components/textbox-question/textbox-question.vue
@@ -44,7 +44,7 @@
-
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.spec.js
deleted file mode 100644
index fbeac8a5..00000000
--- a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.spec.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/* eslint-env jest */
-import { getDamageString } from '@/helpers/damage-helper';
-import vehicleLookupAlertTypes from '@/constants/vehicle-lookup-alert-types';
-import { RouterLinkStub } from '@vue/test-utils';
-import { render } from '@testing-library/vue';
-import '@testing-library/jest-dom';
-import LicensePlateLookupAlertsComponent from '@/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.vue';
-
-jest.mock('@/helpers/damage-helper');
-
-const mountOptions = {
- global: {
- stubs: {
- RouterLink: RouterLinkStub,
- },
- mixins: [
- {
- methods: {
- getCmsContent: jest.fn(() => ''),
- getFooterInfoBoxHeight: jest.fn(() => 80),
- cssClassNameForCmsWidget: jest.fn(() => 'widget-name-mock-class'),
- },
- },
- ],
- },
-};
-
-describe('license-plate-lookup-alerts.vue', () => {
- test('VehicleNotFoundAlert is displayed on the screen', () => {
- // Arrange
- mountOptions.props = {
- activeAlertType: vehicleLookupAlertTypes.NOT_FOUND,
- };
-
- // Act
- const { queryByRole } = render(LicensePlateLookupAlertsComponent, mountOptions);
- const vehicleNotFoundAlert = queryByRole('alert', { name: 'vehicle-not-found-alert' });
- const vehicleNotMatchedAlert = queryByRole('alert', { name: 'vehicle-not-matched-alert'});
-
- // Assert
- expect(vehicleNotFoundAlert).toBeVisible();
- expect(vehicleNotMatchedAlert).toEqual(null);
- });
-
- test('VehicleNotMatchedAlert is displayed on the screen', () => {
- // Arrange
- getDamageString.mockImplementation(() => 'Mock Damage String');
- mountOptions.props = {
- activeAlertType: vehicleLookupAlertTypes.NOT_MATCHED,
- };
-
- // Act
- const { queryByRole } = render(LicensePlateLookupAlertsComponent, mountOptions);
- const vehicleNotFoundAlert = queryByRole('alert', { name: 'vehicle-not-found-alert' });
- const vehicleNotMatchedAlert = queryByRole('alert', { name: 'vehicle-not-matched-alert'});
-
- // Assert
- expect(vehicleNotMatchedAlert).toBeVisible();
- expect(vehicleNotFoundAlert).toEqual(null);
- });
-})
\ No newline at end of file
diff --git a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.vue b/src/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.vue
deleted file mode 100644
index 69f83b9e..00000000
--- a/src/layouts/license-plate-lookup/license-plate-lookup-alerts/license-plate-lookup-alerts.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
\ 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 d33b39c2..e864aae3 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/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js
index 233fcd28..2e2c9d19 100644
--- a/src/router/router-constants/routing-table.js
+++ b/src/router/router-constants/routing-table.js
@@ -137,7 +137,31 @@ const routingTable = function(store) {
{
scenario: navigationScenarios.CLICKED_BACK,
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP,
- },
+ },
+ {
+ scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
+ destinationIssPageValue: issPageValues.VEHICLE_DAMAGE,
+ },
+ {
+ scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
+ destinationIssPageValue: issPageValues.COVERAGE_STATEMENT,
+ },
+ {
+ scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
+ destinationIssPageValue: issPageValues.PART_QUESTIONS,
+ },
+ {
+ scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
+ destinationIssPageValue: issPageValues.VEHICLE_PARTS,
+ },
+ {
+ scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
+ destinationIssPageValue: issPageValues.MOLDING_QUESTIONS,
+ },
+ {
+ scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
+ destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS,
+ },
],
},
{
diff --git a/src/store/index.js b/src/store/index.js
index 4b25b865..68e643d2 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -299,14 +299,14 @@ export const useMainStore = defineStore({
});
},
- async lookupVinByPlate(licensePlate) {
+ async lookupVinByPlate(licensePlate, licenseState) {
try {
const response = await globalMethods.callHttpClient({
method: endpoints.LookupVinByPlate.method,
endpoint: endpoints.LookupVinByPlate.url,
payload: {
licensePlate: licensePlate,
- licenseState: "IL", // hard coded until Welcome Page is complete and license state can be pulled from store
+ licenseState: licenseState,
},
});
@@ -895,6 +895,28 @@ export const useMainStore = defineStore({
}
},
+ saveRegistrationLicensePlateLookup({ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo }) {
+ //Reset dependent state when changing
+ if
+ (
+ registrationInfo?.licensePlate !== this.order.vehicle.registration?.licensePlate ||
+ registrationInfo?.state !== this.order.vehicle.registration?.state ||
+ registrationInfo?.zipCode !== this.order.vehicle.registration?.zipCode
+ )
+ {
+ this.resetRegistrationAndDependencies();
+
+ if (!isSelectedGlassAvailableForVehicle) {
+ this.resetDamageAndDependencies();
+ this.resetPartsAndDependencies();
+ }
+
+ //Save new values
+ this.updateVehicle(vehicleInfo);
+ this.updateRegistration(registrationInfo);
+ }
+ },
+
resetRegistrationAndDependencies() {
this.resetRegistrationState();
this.resetGlassPartsState();