Merge 'develop' into feature/digital/SSR-179

This commit is contained in:
katie 2023-01-18 09:44:42 -05:00
commit ba5dad580f
10 changed files with 258 additions and 309 deletions

View file

@ -48,6 +48,8 @@ export function getMountOptions(mockData) {
mocks.queryStrings = queryStrings; mocks.queryStrings = queryStrings;
mocks.$router = mockData?.router; mocks.$router = mockData?.router;
mocks.$route = mockData?.route; mocks.$route = mockData?.route;
mocks.$loadScript = mockData?.loadScript;
mocks.prependActionToMethod = jest.fn();
const global = { const global = {
mocks: mocks, mocks: mocks,

View file

@ -5,21 +5,15 @@ import addressLookup from "@/layouts/address-lookup/address-lookup.vue";
import { settleAllPromises } from "@/helpers/layout-helper.js"; import { settleAllPromises } from "@/helpers/layout-helper.js";
import { shallowMount } from "@vue/test-utils"; import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { storeActions } from "@/constants/store-actions"; import { useMainStore } from "@/store";
import { storeMutations } from "@/constants/store-mutations";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
import store from "@/store"; import e from "express";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
jest.mock("@/helpers/damage-helper", () => ({ jest.mock("@/helpers/damage-helper", () => ({
isGlassAvailableForCarId: jest.fn().mockImplementation(() => true), isGlassAvailableForCarId: jest.fn().mockImplementation(() => true),
getDamageString: jest.fn(), getDamageString: jest.fn(),
})); }));
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
navigateToHeritageFunnel: jest.fn(),
}));
// Mock our module for promises. // Mock our module for promises.
jest.mock("@/helpers/layout-helper.js", () => ({ jest.mock("@/helpers/layout-helper.js", () => ({
settleAllPromises: jest.fn(), settleAllPromises: jest.fn(),
@ -46,15 +40,20 @@ describe("address-lookup.vue", () => {
carId: "C0000", carId: "C0000",
}, },
}, },
{
vin: "TEST_VIN",
vehicle: {
carId: "C0000",
},
},
], ],
}); });
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
await wrapper.setData({ await wrapper.setData({
customerQuestions: { customerQuestions: {
addressQuestions: mockRegistrationAddress, addressQuestions: mockRegistrationAddress,
}, },
}); });
// Act // Act
@ -84,7 +83,7 @@ describe("address-lookup.vue", () => {
], ],
}); });
store.commit(storeMutations.UPDATE_CAR_ID, "CARID2"); useMainStore().order.vehicle.carId = "CARID2";
await wrapper.setData({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -132,7 +131,7 @@ describe("address-lookup.vue", () => {
}, },
}); });
store.commit(storeMutations.UPDATE_CAR_ID, "CARID"); useMainStore().order.vehicle.carId = "CARID";
await wrapper.setData({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -166,7 +165,7 @@ describe("address-lookup.vue", () => {
}, },
}); });
store.commit(storeMutations.UPDATE_CAR_ID, "CARID"); useMainStore().order.vehicle.carId = "CARID";
await wrapper.setData({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -182,6 +181,7 @@ describe("address-lookup.vue", () => {
// Assert // Assert
expect(wrapper.findComponent({ ref: "alertVinNotFound" }).isVisible()).toBe(true); expect(wrapper.findComponent({ ref: "alertVinNotFound" }).isVisible()).toBe(true);
}); });
}); });
describe("navigation", () => { describe("navigation", () => {
@ -195,7 +195,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.backButtonAction(); await wrapper.vm.backButtonAction();
// Assert // 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 () => { 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 = [ const carsFound = [
{ {
@ -291,7 +291,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES, navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
undefined, undefined,
{}, {},
@ -328,7 +328,7 @@ describe("address-lookup.vue", () => {
], ],
}); });
store.commit(storeMutations.UPDATE_CAR_ID, "CARID"); useMainStore().order.vehicle.carId = "CARID";
await wrapper.setData({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -367,6 +367,8 @@ describe("address-lookup.vue", () => {
isSelectedGlassAvailableForVehicle: false, isSelectedGlassAvailableForVehicle: false,
}); });
useMainStore().order.vehicle.carId = "CARID";
let carsFound = [ let carsFound = [
{ {
vin: "TEST_VIN2", vin: "TEST_VIN2",
@ -380,7 +382,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.navigateForward(carsFound); await wrapper.vm.navigateForward(carsFound);
// Assert // Assert
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
undefined, undefined,
{}, {},
@ -403,6 +405,8 @@ describe("address-lookup.vue", () => {
const { wrapper } = setupMocks({}, {}); const { wrapper } = setupMocks({}, {});
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn(); wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
useMainStore().order.vehicle.carId = "C0000";
// Act // Act
wrapper.vm.navigateForward(carsFound); wrapper.vm.navigateForward(carsFound);
@ -436,12 +440,15 @@ describe("address-lookup.vue", () => {
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn(); wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
useMainStore().order.vehicle.carId = "CARID3";
// Act // Act
wrapper.vm.navigateForward(carsFound); wrapper.vm.navigateForward(carsFound);
// Assert // Assert
expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1); expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1);
}); });
}); });
describe("registration and service zips", () => { describe("registration and service zips", () => {
@ -457,9 +464,20 @@ describe("address-lookup.vue", () => {
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
isZipServiceable: true, 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({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -471,20 +489,8 @@ describe("address-lookup.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith( expect(useMainStore().saveRegistrationAddressLookup).toHaveBeenCalled();
"lookupVinByAddress", expect(useMainStore().validateZip).toHaveBeenCalledWith({ zip: "43215" });
{
licenseLastName: undefined,
licenseState: "OH",
licenseStreetAddress: "1234 Main St",
licenseZip: "43215",
},
false
);
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith("validateZip", {
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({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -549,7 +555,7 @@ describe("address-lookup.vue", () => {
isZipServiceable: false, isZipServiceable: false,
}); });
store.commit(storeMutations.UPDATE_CAR_ID, "CARID"); useMainStore().order.vehicle.carId = "CARID";
await wrapper.setData({ await wrapper.setData({
customerQuestions: { customerQuestions: {
@ -557,83 +563,17 @@ describe("address-lookup.vue", () => {
}, },
}); });
useMainStore().saveRegistrationAddressLookup = jest.fn();
// Act // Act
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//FIX THIS
// Assert // Assert
expect(wrapper.vm.dispatchStoreAction).not.toHaveBeenCalledWith( expect(useMainStore().saveRegistrationAddressLookup).not.toHaveBeenCalled();
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");
}); });
}); });
}); });
}); });
function setupMocks({ function setupMocks({
@ -644,50 +584,54 @@ function setupMocks({
isStatePermissible = true, isStatePermissible = true,
vinVehicles = [], vinVehicles = [],
carId = "C0000", carId = "C0000",
}) { route = null,
store.commit(storeMutations.RESET_STATE); })
{
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( const wrapper = shallowMount(
addressLookup, addressLookup,
getMountOptions({ getMountOptions({
actionList: [ route: route ? route : undefined,
{
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,
},
},
],
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
}, },
store: { mainStore: {
getters: { order: {
vehicle: { vehicle: {
carId: carId, carId: carId,
registration: { registration: {
@ -695,16 +639,15 @@ function setupMocks({
zipCode: "12345", zipCode: "12345",
}, },
}, },
order: { customer: {
customer: { emailAddress: "test@test.com",
emailAddress: "test@test.com", },
}, serviceLocation: {
serviceLocation: { zipCode: "11111",
zipCode: "11111",
},
}, },
}, },
}, },
}) })
); );
@ -723,8 +666,8 @@ function setupMocks({
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ""); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn(); wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn(); wrapper.vm.$refs.siteFooter.removeLoader = jest.fn();
return { wrapper }; return { wrapper };
} }

View file

@ -163,19 +163,7 @@ export default {
return this.mainStore.order.vehicle.carId !== null; return this.mainStore.order.vehicle.carId !== null;
}, },
loadDefaultsFromStore() { loadDefaultsFromStore() {
const data = this.mainStore.order.vehicle.registration; this.customerQuestions = this.mainStore.customerDataAddressLookup;
this.customerQuestions = { ...this.customerQuestions,
...{
firstName: data.firstName,
lastName: data.lastName,
addressQuestions: {
streetAddress: data.address,
city: data.city,
state: data.state,
zipCode: data.zipCode
}
}
};
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
@ -340,8 +328,7 @@ export default {
// display vehicle changed alert on that page. // display vehicle changed alert on that page.
if ( if (
this.isCarIdDifferent && this.isCarIdDifferent &&
!this.isSelectedGlassAvailableForVehicle && !this.isSelectedGlassAvailableForVehicle
matchingCars.length === 1
) { ) {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,

View file

@ -5,8 +5,6 @@ import alert from "@/ux-components/alert/alert";
// Supporting Files // Supporting Files
import { mount, shallowMount } from "@vue/test-utils"; import { mount, shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { storeMutations } from "@/constants/store-mutations";
import store from "@/store";
let autocompleteElement; let autocompleteElement;
describe("address-questions.vue", () => { describe("address-questions.vue", () => {
@ -18,29 +16,6 @@ describe("address-questions.vue", () => {
}); });
describe("initial state", () => { 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 () => { test("Should render addressQuestions sub-components (textbox-questions and dropdown-questions)", async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -58,27 +33,6 @@ describe("address-questions.vue", () => {
expect(zipCode.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", () => { describe("happy paths", () => {
@ -109,46 +63,6 @@ describe("address-questions.vue", () => {
expect(cityField.isVisible()).toBeTruthy(); 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 () => { test("street address is entered, user chooses good result from autocomplete results => other fields are filled in", async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -520,6 +434,7 @@ describe("address-questions.vue", () => {
}); });
}); });
}); });
}); });
function setupMocks({ function setupMocks({
@ -529,7 +444,6 @@ function setupMocks({
querySelectorFunction, querySelectorFunction,
geocoderResult = ["1234 Test Street"], geocoderResult = ["1234 Test Street"],
}) { }) {
store.commit(storeMutations.RESET_STATE);
const resultingMountOptions = getMountOptions({ const resultingMountOptions = getMountOptions({
...mountOptions, ...mountOptions,

View file

@ -22,12 +22,10 @@ describe("customerQuestions.vue", () => {
const addressQuestions = wrapper.findComponent({ ref: "addressQuestions" }); const addressQuestions = wrapper.findComponent({ ref: "addressQuestions" });
const firstName = wrapper.findComponent({ ref: "firstName" }); const firstName = wrapper.findComponent({ ref: "firstName" });
const lastName = wrapper.findComponent({ ref: "lastName" }); const lastName = wrapper.findComponent({ ref: "lastName" });
const emailAddress = wrapper.findComponent({ ref: "emailAddress" });
// Assert // Assert
expect(addressQuestions.exists()).toBe(true); expect(addressQuestions.exists()).toBe(true);
expect(firstName.exists()).toBe(true); expect(firstName.exists()).toBe(true);
expect(lastName.exists()).toBe(true); expect(lastName.exists()).toBe(true);
expect(emailAddress.exists()).toBe(true);
}); });
}); });

View file

@ -4,9 +4,7 @@ import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
export default { export default {
methods: { methods: {
async navigateForwardWithSingleCarMatch() { async navigateForwardWithSingleCarMatch() {
const store = useMainStore(); const result = await useMainStore().getPartsOrQuestions();
const result = await store.getPartsOrQuestions();
const partsOrQuestions = result.data.partsOrQuestions; const partsOrQuestions = result.data.partsOrQuestions;
vehicleQuestionsMixin.methods.navigateForward(partsOrQuestions, this); vehicleQuestionsMixin.methods.navigateForward(partsOrQuestions, this);

View file

@ -1,16 +1,8 @@
import vinPagesMixin from "@/mixins/vin-pages-mixin"; import vinPagesMixin from "@/mixins/vin-pages-mixin";
import { shallowMount } from "@vue/test-utils"; import { shallowMount } from "@vue/test-utils";
import { setupMocksForJsFiles, getMountOptions } from "@/helpers/unit-test-helper.js"; import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { storeActions } from "@/constants/store-actions";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin"; import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { useMainStore } from "@/store";
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
navigateForward: jest.fn(),
}));
jest.mock("@/helpers/heritage-integration/order-helper.js", () => ({
saveSession: jest.fn(),
}));
describe("vin-pages-mixin", () => { describe("vin-pages-mixin", () => {
afterEach(() => { afterEach(() => {
@ -20,6 +12,7 @@ describe("vin-pages-mixin", () => {
describe("navigateForwardWithSingleCarMatch", () => { describe("navigateForwardWithSingleCarMatch", () => {
test("should navigateForward", async () => { test("should navigateForward", async () => {
// Arrange // Arrange
useMainStore().getPartsOrQuestions = () => { return { data: {partsOrQuestions: {}}} };
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
vehicleQuestionsMixin.methods.navigateForward = jest.fn(); vehicleQuestionsMixin.methods.navigateForward = jest.fn();
@ -32,36 +25,15 @@ describe("vin-pages-mixin", () => {
}); });
}); });
function setupMocks({ partsOrQuestions = [] }) { function setupMocks() {
const baseMixin = setupMocksForJsFiles({
actionList: [
{
actionName: storeActions.GET_PARTS_OR_QUESTIONS,
data: {
partsOrQuestions: partsOrQuestions,
},
},
],
});
const mocks = getMountOptions({ const mocks = getMountOptions({
router: { router: {
navigate: jest.fn(), navigate: jest.fn(),
navigateWithSaving: jest.fn(),
navigateWithoutSaving: jest.fn(),
},
store: {
commit: jest.fn(),
getters: {
applicationUser: {
savedSessionId: 1,
},
},
}, },
}); });
const mockVinComponent = { const mockVinComponent = {
mixins: [vinPagesMixin, baseMixin.baseMixin], mixins: [vinPagesMixin],
}; };
const wrapper = shallowMount(mockVinComponent, mocks); const wrapper = shallowMount(mockVinComponent, mocks);

View file

@ -255,21 +255,57 @@ const routingTable = function(store) {
destinationIssPageValue: issPageValues.QUOTE, destinationIssPageValue: issPageValues.QUOTE,
}, },
], ],
}, },
{ {
issPageValue: issPageValues.WELCOME_PAGE, issPageValue: issPageValues.ADDRESS_LOOKUP,
maps: [ maps: [
{ {
scenario: navigationScenarios.CLICKED_BACK, scenario: navigationScenarios.CLICKED_BACK,
destinationIssPageValue: issPageValues.WELCOME_PAGE destinationIssPageValue: issPageValues.VEHICLE_LOOKUP,
}, },
{ {
scenario: navigationScenarios.WELCOME_PAGE, scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS 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
},
],
},
]; ];
}; };

View file

@ -42,6 +42,14 @@ const getDefaultState = () => {
capabilityQuestionAnswers: null, capabilityQuestionAnswers: null,
}, },
customer: { customer: {
address: {
streetAddress: null,
city: null,
state: null,
zipCode: null,
},
firstName: null,
lastName: null,
emailAddress: null, emailAddress: null,
}, },
serviceLocation: { serviceLocation: {
@ -110,6 +118,35 @@ export const useMainStore = defineStore({
pageData: (state) => (page) => { pageData: (state) => (page) => {
return state.applicationUser.pageData[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) => { experimentOrder: (state) => {
return { return {
issVehicleYear: state.order.vehicle.year, issVehicleYear: state.order.vehicle.year,

View file

@ -157,4 +157,66 @@ describe("Store", () => {
expect(store.order.damage.numberOfChips).toEqual(null); 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);
});
}); });