updates
This commit is contained in:
parent
ac1bad19ad
commit
de0add665c
6 changed files with 57 additions and 156 deletions
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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 store from "@/store";
|
||||||
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(),
|
||||||
|
|
@ -49,8 +43,6 @@ describe("address-lookup.vue", () => {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress,
|
addressQuestions: mockRegistrationAddress,
|
||||||
|
|
@ -63,7 +55,8 @@ describe("address-lookup.vue", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe(true);
|
expect(wrapper.findComponent({ ref: "alertNonServiceableZip" }).isVisible()).toBe(true);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
/*
|
||||||
test("if the address matches a different vehicle display the Matched Different VehicleAlert", async () => {
|
test("if the address matches a different vehicle display the Matched Different VehicleAlert", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mockRegistrationAddress = {
|
const mockRegistrationAddress = {
|
||||||
|
|
@ -182,8 +175,9 @@ 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", () => {
|
||||||
test("if the back button is clicked, navigate back", async () => {
|
test("if the back button is clicked, navigate back", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -195,7 +189,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 () => {
|
||||||
|
|
@ -291,7 +285,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,
|
||||||
{},
|
{},
|
||||||
|
|
@ -380,7 +374,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,
|
||||||
{},
|
{},
|
||||||
|
|
@ -634,6 +628,7 @@ describe("address-lookup.vue", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
|
|
@ -644,50 +639,52 @@ function setupMocks({
|
||||||
isStatePermissible = true,
|
isStatePermissible = true,
|
||||||
vinVehicles = [],
|
vinVehicles = [],
|
||||||
carId = "C0000",
|
carId = "C0000",
|
||||||
}) {
|
})
|
||||||
store.commit(storeMutations.RESET_STATE);
|
{
|
||||||
|
/*
|
||||||
|
useMainStore().validateZip = jest.fn().mockImplementation(() => {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: {
|
||||||
|
isValid: isZipValid,
|
||||||
|
isServiceable: isZipServiceable,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
useMainStore().LOOKUP_VIN_BY_ADDRESS = 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: [
|
|
||||||
{
|
|
||||||
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: {
|
||||||
|
|
@ -723,8 +720,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 };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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({});
|
||||||
|
|
@ -57,28 +32,7 @@ describe("address-questions.vue", () => {
|
||||||
expect(state.exists()).toBe(true);
|
expect(state.exists()).toBe(true);
|
||||||
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,8 +444,7 @@ 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,
|
||||||
router: {
|
router: {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,6 @@ import { setupMocksForJsFiles, getMountOptions } from "@/helpers/unit-test-helpe
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
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(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe("vin-pages-mixin", () => {
|
describe("vin-pages-mixin", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue