Lookup Pages

This commit is contained in:
Chloe Herd 2023-09-19 12:22:56 -04:00
parent 2bec4fa045
commit 5ff14add7b
12 changed files with 141 additions and 50 deletions

View file

@ -54,10 +54,11 @@ export function includesWindshieldReplacement() {
return windshieldMatches.length > 0; return windshieldMatches.length > 0;
} }
export async function isGlassAvailableForCarId(carId) { export async function isGlassAvailableForCarId(carId, pageNameToLog) {
const newGlassOptions = await baseMixin.methods.dispatchStoreAction( const newGlassOptions = await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_DAMAGE_OPTIONS, storeActions.GET_DAMAGE_OPTIONS,
{ carId: carId } { carId: carId },
pageNameToLog
); );
const currentGlassOptions = store.getters.damage.glassToReplace; const currentGlassOptions = store.getters.damage.glassToReplace;

View file

@ -11,6 +11,13 @@ jest.mock("@/mixins/base-mixin.js", () => ({
}, },
}; };
}), }),
dispatchStoreActionWithLogging: jest.fn().mockImplementation(() => {
return {
data: {
windshieldOptions: { availableReplacementOptions: ["windshield"] },
},
};
}),
}, },
})); }));
@ -77,7 +84,7 @@ describe("damage-helper.js", () => {
]; ];
// Act // Act
const isGlassAvailable = await isGlassAvailableForCarId(); const isGlassAvailable = await isGlassAvailableForCarId("id", "testName");
// Assert // Assert
expect(isGlassAvailable).toEqual(true); expect(isGlassAvailable).toEqual(true);
@ -91,7 +98,7 @@ describe("damage-helper.js", () => {
{ glassLocation: "Windshield", glassName: "sideWindow" }, { glassLocation: "Windshield", glassName: "sideWindow" },
]; ];
const isGlassAvailable = await isGlassAvailableForCarId(); const isGlassAvailable = await isGlassAvailableForCarId("id", "testName");
// Assert // Assert
expect(isGlassAvailable).toEqual(false); expect(isGlassAvailable).toEqual(false);

View file

@ -44,6 +44,16 @@ export function getMountOptions(mockData) {
}); });
} }
}); });
mocks.dispatchStoreActionWithLogging = jest.fn();
mocks.dispatchStoreActionWithLogging.mockImplementation((actionName) => {
let actionFilterResult = mockData.actionList?.filter((x) => x.actionName == actionName);
if (actionFilterResult?.length === 1) {
return Promise.resolve({
data: actionFilterResult[0].data,
});
}
});
// Mock const files // Mock const files
mocks.storeActions = storeActions; mocks.storeActions = storeActions;
@ -141,5 +151,16 @@ function setupBaseMixinDispatchStoreAction(mockData) {
}); });
} }
}); });
baseMixin.methods.dispatchStoreActionWithLogging = jest.fn();
baseMixin.methods.dispatchStoreActionWithLogging.mockImplementation((actionName) => {
let actionFilterResult = mockData.actionList.filter((x) => x.actionName == actionName);
if (actionFilterResult.length > 0 && actionFilterResult.length === 1) {
return Promise.resolve({
data: actionFilterResult[0].data,
});
}
});
} }
} }

View file

@ -471,7 +471,7 @@ describe("address-lookup.vue", () => {
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith( expect(wrapper.vm.dispatchStoreActionWithLogging).toHaveBeenCalledWith(
"lookupVinByAddress", "lookupVinByAddress",
{ {
licenseLastName: undefined, licenseLastName: undefined,
@ -479,12 +479,17 @@ describe("address-lookup.vue", () => {
licenseStreetAddress: "1234 Main St", licenseStreetAddress: "1234 Main St",
licenseZip: "43215", licenseZip: "43215",
}, },
"address-lookup",
false false
); );
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith("validateZip", { expect(wrapper.vm.dispatchStoreActionWithLogging).toHaveBeenCalledWith(
"validateZip",
{
zip: "43215", zip: "43215",
}); },
"address-lookup"
);
}); });
}); });

View file

@ -207,7 +207,7 @@ export default {
// Vehicle info change in the flow, use a variable to keep track and commit to state at the end. // Vehicle info change in the flow, use a variable to keep track and commit to state at the end.
let vehicleInfoToCommit = {}; let vehicleInfoToCommit = {};
const vinLookupResponse = this.dispatchStoreAction( const vinLookupResponse = this.dispatchStoreActionWithLogging(
storeActions.LOOKUP_VIN_BY_ADDRESS, storeActions.LOOKUP_VIN_BY_ADDRESS,
{ {
licenseLastName: this.customerQuestions.lastName, licenseLastName: this.customerQuestions.lastName,
@ -215,6 +215,7 @@ export default {
licenseZip: this.customerQuestions.addressQuestions.zipCode, licenseZip: this.customerQuestions.addressQuestions.zipCode,
licenseState: this.customerQuestions.addressQuestions.state, licenseState: this.customerQuestions.addressQuestions.state,
}, },
"address-lookup",
false false
); );
@ -227,12 +228,20 @@ export default {
{ {
resultKey: "serviceZipValidationResponse", resultKey: "serviceZipValidationResponse",
promise: this.serviceZipCode promise: this.serviceZipCode
? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { ? this.dispatchStoreActionWithLogging(
storeActions.VALIDATE_ZIP,
{
zip: this.serviceZipCode, zip: this.serviceZipCode,
}) },
: this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { "address-lookup"
)
: this.dispatchStoreActionWithLogging(
storeActions.VALIDATE_ZIP,
{
zip: this.customerQuestions.addressQuestions.zipCode, zip: this.customerQuestions.addressQuestions.zipCode,
}), },
"address-lookup"
),
}, },
]; ];
@ -267,7 +276,8 @@ export default {
this.displayMatchedDifferentVehicleAlert = true; this.displayMatchedDifferentVehicleAlert = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId( this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(
carFound.carId carFound.carId,
"address-lookup"
); );
// Update button "Continue with..." // Update button "Continue with..."

View file

@ -162,9 +162,13 @@ export default {
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
async forwardButtonAction() { async forwardButtonAction() {
const vinLookup = await this.dispatchStoreAction(storeActions.LOOKUP_VEHICLE_BY_VIN, { const vinLookup = await this.dispatchStoreActionWithLogging(
storeActions.LOOKUP_VEHICLE_BY_VIN,
{
vin: this.selectedVehicle.vin, vin: this.selectedVehicle.vin,
}).catch(() => { },
"address-vehicles"
).catch(() => {
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
}); });
@ -173,7 +177,8 @@ export default {
} }
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId( this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(
vinLookup.data.carId vinLookup.data.carId,
"address-vehicles"
); );
await this.dispatchStoreAction( await this.dispatchStoreAction(

View file

@ -120,7 +120,7 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ""); wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
wrapper.vm.navigateForward = jest.fn(); wrapper.vm.navigateForward = jest.fn();
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => wrapper.vm.dispatchStoreActionWithLogging = jest.fn().mockImplementation(() =>
Promise.resolve({ Promise.resolve({
data: { data: {
vehicle: { vehicle: {
@ -157,7 +157,7 @@ describe("license-plate-lookup.vue", () => {
}); });
// Mock store action call // Mock store action call
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => wrapper.vm.dispatchStoreActionWithLogging = jest.fn().mockImplementation(() =>
Promise.resolve({ Promise.resolve({
data: { data: {
vehicle: { vehicle: {
@ -201,7 +201,7 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.navigateForward = jest.fn(); wrapper.vm.navigateForward = jest.fn();
// Mock store action call // Mock store action call
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => wrapper.vm.dispatchStoreActionWithLogging = jest.fn().mockImplementation(() =>
Promise.resolve({ Promise.resolve({
data: { data: {
vehicle: { vehicle: {
@ -242,7 +242,7 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => { wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
return ""; return "";
}); });
wrapper.vm.dispatchStoreAction = jest.fn(); wrapper.vm.dispatchStoreActionWithLogging = jest.fn();
await wrapper.vm.navigateForward(); await wrapper.vm.navigateForward();
@ -379,7 +379,7 @@ describe("license-plate-lookup.vue", () => {
return { data: { vehicle: { carId: "C00000" } } }; return { data: { vehicle: { carId: "C00000" } } };
}); });
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => wrapper.vm.dispatchStoreActionWithLogging = jest.fn().mockImplementation(() =>
Promise.resolve({ Promise.resolve({
data: { data: {
vehicle: { vehicle: {
@ -417,7 +417,7 @@ describe("license-plate-lookup.vue", () => {
await wrapper.setData({ registrationZip: "00000" }); await wrapper.setData({ registrationZip: "00000" });
navigateToHeritage.navigateToHeritageFunnel = jest.fn(); navigateToHeritage.navigateToHeritageFunnel = jest.fn();
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => wrapper.vm.dispatchStoreActionWithLogging = jest.fn().mockImplementation(() =>
Promise.resolve({ Promise.resolve({
data: { data: {
vehicle: { vehicle: {
@ -449,7 +449,7 @@ describe("license-plate-lookup.vue", () => {
await wrapper.setData({ registrationZipCode: "00000" }); await wrapper.setData({ registrationZipCode: "00000" });
navigateToHeritage.navigateToHeritageFunnel = jest.fn(); navigateToHeritage.navigateToHeritageFunnel = jest.fn();
wrapper.vm.dispatchStoreAction = jest.fn().mockImplementation(() => wrapper.vm.dispatchStoreActionWithLogging = jest.fn().mockImplementation(() =>
Promise.resolve({ Promise.resolve({
data: { data: {
vehicle: { vehicle: {

View file

@ -199,9 +199,10 @@ export default {
async forwardButtonAction() { async forwardButtonAction() {
this.resetWarningsAndErrors(); this.resetWarningsAndErrors();
const registrationZipValidationResponse = this.dispatchStoreAction( const registrationZipValidationResponse = this.dispatchStoreActionWithLogging(
storeActions.VALIDATE_ZIP, storeActions.VALIDATE_ZIP,
{ zip: this.registrationZipCode } { zip: this.registrationZipCode },
"license-plate-lookup"
); );
// Settle promises and get results // Settle promises and get results
@ -214,9 +215,13 @@ export default {
// If serviceZipCode is not set, then sets the response to the registrationZipValidationResponse. Calls VALIDATE_ZIP if the serviceZipCode is set. // If serviceZipCode is not set, then sets the response to the registrationZipValidationResponse. Calls VALIDATE_ZIP if the serviceZipCode is set.
resultKey: "serviceZipValidationResponse", resultKey: "serviceZipValidationResponse",
promise: this.serviceZipCode promise: this.serviceZipCode
? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { ? this.dispatchStoreActionWithLogging(
storeActions.VALIDATE_ZIP,
{
zip: this.serviceZipCode, zip: this.serviceZipCode,
}) },
"license-plate-lookup"
)
: registrationZipValidationResponse, : registrationZipValidationResponse,
}, },
]; ];
@ -260,7 +265,8 @@ export default {
this.displayMatchedDifferentVehicleAlert = true; this.displayMatchedDifferentVehicleAlert = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId( this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(
vinLookup.data.vehicle.carId vinLookup.data.vehicle.carId,
"license-plate-lookup"
); );
// Update button "Continue with..." // Update button "Continue with..."
@ -312,9 +318,10 @@ export default {
return await this.navigateForward(); return await this.navigateForward();
}, },
lookupVin(plate, state) { lookupVin(plate, state) {
return this.dispatchStoreAction( return this.dispatchStoreActionWithLogging(
storeActions.LOOKUP_VIN_BY_PLATE, storeActions.LOOKUP_VIN_BY_PLATE,
{ licensePlate: plate, licenseState: state }, { licensePlate: plate, licenseState: state },
"license-plate-lookup",
false false
); );
}, },

View file

@ -255,9 +255,10 @@ export default {
// If this is a new VIN Lookup, do both a Vehicle Lookup and a Zip Validation // If this is a new VIN Lookup, do both a Vehicle Lookup and a Zip Validation
if (!this.vinPopulatedOnPageLoad) { if (!this.vinPopulatedOnPageLoad) {
const vehicleLookupResponse = this.dispatchStoreAction( const vehicleLookupResponse = this.dispatchStoreActionWithLogging(
storeActions.LOOKUP_VEHICLE_BY_VIN, storeActions.LOOKUP_VEHICLE_BY_VIN,
{ vin: this.vin } { vin: this.vin },
"vin-lookup"
); );
// Settle promises and get results // Settle promises and get results
@ -311,7 +312,8 @@ export default {
this.displayMatchedDifferentVehicleAlert = true; this.displayMatchedDifferentVehicleAlert = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId( this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(
resultMap.vehicleLookupResponse.carId resultMap.vehicleLookupResponse.carId,
"vin-lookup"
); );
// Update button "Continue with..." // Update button "Continue with..."
@ -399,7 +401,11 @@ export default {
}, },
getVinFromImage(image) { getVinFromImage(image) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_IMAGE, image) this.dispatchStoreActionWithLogging(
storeActions.LOOKUP_VIN_BY_IMAGE,
image,
"vin-lookup"
)
.then((response) => { .then((response) => {
if (response.data.length > 0) { if (response.data.length > 0) {
resolve(response.data[0]); resolve(response.data[0]);

View file

@ -64,9 +64,12 @@ export default {
return footerInfoBox ? footerInfoBox.offsetHeight : 0; return footerInfoBox ? footerInfoBox.offsetHeight : 0;
}, },
async getZipCodeData(zipCode) { async getZipCodeData(zipCode) {
const serviceZipValidationResponse = await this.dispatchStoreAction( const pageName = this.$options?.name;
const serviceZipValidationResponse = await this.dispatchStoreActionWithLogging(
storeActions.VALIDATE_ZIP, storeActions.VALIDATE_ZIP,
{ zip: zipCode } { zip: zipCode },
pageName
); );
return { return {

View file

@ -661,17 +661,19 @@ export const actions = {
}); });
}, },
lookupVehicleByVin(context, { vin }) { lookupVehicleByVin(context, { payload: { vin }, pageNameToLog }) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
method: endpoints.LookupVehicleByVin.method, method: endpoints.LookupVehicleByVin.method,
endpoint: endpoints.LookupVehicleByVin.url, endpoint: endpoints.LookupVehicleByVin.url,
payload: { payload: {
vin: vin, // EX "1J4GW58S4XC541166" vin: vin, // EX "1J4GW58S4XC541166"
}, },
logApiCall: true,
pageNameToLog: pageNameToLog,
}); });
}, },
lookupVinByPlate(context, { licensePlate, licenseState }) { lookupVinByPlate(context, { payload: { licensePlate, licenseState }, pageNameToLog }) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
method: endpoints.LookupVinByPlate.method, method: endpoints.LookupVinByPlate.method,
endpoint: endpoints.LookupVinByPlate.url, endpoint: endpoints.LookupVinByPlate.url,
@ -679,12 +681,17 @@ export const actions = {
licensePlate: licensePlate, licensePlate: licensePlate,
licenseState: licenseState, licenseState: licenseState,
}, },
logApiCall: true,
pageNameToLog: pageNameToLog,
}); });
}, },
lookupVinByAddress( lookupVinByAddress(
context, context,
{ licenseLastName, licenseStreetAddress, licenseZip, licenseState } {
payload: { licenseLastName, licenseStreetAddress, licenseZip, licenseState },
pageNameToLog,
}
) { ) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
method: endpoints.LookupVinByAddress.method, method: endpoints.LookupVinByAddress.method,
@ -695,10 +702,14 @@ export const actions = {
licenseZip: licenseZip, licenseZip: licenseZip,
licenseState: licenseState, licenseState: licenseState,
}, },
logApiCall: true,
pageNameToLog: pageNameToLog,
}); });
}, },
lookupVinByImage(context, image) { lookupVinByImage(context, { payload, pageNameToLog }) {
const image = payload;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let reader = new FileReader(); let reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
@ -720,6 +731,8 @@ export const actions = {
method: endpoints.LookupVinByImage.method, method: endpoints.LookupVinByImage.method,
endpoint: endpoints.LookupVinByImage.url, endpoint: endpoints.LookupVinByImage.url,
payload: data, payload: data,
logApiCall: true,
pageNameToLog: pageNameToLog,
}); });
}); });
}, },
@ -790,10 +803,12 @@ export const actions = {
}); });
}, },
validateZip(context, { zip }) { validateZip(context, { payload: { zip }, pageNameToLog }) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
methods: endpoints.ValidateZip.method, methods: endpoints.ValidateZip.method,
endpoint: `${endpoints.ValidateZip.url}/${zip}`, endpoint: `${endpoints.ValidateZip.url}/${zip}`,
logApiCall: true,
pageNameToLog: pageNameToLog,
}); });
}, },

View file

@ -428,7 +428,10 @@ describe("Actions", () => {
}); });
// Assert // Assert
const response = await actions.lookupVinByPlate(context, "12345678901234567"); const response = await actions.lookupVinByPlate(context, {
payload: { licensePlate: "12345678901234567", licenseState: "OH" },
pageNameToLog: "test",
});
expect(response.data).toEqual({ carId: "C00000001" }); expect(response.data).toEqual({ carId: "C00000001" });
}); });
@ -445,7 +448,10 @@ describe("Actions", () => {
}); });
// Act // Act
const response = await actions.lookupVinByImage(context, image); const response = await actions.lookupVinByImage(context, {
payload: image,
pageNameToLog: "test",
});
// Assert // Assert
expect(response.data).toEqual(["1C6JJTAG3NL134044"]); expect(response.data).toEqual(["1C6JJTAG3NL134044"]);
@ -465,7 +471,9 @@ describe("Actions", () => {
// Act // Act
// Assert // Assert
await expect(actions.lookupVinByImage(context, image)).rejects.toEqual("An error occurred"); await expect(
actions.lookupVinByImage(context, { payload: image, pageNameToLog: "test" })
).rejects.toEqual("An error occurred");
}); });
it("getVehicleMakes action, should return makes list", async () => { it("getVehicleMakes action, should return makes list", async () => {
@ -574,7 +582,10 @@ describe("Actions", () => {
}); });
}); });
const response = await actions.validateZip(context, "43212"); const response = await actions.validateZip(context, {
payload: { zip: "43212" },
pageNameToLog: "test",
});
// Assert // Assert
expect(response.data).toEqual({ expect(response.data).toEqual({