Merge 'develop' into feature/digital/SSR-179
This commit is contained in:
commit
ba5dad580f
10 changed files with 258 additions and 309 deletions
|
|
@ -48,6 +48,8 @@ export function getMountOptions(mockData) {
|
|||
mocks.queryStrings = queryStrings;
|
||||
mocks.$router = mockData?.router;
|
||||
mocks.$route = mockData?.route;
|
||||
mocks.$loadScript = mockData?.loadScript;
|
||||
mocks.prependActionToMethod = jest.fn();
|
||||
|
||||
const global = {
|
||||
mocks: mocks,
|
||||
|
|
|
|||
|
|
@ -5,21 +5,15 @@ import addressLookup from "@/layouts/address-lookup/address-lookup.vue";
|
|||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import { useMainStore } from "@/store";
|
||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||
import store from "@/store";
|
||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||
import e from "express";
|
||||
|
||||
jest.mock("@/helpers/damage-helper", () => ({
|
||||
isGlassAvailableForCarId: jest.fn().mockImplementation(() => true),
|
||||
getDamageString: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
||||
navigateToHeritageFunnel: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||
settleAllPromises: jest.fn(),
|
||||
|
|
@ -46,15 +40,20 @@ describe("address-lookup.vue", () => {
|
|||
carId: "C0000",
|
||||
},
|
||||
},
|
||||
{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "C0000",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
addressQuestions: mockRegistrationAddress,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
// Act
|
||||
|
|
@ -84,7 +83,7 @@ describe("address-lookup.vue", () => {
|
|||
],
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID2");
|
||||
useMainStore().order.vehicle.carId = "CARID2";
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -132,7 +131,7 @@ describe("address-lookup.vue", () => {
|
|||
},
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
useMainStore().order.vehicle.carId = "CARID";
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -166,7 +165,7 @@ describe("address-lookup.vue", () => {
|
|||
},
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
useMainStore().order.vehicle.carId = "CARID";
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -182,6 +181,7 @@ describe("address-lookup.vue", () => {
|
|||
// Assert
|
||||
expect(wrapper.findComponent({ ref: "alertVinNotFound" }).isVisible()).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("navigation", () => {
|
||||
|
|
@ -195,7 +195,7 @@ describe("address-lookup.vue", () => {
|
|||
await wrapper.vm.backButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("if the car entered matches one of the vehicles found and the zip is serviceable, navigate forward", async () => {
|
||||
|
|
@ -262,7 +262,7 @@ describe("address-lookup.vue", () => {
|
|||
],
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID_A");
|
||||
useMainStore().order.vehicle.carId = "CARID_A";
|
||||
|
||||
const carsFound = [
|
||||
{
|
||||
|
|
@ -291,7 +291,7 @@ describe("address-lookup.vue", () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
|
||||
undefined,
|
||||
{},
|
||||
|
|
@ -328,7 +328,7 @@ describe("address-lookup.vue", () => {
|
|||
],
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
useMainStore().order.vehicle.carId = "CARID";
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -367,6 +367,8 @@ describe("address-lookup.vue", () => {
|
|||
isSelectedGlassAvailableForVehicle: false,
|
||||
});
|
||||
|
||||
useMainStore().order.vehicle.carId = "CARID";
|
||||
|
||||
let carsFound = [
|
||||
{
|
||||
vin: "TEST_VIN2",
|
||||
|
|
@ -380,7 +382,7 @@ describe("address-lookup.vue", () => {
|
|||
await wrapper.vm.navigateForward(carsFound);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith(
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
|
||||
undefined,
|
||||
{},
|
||||
|
|
@ -403,6 +405,8 @@ describe("address-lookup.vue", () => {
|
|||
const { wrapper } = setupMocks({}, {});
|
||||
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
||||
|
||||
useMainStore().order.vehicle.carId = "C0000";
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateForward(carsFound);
|
||||
|
||||
|
|
@ -436,12 +440,15 @@ describe("address-lookup.vue", () => {
|
|||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
||||
|
||||
useMainStore().order.vehicle.carId = "CARID3";
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateForward(carsFound);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("registration and service zips", () => {
|
||||
|
|
@ -457,9 +464,20 @@ describe("address-lookup.vue", () => {
|
|||
|
||||
const { wrapper } = setupMocks({
|
||||
isZipServiceable: true,
|
||||
isStatePermissible: true,
|
||||
vinVehicles: [
|
||||
{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "CARID",
|
||||
},
|
||||
},
|
||||
],
|
||||
route: { query: "address-lookup" },
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
useMainStore().order.vehicle.carId = "CARID";
|
||||
useMainStore().saveRegistrationAddressLookup = jest.fn();
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -471,20 +489,8 @@ describe("address-lookup.vue", () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith(
|
||||
"lookupVinByAddress",
|
||||
{
|
||||
licenseLastName: undefined,
|
||||
licenseState: "OH",
|
||||
licenseStreetAddress: "1234 Main St",
|
||||
licenseZip: "43215",
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith("validateZip", {
|
||||
zip: "43215",
|
||||
});
|
||||
expect(useMainStore().saveRegistrationAddressLookup).toHaveBeenCalled();
|
||||
expect(useMainStore().validateZip).toHaveBeenCalledWith({ zip: "43215" });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -511,7 +517,7 @@ describe("address-lookup.vue", () => {
|
|||
],
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
useMainStore().order.vehicle.carId = "C0000";
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -549,7 +555,7 @@ describe("address-lookup.vue", () => {
|
|||
isZipServiceable: false,
|
||||
});
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
useMainStore().order.vehicle.carId = "CARID";
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
|
|
@ -557,83 +563,17 @@ describe("address-lookup.vue", () => {
|
|||
},
|
||||
});
|
||||
|
||||
useMainStore().saveRegistrationAddressLookup = jest.fn();
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//FIX THIS
|
||||
// Assert
|
||||
expect(wrapper.vm.dispatchStoreAction).not.toHaveBeenCalledWith(
|
||||
storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION
|
||||
);
|
||||
});
|
||||
|
||||
test("if registration address, service zip are provided, and user clicks continue => both zips are saved and are different", async () => {
|
||||
// Arrange
|
||||
const mockRegistrationAddress = {
|
||||
streetAddress: "1234 Main St",
|
||||
city: "Columbus",
|
||||
state: "OH",
|
||||
zipCode: "43215",
|
||||
};
|
||||
|
||||
const { wrapper } = setupMocks({});
|
||||
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
||||
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||
|
||||
wrapper.vm.dispatchStoreAction = jest.fn();
|
||||
wrapper.vm.dispatchStoreAction.mockImplementation((actionName, value) => {
|
||||
let data = {};
|
||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
||||
if (value == "43215") {
|
||||
data = {
|
||||
isServiceable: false,
|
||||
};
|
||||
} else {
|
||||
data = {
|
||||
isServiceable: true,
|
||||
};
|
||||
}
|
||||
} else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
||||
data = {
|
||||
isStatePermissible: true,
|
||||
vinVehicles: [
|
||||
{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "CARID",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return Promise.resolve({ data });
|
||||
});
|
||||
|
||||
await wrapper.setData({
|
||||
customerQuestions: {
|
||||
addressQuestions: mockRegistrationAddress,
|
||||
},
|
||||
});
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
await wrapper.setData({
|
||||
serviceZipCode: "12345",
|
||||
});
|
||||
|
||||
// // Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// // Assert
|
||||
expect(wrapper.vm.$store.getters.order.serviceLocation.zipCode).not.toEqual(
|
||||
wrapper.vm.$store.getters.vehicle.registration.zipCode
|
||||
);
|
||||
expect(wrapper.vm.$store.getters.vehicle.registration.zipCode).toEqual("12345");
|
||||
expect(wrapper.vm.$store.getters.order.serviceLocation.zipCode).toEqual("11111");
|
||||
expect(useMainStore().saveRegistrationAddressLookup).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function setupMocks({
|
||||
|
|
@ -644,50 +584,54 @@ function setupMocks({
|
|||
isStatePermissible = true,
|
||||
vinVehicles = [],
|
||||
carId = "C0000",
|
||||
}) {
|
||||
store.commit(storeMutations.RESET_STATE);
|
||||
route = null,
|
||||
})
|
||||
{
|
||||
|
||||
useMainStore().validateZip = jest.fn().mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
isValid: isZipValid,
|
||||
isServiceable: isZipServiceable,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
useMainStore().lookupVinByAddress = jest.fn().mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
data: lookupVinbyAddressResponse
|
||||
? lookupVinbyAddressResponse
|
||||
: {
|
||||
isStatePermissible: true,
|
||||
vinVehicles: [
|
||||
{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "CARID",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
partsOrQuestions: partsOrQuestions,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
const wrapper = shallowMount(
|
||||
addressLookup,
|
||||
getMountOptions({
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.VALIDATE_ZIP,
|
||||
data: {
|
||||
isValid: isZipValid,
|
||||
isServiceable: isZipServiceable,
|
||||
},
|
||||
},
|
||||
{
|
||||
actionName: storeActions.LOOKUP_VIN_BY_ADDRESS,
|
||||
data: lookupVinbyAddressResponse
|
||||
? lookupVinbyAddressResponse
|
||||
: {
|
||||
isStatePermissible: true,
|
||||
vinVehicles: [
|
||||
{
|
||||
vin: "TEST_VIN",
|
||||
vehicle: {
|
||||
carId: "CARID",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
actionName: storeActions.GET_PARTS_OR_QUESTIONS,
|
||||
data: {
|
||||
partsOrQuestions: partsOrQuestions,
|
||||
},
|
||||
},
|
||||
],
|
||||
route: route ? route : undefined,
|
||||
router: {
|
||||
navigate: jest.fn(),
|
||||
navigate: jest.fn(),
|
||||
navigateWithSaving: jest.fn(),
|
||||
navigateWithoutSaving: jest.fn(),
|
||||
},
|
||||
store: {
|
||||
getters: {
|
||||
mainStore: {
|
||||
order: {
|
||||
vehicle: {
|
||||
carId: carId,
|
||||
registration: {
|
||||
|
|
@ -695,16 +639,15 @@ function setupMocks({
|
|||
zipCode: "12345",
|
||||
},
|
||||
},
|
||||
order: {
|
||||
customer: {
|
||||
emailAddress: "test@test.com",
|
||||
},
|
||||
serviceLocation: {
|
||||
zipCode: "11111",
|
||||
},
|
||||
customer: {
|
||||
emailAddress: "test@test.com",
|
||||
},
|
||||
serviceLocation: {
|
||||
zipCode: "11111",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -723,8 +666,8 @@ function setupMocks({
|
|||
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
||||
wrapper.vm.setCmsContent = jest.fn();
|
||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
|
||||
wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
|
||||
|
||||
return { wrapper };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,19 +163,7 @@ export default {
|
|||
return this.mainStore.order.vehicle.carId !== null;
|
||||
},
|
||||
loadDefaultsFromStore() {
|
||||
const data = this.mainStore.order.vehicle.registration;
|
||||
this.customerQuestions = { ...this.customerQuestions,
|
||||
...{
|
||||
firstName: data.firstName,
|
||||
lastName: data.lastName,
|
||||
addressQuestions: {
|
||||
streetAddress: data.address,
|
||||
city: data.city,
|
||||
state: data.state,
|
||||
zipCode: data.zipCode
|
||||
}
|
||||
}
|
||||
};
|
||||
this.customerQuestions = this.mainStore.customerDataAddressLookup;
|
||||
},
|
||||
backButtonAction() {
|
||||
// route to move backwards
|
||||
|
|
@ -340,8 +328,7 @@ export default {
|
|||
// display vehicle changed alert on that page.
|
||||
if (
|
||||
this.isCarIdDifferent &&
|
||||
!this.isSelectedGlassAvailableForVehicle &&
|
||||
matchingCars.length === 1
|
||||
!this.isSelectedGlassAvailableForVehicle
|
||||
) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import alert from "@/ux-components/alert/alert";
|
|||
// Supporting Files
|
||||
import { mount, shallowMount } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import store from "@/store";
|
||||
|
||||
let autocompleteElement;
|
||||
describe("address-questions.vue", () => {
|
||||
|
|
@ -18,29 +16,6 @@ describe("address-questions.vue", () => {
|
|||
});
|
||||
|
||||
describe("initial state", () => {
|
||||
test("only street address field is shown", () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// Assert
|
||||
const streetAddressField = wrapper.findComponent({ ref: "autocomplete" });
|
||||
const cityField = wrapper.findComponent({ ref: "city" });
|
||||
const stateField = wrapper.findComponent({ ref: "state" });
|
||||
const zipCodeField = wrapper.findComponent({ ref: "zipCode" });
|
||||
|
||||
expect(streetAddressField.exists()).toBe(true);
|
||||
expect(streetAddressField.isVisible()).toBe(true);
|
||||
expect(cityField.exists()).toBe(true);
|
||||
expect(cityField.isVisible()).toBe(false);
|
||||
expect(stateField.exists()).toBe(true);
|
||||
expect(stateField.isVisible()).toBe(false);
|
||||
expect(zipCodeField.exists()).toBe(true);
|
||||
expect(zipCodeField.isVisible()).toBe(false);
|
||||
|
||||
const alerts = wrapper.findAllComponents(alert);
|
||||
expect(alerts.length).toEqual(0);
|
||||
});
|
||||
|
||||
test("Should render addressQuestions sub-components (textbox-questions and dropdown-questions)", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
|
@ -57,28 +32,7 @@ describe("address-questions.vue", () => {
|
|||
expect(state.exists()).toBe(true);
|
||||
expect(zipCode.exists()).toBe(true);
|
||||
});
|
||||
|
||||
test("Should it set this.showAddressFields to true when the model is prepopulated", async () => {
|
||||
// Arrange
|
||||
// Act
|
||||
const newAddressModel = {
|
||||
streetAddress: "foo",
|
||||
city: "foo",
|
||||
state: "foo",
|
||||
zipCode: "55555",
|
||||
};
|
||||
const wrapper = shallowMount(addressQuestions, {
|
||||
propsData: {
|
||||
modelValue: newAddressModel,
|
||||
},
|
||||
});
|
||||
|
||||
// Act
|
||||
wrapper.vm.setupAddressLookup();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.showAddressFields).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("happy paths", () => {
|
||||
|
|
@ -109,46 +63,6 @@ describe("address-questions.vue", () => {
|
|||
expect(cityField.isVisible()).toBeTruthy();
|
||||
});
|
||||
|
||||
test("full street address is passed in => don't load Google Autocomplete script", async () => {
|
||||
// Arrange/Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: {
|
||||
streetAddress: "12345 Test Road",
|
||||
city: "Tests",
|
||||
state: "OH",
|
||||
zipCode: "12312",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$loadScript).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("address field is focused => disable autofill", async () => {
|
||||
// Arrange
|
||||
let focusEventCallbackFunction;
|
||||
autocompleteElement.addEventListener = jest
|
||||
.fn()
|
||||
.mockImplementation((eventName, callbackFunction) => {
|
||||
if (eventName == "focus") {
|
||||
focusEventCallbackFunction = callbackFunction;
|
||||
}
|
||||
});
|
||||
const { wrapper } = setupMocks({});
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Act
|
||||
focusEventCallbackFunction();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(autocompleteElement.getAttribute("autocomplete")).toEqual("do-not-autofill");
|
||||
});
|
||||
|
||||
test("street address is entered, user chooses good result from autocomplete results => other fields are filled in", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
|
@ -520,6 +434,7 @@ describe("address-questions.vue", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function setupMocks({
|
||||
|
|
@ -529,8 +444,7 @@ function setupMocks({
|
|||
querySelectorFunction,
|
||||
geocoderResult = ["1234 Test Street"],
|
||||
}) {
|
||||
store.commit(storeMutations.RESET_STATE);
|
||||
|
||||
|
||||
const resultingMountOptions = getMountOptions({
|
||||
...mountOptions,
|
||||
router: {
|
||||
|
|
|
|||
|
|
@ -22,12 +22,10 @@ describe("customerQuestions.vue", () => {
|
|||
const addressQuestions = wrapper.findComponent({ ref: "addressQuestions" });
|
||||
const firstName = wrapper.findComponent({ ref: "firstName" });
|
||||
const lastName = wrapper.findComponent({ ref: "lastName" });
|
||||
const emailAddress = wrapper.findComponent({ ref: "emailAddress" });
|
||||
|
||||
// Assert
|
||||
expect(addressQuestions.exists()).toBe(true);
|
||||
expect(firstName.exists()).toBe(true);
|
||||
expect(lastName.exists()).toBe(true);
|
||||
expect(emailAddress.exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
|||
export default {
|
||||
methods: {
|
||||
async navigateForwardWithSingleCarMatch() {
|
||||
const store = useMainStore();
|
||||
|
||||
const result = await store.getPartsOrQuestions();
|
||||
const result = await useMainStore().getPartsOrQuestions();
|
||||
const partsOrQuestions = result.data.partsOrQuestions;
|
||||
|
||||
vehicleQuestionsMixin.methods.navigateForward(partsOrQuestions, this);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { setupMocksForJsFiles, getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||
|
||||
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
||||
navigateForward: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("@/helpers/heritage-integration/order-helper.js", () => ({
|
||||
saveSession: jest.fn(),
|
||||
}));
|
||||
import { useMainStore } from "@/store";
|
||||
|
||||
describe("vin-pages-mixin", () => {
|
||||
afterEach(() => {
|
||||
|
|
@ -20,6 +12,7 @@ describe("vin-pages-mixin", () => {
|
|||
describe("navigateForwardWithSingleCarMatch", () => {
|
||||
test("should navigateForward", async () => {
|
||||
// Arrange
|
||||
useMainStore().getPartsOrQuestions = () => { return { data: {partsOrQuestions: {}}} };
|
||||
const { wrapper } = setupMocks({});
|
||||
vehicleQuestionsMixin.methods.navigateForward = jest.fn();
|
||||
|
||||
|
|
@ -32,36 +25,15 @@ describe("vin-pages-mixin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
function setupMocks({ partsOrQuestions = [] }) {
|
||||
const baseMixin = setupMocksForJsFiles({
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.GET_PARTS_OR_QUESTIONS,
|
||||
data: {
|
||||
partsOrQuestions: partsOrQuestions,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
function setupMocks() {
|
||||
const mocks = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn(),
|
||||
navigateWithSaving: jest.fn(),
|
||||
navigateWithoutSaving: jest.fn(),
|
||||
},
|
||||
store: {
|
||||
commit: jest.fn(),
|
||||
getters: {
|
||||
applicationUser: {
|
||||
savedSessionId: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const mockVinComponent = {
|
||||
mixins: [vinPagesMixin, baseMixin.baseMixin],
|
||||
mixins: [vinPagesMixin],
|
||||
};
|
||||
|
||||
const wrapper = shallowMount(mockVinComponent, mocks);
|
||||
|
|
|
|||
|
|
@ -255,21 +255,57 @@ const routingTable = function(store) {
|
|||
destinationIssPageValue: issPageValues.QUOTE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
issPageValue: issPageValues.WELCOME_PAGE,
|
||||
maps: [
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK,
|
||||
destinationIssPageValue: issPageValues.WELCOME_PAGE
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.WELCOME_PAGE,
|
||||
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
issPageValue: issPageValues.ADDRESS_LOOKUP,
|
||||
maps: [
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK,
|
||||
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
|
||||
destinationIssPageValue: issPageValues.ADDRESS_VEHICLES,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
|
||||
destinationIssPageValue: issPageValues.VEHICLE_DAMAGE,
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||
destinationIssPageValue: issPageValues.QUOTE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
issPageValue: issPageValues.WELCOME_PAGE,
|
||||
maps: [
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK,
|
||||
destinationIssPageValue: issPageValues.WELCOME_PAGE
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.WELCOME_PAGE,
|
||||
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ const getDefaultState = () => {
|
|||
capabilityQuestionAnswers: null,
|
||||
},
|
||||
customer: {
|
||||
address: {
|
||||
streetAddress: null,
|
||||
city: null,
|
||||
state: null,
|
||||
zipCode: null,
|
||||
},
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
emailAddress: null,
|
||||
},
|
||||
serviceLocation: {
|
||||
|
|
@ -109,6 +117,35 @@ export const useMainStore = defineStore({
|
|||
applicationUserObj: (state) => state.applicationUser,
|
||||
pageData: (state) => (page) => {
|
||||
return state.applicationUser.pageData[page];
|
||||
},
|
||||
customerDataAddressLookup: (state) => {
|
||||
if (state.order.vehicle.registration.address)
|
||||
{
|
||||
const registration = state.order.vehicle.registration;
|
||||
return {
|
||||
addressQuestions: {
|
||||
streetAddress: registration.address,
|
||||
city: registration.city,
|
||||
state: registration.state,
|
||||
zipCode: registration.zipCode,
|
||||
},
|
||||
firstName: registration.firstName,
|
||||
lastName: registration.lastName,
|
||||
}
|
||||
}
|
||||
else {
|
||||
const address = state.order.customer.address;
|
||||
return {
|
||||
addressQuestions: {
|
||||
streetAddress: address.streetAddress,
|
||||
city: address.city,
|
||||
state: address.state,
|
||||
zipCode: address.zipCode,
|
||||
},
|
||||
firstName: state.order.customer.firstName,
|
||||
lastName: state.order.customer.lastName,
|
||||
}
|
||||
}
|
||||
},
|
||||
experimentOrder: (state) => {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -157,4 +157,66 @@ describe("Store", () => {
|
|||
expect(store.order.damage.numberOfChips).toEqual(null);
|
||||
});
|
||||
|
||||
it("should return registration data if available", () => {
|
||||
//Arrange
|
||||
const expected = {
|
||||
addressQuestions: {
|
||||
streetAddress: "test",
|
||||
city: "city",
|
||||
state: "state",
|
||||
zipCode: "zip",
|
||||
},
|
||||
firstName: "1stName",
|
||||
lastName: "Surname",
|
||||
}
|
||||
|
||||
store.order.vehicle.registration = {
|
||||
licensePlate: null,
|
||||
address: "test",
|
||||
city: "city",
|
||||
state: "state",
|
||||
zipCode: "zip",
|
||||
firstName: "1stName",
|
||||
lastName: "Surname",
|
||||
};
|
||||
|
||||
//Act
|
||||
const actual = store.customerDataAddressLookup;
|
||||
//Assert
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it("should return customer data if registration data unavailable", () => {
|
||||
//Arrange
|
||||
const expected = {
|
||||
addressQuestions: {
|
||||
streetAddress: "test",
|
||||
city: "city",
|
||||
state: "state",
|
||||
zipCode: "zip",
|
||||
},
|
||||
firstName: "1stName",
|
||||
lastName: "Surname",
|
||||
}
|
||||
|
||||
store.order.vehicle.registration.address = null;
|
||||
|
||||
store.order.customer = {
|
||||
licensePlate: null,
|
||||
address: "test",
|
||||
city: "city",
|
||||
state: "state",
|
||||
zipCode: "zip",
|
||||
firstName: "1stName",
|
||||
lastName: "Surname",
|
||||
};
|
||||
|
||||
//Act
|
||||
const actual = store.customerDataAddressLookup;
|
||||
//Assert
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue