CSR-514 Fix merge conflicts

This commit is contained in:
Katie 2022-08-05 12:37:31 -04:00
commit 4de7240610
51 changed files with 1891 additions and 698 deletions

View file

@ -12,6 +12,8 @@ module.exports = {
"!src/router/**/*.js", "!src/router/**/*.js",
"!src/helpers/unit-test-helper.js", "!src/helpers/unit-test-helper.js",
"!src/layouts/vehicle-damage/windshield-options/windshield-options.vue", "!src/layouts/vehicle-damage/windshield-options/windshield-options.vue",
"!src/layouts/molding-questions/**/*.vue",
"!src/layouts/capability-questions/**/*.vue",
"!src/layouts/part-questions/**/*.vue", "!src/layouts/part-questions/**/*.vue",
"!src/layouts/reveal/**/*.vue", "!src/layouts/reveal/**/*.vue",
"!src/ux-components/text-link/**/*.vue", "!src/ux-components/text-link/**/*.vue",

View file

@ -7,6 +7,7 @@
<div class="w-100 d-flex justify-content-center"> <div class="w-100 d-flex justify-content-center">
<fieldset class="w-100" :aria-required=isRequired :class="getFieldSetClasses" :role="isMultiSelect ? 'group' : 'radiogroup'" :aria-labelledby="formattedGroupName"> <fieldset class="w-100" :aria-required=isRequired :class="getFieldSetClasses" :role="isMultiSelect ? 'group' : 'radiogroup'" :aria-labelledby="formattedGroupName">
<legend class="sr-only" :data-focus-target="formattedGroupName" :id="formattedGroupName" tabindex="-1"> <legend class="sr-only" :data-focus-target="formattedGroupName" :id="formattedGroupName" tabindex="-1">
{{ questionText }}
{{(isMultiSelect && answers && answers.length > 1) ? 'Select one or more options below.' : 'Select an option below.' }} {{(isMultiSelect && answers && answers.length > 1) ? 'Select one or more options below.' : 'Select an option below.' }}
</legend> </legend>
<div :class="getComponentLoopWrapperClasses" role="application"> <div :class="getComponentLoopWrapperClasses" role="application">
@ -35,8 +36,9 @@
data-test="button" data-test="button"
:validationRules="validationRules" :validationRules="validationRules"
:class="[suppressError ? 'alertError' : '']" :class="[suppressError ? 'alertError' : '']"
:valueToLogType="valueToLogType"
/> />
<!-- For nested questions --> <!-- For nested questions -->
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<div v-if="typeof selectedValues == 'string' && selectedValues == answer.Name"> <div v-if="typeof selectedValues == 'string' && selectedValues == answer.Name">
<slot></slot> <slot></slot>
@ -89,7 +91,8 @@ export default {
modelValue: [Array, String], modelValue: [Array, String],
validationRules: String, validationRules: String,
suppressError: Boolean, suppressError: Boolean,
useTextForValue: Boolean useTextForValue: Boolean,
valueToLogType: String,
}, },
computed: { computed: {
formattedGroupName() { formattedGroupName() {

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="menu-modal-container"> <div class="menu-modal-container">
<button class="menu-button" type="button" :class="[isActive ? 'active' : '']" data-bs-toggle="modal" data-bs-target="#footerModal"> <button class="menu-button" type="button" :class="[isActive ? 'active' : '']" data-bs-toggle="modal" data-bs-target="#footerModal" aria-label="Hamburger Menu (modal window)">
<div class="bar1"></div> <div class="bar1"></div>
<div class="bar2"></div> <div class="bar2"></div>
<div class="bar3"></div> <div class="bar3"></div>

View file

@ -13,6 +13,7 @@
:aria-disabled="isDisabled" :aria-disabled="isDisabled"
:disabled="isDisabled" :disabled="isDisabled"
:aria-required="isRequired" :aria-required="isRequired"
:aria-label="questionText"
:class="[hasIcon ? 'has-icon' : '', iconRight ? 'icon-right' : '']" :class="[hasIcon ? 'has-icon' : '', iconRight ? 'icon-right' : '']"
:validationRules="validationRules" :validationRules="validationRules"
@change="handleChange" @change="handleChange"

View file

@ -29,5 +29,8 @@ const GaLabels = {
ADDRESS_LOOKUP: 'Address_Look_up', ADDRESS_LOOKUP: 'Address_Look_up',
}; };
const ValueToLogTypes = {
LAST_5: "last_5",
};
export { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents}; export { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents, ValueToLogTypes };

View file

@ -0,0 +1,3 @@
export const headerKeys = {
EXPERIMENT: "X-Experiment-Data"
}

View file

@ -32,6 +32,7 @@ const storeActions = {
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
RUN_EXPERIMENTS_FOR_TRIGGER: "runExperimentsForTrigger", RUN_EXPERIMENTS_FOR_TRIGGER: "runExperimentsForTrigger",
CLEAR_VIN: "clearVin", CLEAR_VIN: "clearVin",
RESET_SAVE_ORDER_PROMISE: "resetSaveOrderPromise",
// DEPENDENCY MUTATIONS // DEPENDENCY MUTATIONS
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",

View file

@ -39,7 +39,7 @@ const storeMutations = {
UPDATE_REFERRAL_DATE: "updateReferralDate", UPDATE_REFERRAL_DATE: "updateReferralDate",
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId", UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber", UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber",
UPDATE_SAVE_QUOTE_ID: "updateSaveQuoteId", UPDATE_SAVED_SESSION_ID: "updateSavedSessionId",
UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId", UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId",
// EVENT BUS MUTATIONS // EVENT BUS MUTATIONS
@ -52,6 +52,7 @@ const storeMutations = {
RESET_REGISTRATION_STATE: "resetRegistrationState", RESET_REGISTRATION_STATE: "resetRegistrationState",
RESET_GLASS_PARTS_STATE: "resetGlassPartsState", RESET_GLASS_PARTS_STATE: "resetGlassPartsState",
RESET_STATE: "resetState", RESET_STATE: "resetState",
RESET_SAVE_ORDER_PROMISE: "resetSaveOrderPromise",
// OTHER MUTATIONS // OTHER MUTATIONS
UPDATE_PAGE_DATA: "updatePageData", UPDATE_PAGE_DATA: "updatePageData",
@ -61,7 +62,7 @@ const storeMutations = {
// EXPERIMENT MUTATIONS // EXPERIMENT MUTATIONS
UPDATE_EXPERIMENTS: "updateExperiments", UPDATE_EXPERIMENTS: "updateExperiments",
UPDATE_TRIGGERED_SITE_ENTRY: "updateTriggeredSiteEntry" UPDATE_TRIGGERED_SITE_ENTRY: "updateTriggeredSiteEntry",
}; };
export { storeMutations }; export { storeMutations };

View file

@ -1,16 +1,24 @@
import axios from "axios"; import axios from "axios";
import analyticsMixIn from "@/mixins/analytics-mixin.js"; import analyticsMixIn from "@/mixins/analytics-mixin.js";
import store from "@/store";
import { applicationConfig } from "@/constants/application-config.js"; import { applicationConfig } from "@/constants/application-config.js";
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics"; import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
import { headerKeys } from "@/constants/header-keys";
export default { export default {
callHttpClient({ method, endpoint, payload, logApiCall = true }) { callHttpClient({ method, endpoint, payload, logApiCall = true }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" });
const headers = {
[headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings)
}
axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {} }) if (endpoint.includes("/vehicle/"))
cfDistroUrl = "https://localhost:44331"
axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {}, headers: headers })
.then((response) => { .then((response) => {
if (logApiCall) { if (logApiCall) {

View file

@ -15,7 +15,7 @@ export function updateOrCreateFunnelCookie() {
// Set up cookie with all the props. // Set up cookie with all the props.
setFunnelCookieProperties({ setFunnelCookieProperties({
LastTouched: new Date().toUTCString(), LastTouched: new Date().toUTCString(),
SavedQuoteTimeoutDate: store.getters.applicationUser.savedSessionTimeout, SavedSessionTimeoutDate: store.getters.applicationUser.savedSessionTimeout,
DidHeritageFunnelUpdateLast: false, DidHeritageFunnelUpdateLast: false,
ShouldResetState: false, ShouldResetState: false,
ReferralNumber: store.getters.order.referralNumber, ReferralNumber: store.getters.order.referralNumber,

View file

@ -309,10 +309,10 @@ describe("navigateToHeritageFunnel", () => {
const mockCorrelationId = "55"; const mockCorrelationId = "55";
const mockReferralDate = "2022"; const mockReferralDate = "2022";
const mockAccountNumber = "167132"; const mockAccountNumber = "167132";
const mockSaveQuoteId = "xxx-xxx-xxx"; const mockSavedSessionId = "xxx-xxx-xxx";
const mockCrmCustomerId = "xxx-xxx-xxx" const mockCrmCustomerId = "xxx-xxx-xxx"
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSavedSessionId, mockCrmCustomerId);
const mockData = { const mockData = {
actionList: [{ actionList: [{
@ -344,10 +344,10 @@ describe("navigateToHeritageFunnel", () => {
const mockCorrelationId = "55"; const mockCorrelationId = "55";
const mockReferralDate = "2022"; const mockReferralDate = "2022";
const mockAccountNumber = "167132"; const mockAccountNumber = "167132";
const mockSaveQuoteId = "xxx-xxx-xxx"; const mockSavedSessionId = "xxx-xxx-xxx";
const mockCrmCustomerId = "xxx-xxx-xxx" const mockCrmCustomerId = "xxx-xxx-xxx"
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSavedSessionId, mockCrmCustomerId);
const mockData = { const mockData = {
actionList: [{ actionList: [{

View file

@ -60,6 +60,8 @@ export async function saveOrder() {
and returns the response. and returns the response.
*/ */
async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) { async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) {
// await the saveOrderPromise in the store to make sure we're loading up to date information
await store.getters.applicationUser.saveOrderPromise;
const response = await baseMixin.methods.dispatchStoreAction(storeActions.LOAD_ORDER, const response = await baseMixin.methods.dispatchStoreAction(storeActions.LOAD_ORDER,
{ {
referralNumber: referralNumber.toString(), referralNumber: referralNumber.toString(),
@ -82,7 +84,7 @@ async function saveOrderHelper() {
referralCorrelationId: savedOrderInfo.data.referralCorrelationId, referralCorrelationId: savedOrderInfo.data.referralCorrelationId,
referralDate: savedOrderInfo.data.referralDate, referralDate: savedOrderInfo.data.referralDate,
accountNumber: savedOrderInfo.data.accountNumber.toString(), accountNumber: savedOrderInfo.data.accountNumber.toString(),
saveQuoteId: savedOrderInfo.data.saveQuoteId, savedSessionId: savedOrderInfo.data.savedSessionId,
crmCustomerId: savedOrderInfo.data.crmCustomerId.toString(), crmCustomerId: savedOrderInfo.data.crmCustomerId.toString(),
}, false); }, false);

View file

@ -112,10 +112,10 @@ describe("saveOrder", () => {
const mockCorrelationId = "55"; const mockCorrelationId = "55";
const mockReferralDate = "2022"; const mockReferralDate = "2022";
const mockAccountNumber = "167132"; const mockAccountNumber = "167132";
const mockSaveQuoteId = "xxx-xxx-xxx"; const mockSavedSessionId = "xxx-xxx-xxx";
const mockCrmCustomerId = "xxx-xxx-xxx" const mockCrmCustomerId = "xxx-xxx-xxx"
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, mockAccountNumber, mockSavedSessionId, mockCrmCustomerId);
const mockData = { const mockData = {
actionList: [ actionList: [
@ -141,7 +141,7 @@ describe("saveOrder", () => {
referralDate: mockReferralDate, referralDate: mockReferralDate,
referralCorrelationId: mockCorrelationId, referralCorrelationId: mockCorrelationId,
accountNumber: mockAccountNumber, accountNumber: mockAccountNumber,
saveQuoteId: mockSaveQuoteId, savedSessionId: mockSavedSessionId,
crmCustomerId: mockCrmCustomerId, crmCustomerId: mockCrmCustomerId,
}, false); }, false);
}); });
@ -152,10 +152,10 @@ describe("saveOrder", () => {
const mockReferralDate = "2022-03-15T10:56:24.597"; const mockReferralDate = "2022-03-15T10:56:24.597";
const mockReferralCorrelationId = "404d2b04-f86e-45c3-b373-127b6217b060"; const mockReferralCorrelationId = "404d2b04-f86e-45c3-b373-127b6217b060";
const mockAccountNumber = "167132"; const mockAccountNumber = "167132";
const mockSaveQuoteId = "xxx-xxx-xxx"; const mockSavedSessionId = "xxx-xxx-xxx";
const mockCrmCustomerId = "xxx-xxx-xxx" const mockCrmCustomerId = "xxx-xxx-xxx"
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockReferralCorrelationId, mockReferralDate, mockAccountNumber, mockSaveQuoteId, mockCrmCustomerId); const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockReferralCorrelationId, mockReferralDate, mockAccountNumber, mockSavedSessionId, mockCrmCustomerId);
const mockData = { const mockData = {
actionList: [{ actionList: [{

View file

@ -28,7 +28,7 @@ export function isAnalyticsSessionStillActive() {
*/ */
export function isSavedSessionStillActive() { export function isSavedSessionStillActive() {
if (getFunnelCookie() !== null) { if (getFunnelCookie() !== null) {
const savedSessionTimeStamp = new Date(getFunnelCookie().SavedQuoteTimeoutDate); const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate);
const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp); const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp);
if (isSavedSessionTimedOut) { if (isSavedSessionTimedOut) {

View file

@ -41,7 +41,7 @@ describe("isSavedSessionStillActive", () => {
mockDate.setDate(mockDate.getDate() + 1); mockDate.setDate(mockDate.getDate() + 1);
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie") cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
.mockReturnValue({ SavedQuoteTimeoutDate: mockDate }); .mockReturnValue({ SavedSessionTimeoutDate: mockDate });
// Act // Act
const result = isSavedSessionStillActive(); const result = isSavedSessionStillActive();
@ -56,7 +56,7 @@ describe("isSavedSessionStillActive", () => {
mockDate.setDate(mockDate.getDate() - 1) mockDate.setDate(mockDate.getDate() - 1)
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie") cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie")
.mockReturnValue({ SavedQuoteTimeoutDate: mockDate }); .mockReturnValue({ SavedSessionTimeoutDate: mockDate });
// Act // Act
const result = isSavedSessionStillActive(); const result = isSavedSessionStillActive();

View file

@ -7,7 +7,7 @@ import { cookieNames } from "@/constants/cookie-names";
import { Form } from "vee-validate"; import { Form } from "vee-validate";
import baseMixin from "@/mixins/base-mixin"; import baseMixin from "@/mixins/base-mixin";
import { getCookieDomainValue } from "@/helpers/heritage-integration/cookie-helper"; import { getCookieDomainValue } from "@/helpers/heritage-integration/cookie-helper";
import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents } from "@/constants/analytics"; import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents, ValueToLogTypes } from "@/constants/analytics";
import { queryStrings } from "@/constants/query-strings"; import { queryStrings } from "@/constants/query-strings";
import { routerParams } from "@/router/router-constants/router-params"; import { routerParams } from "@/router/router-constants/router-params";
@ -48,6 +48,7 @@ export function getMountOptions(mockData) {
mocks.GaActions = GaActions; mocks.GaActions = GaActions;
mocks.GaLabels = GaLabels; mocks.GaLabels = GaLabels;
mocks.GaEvents = GaEvents; mocks.GaEvents = GaEvents;
mocks.ValueToLogTypes = ValueToLogTypes;
mocks.queryStrings = queryStrings; mocks.queryStrings = queryStrings;
mocks.routerParams = routerParams; mocks.routerParams = routerParams;
@ -90,13 +91,13 @@ export function removeAllTestCookies() {
}); });
} }
export function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, accountNumber = "0", saveQuoteId, crmCustomerId) { export function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate, accountNumber = "0", savedSessionId, crmCustomerId) {
return { return {
referralNumber: mockReferralNumber, referralNumber: mockReferralNumber,
referralCorrelationId: mockCorrelationId, referralCorrelationId: mockCorrelationId,
referralDate: mockReferralDate, referralDate: mockReferralDate,
accountNumber: accountNumber, accountNumber: accountNumber,
saveQuoteId: saveQuoteId, savedSessionId: savedSessionId,
crmCustomerId: crmCustomerId, crmCustomerId: crmCustomerId,
} }
} }

View file

@ -1,5 +1,7 @@
import { shallowMount } from "@vue/test-utils"; import { shallowMount } from "@vue/test-utils";
import addressVehiclesQuestion from "@/layouts/address-vehicles/address-vehicles-question/address-vehicles-question"; import addressVehiclesQuestion from "@/layouts/address-vehicles/address-vehicles-question/address-vehicles-question";
import { ValueToLogTypes } from "@/constants/analytics";
describe("addressVehiclesQuestion.vue", () => { describe("addressVehiclesQuestion.vue", () => {
@ -54,9 +56,15 @@ const mockMixin = {
return 'FoundWindshieldTestReturn'; return 'FoundWindshieldTestReturn';
} }
return null; return null;
}), }),
vehicles: jest.fn(() => { vehicles: jest.fn(() => {
return [{ vehicle: "test" }]; return [{ vehicle: "test" }];
}) })
} },
computed: {
ValueToLogTypes() {
return ValueToLogTypes;
}
},
} }

View file

@ -8,6 +8,7 @@
v-model="selectedVehicleVinAsArray" v-model="selectedVehicleVinAsArray"
isRequired isRequired
:validation-rules="validationRules" :validation-rules="validationRules"
:valueToLogType="ValueToLogTypes.LAST_5"
/> />
<alert ref="differentVehicleAlert" <alert ref="differentVehicleAlert"
v-if="isCarIdDifferent" v-if="isCarIdDifferent"

View file

@ -0,0 +1,165 @@
<template>
<Form
@submit="onSubmit"
@invalid-submit="onInvalidSubmit"
ref="theForm"
v-slot="{ meta }"
>
<div class="page-container-grouped-styles capability-questions">
<loadingModal ref="loadingModal"/>
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage=false />
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
<div class="fade-on-route-transition sub-container make-tall">
<h1>CAPABILITY QUESTIONS TEMPORARY PLACEHOLDER</h1>
<alert
ref="alertFewMoreQuestions"
class="my-5"
alertClass="alert-warning"
:manualHeadline="AlertFewMoreQuestionsHeader"
:manualCopy="AlertFewMoreQuestionsCopy"
v-bind:isDismissible="false"
/>
<div v-for="(part, i) in capabilityQuestionsData" :key="i">
<questionChain
ref="questionChain"
v-model="selectedModel"
:questionData="part"
:partIndex="i"
v-if="showThisPartQuestionChain(part, i)"
validationRules="questions-required"
/>
</div>
<funnel-footer
ref="funnelFooter"
cmsWidgetName="FunnelFooterWidget"
:isForwardActionDisabled="!meta.valid"
@back-clicked="backButtonAction"
@ForwardClicked="forwardButtonAction"
/>
</div>
</div>
</Form>
</template>
<script>
// Components
import funnelHeader from "@/common-components/funnel-header/funnel-header";
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
import alert from "@/ux-components/alert/alert";
import questionChain from "@/common-components/question-chain/question-chain";
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
// Supporting Files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import store from "@/store";
import { storeActions } from "@/constants/store-actions";
import { storeMutations } from "@/constants/store-mutations";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { Form, defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages";
// DEFINE VALIDATION RULES
defineRule("questions-required", required(errorMessages.OPTION_REQUIRED));
export default {
name: "capability-questions",
async beforeRouteEnter(to, from, next) {
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
// Settle promises and get results
const promiseResultMap = [
{
resultKey: "cmsContent",
promise: cmsContentPromise,
},
];
const resultMap = await settleAllPromises(promiseResultMap);
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
});
},
data() {
return {
selectedModel: [],
partsQuestionsData: this.$store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS).partsOrQuestions.filter((p) => {
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
return {
glassName: p.glassName,
glassLocation: p.glassLocation,
partQuestions: p.partQuestions,
};
}
}),
currentPartNum: 0,
};
},
computed: {
AlertFewMoreQuestionsHeader() {
return this.getCmsContent("AlertPartsQuestions", "HeadlineText");
},
AlertFewMoreQuestionsCopy() {
return this.getCmsContent("AlertPartsQuestions", "BodyText");
},
},
methods: {
arePagePrerequisitesValid() {
return true; // TODO - DO TRUE TEST OF PAGEDATA
// return Object.keys(store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS)).length > 0;
},
showThisPartQuestionChain(part, i) {
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
if (this.currentPartNum === i || part.answerData?.answerResult.length > 0) { return true; }
return false;
},
backButtonAction() {
// route to move backwards
this.$router.navigate(
this.navigationScenarios.CLICKED_BACK,
this.$route
);
},
async forwardButtonAction() {
// TODO: TO COME
},
},
watch: {
selectedModel(model) {
this.capabilityQuestionsData[model.partIndex].answerData = {
answerResult: model.answerResult,
answeredQuestions: model.answeredQuestions,
}
this.currentPartNum = model.partIndex + 1;
},
},
components: {
funnelHeader,
vehicleBanner,
alert,
questionChain,
funnelSubHeader,
funnelFooter,
loadingModal,
Form,
},
};
</script>
<style lang="scss">
.capability-questions {
.question-text {
margin-bottom: .5rem;
span {
text-align: left;
}
}
}
</style>

View file

@ -235,7 +235,7 @@ describe("license-plate-lookup.vue", () => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
}); });
test("navigateToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => { test("navigateForwardWithSingleCarMatch should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -247,11 +247,11 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => { wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
return ''; return '';
}); });
navigateToHeritage.navigateToHeritageFunnel = jest.fn(); wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
await wrapper.vm.navigateForward(); await wrapper.vm.navigateForward();
//Assert //Assert
expect(navigateToHeritage.navigateToHeritageFunnel).toHaveBeenCalled(); expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalled();
}); });
test("carId matches returned vehicle => navigateForwardWithSingleCarMatch", async () => { test("carId matches returned vehicle => navigateForwardWithSingleCarMatch", async () => {

View file

@ -0,0 +1,202 @@
<template>
<Form
@submit="onSubmit"
@invalid-submit="onInvalidSubmit"
ref="theForm"
v-slot="{ meta }"
>
<div class="page-container-grouped-styles molding-questions">
<loadingModal ref="loadingModal"/>
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage=false />
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
<div class="fade-on-route-transition sub-container make-tall">
<h1>MOLDING QUESTIONS TEMPORARY PLACEHOLDER</h1>
<alert
ref="alertFewMoreQuestions"
class="my-5"
alertClass="alert-warning"
:manualHeadline="AlertFewMoreQuestionsHeader"
:manualCopy="AlertFewMoreQuestionsCopy"
v-bind:isDismissible="false"
/>
<div v-for="(part, i) in moldingQuestionsData" :key="i">
<questionChain
ref="questionChain"
v-model="selectedModel"
:questionData="part"
:partIndex="i"
v-if="showThisPartQuestionChain(part, i)"
validationRules="questions-required"
/>
</div>
<funnel-footer
ref="funnelFooter"
cmsWidgetName="FunnelFooterWidget"
:isForwardActionDisabled="!meta.valid"
@back-clicked="backButtonAction"
@ForwardClicked="forwardButtonAction"
/>
</div>
</div>
</Form>
</template>
<script>
// Components
import funnelHeader from "@/common-components/funnel-header/funnel-header";
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
import alert from "@/ux-components/alert/alert";
import questionChain from "@/common-components/question-chain/question-chain";
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
// Supporting Files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import store from "@/store";
import { storeActions } from "@/constants/store-actions";
import { storeMutations } from "@/constants/store-mutations";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { Form, defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
// DEFINE VALIDATION RULES
defineRule("questions-required", required(errorMessages.OPTION_REQUIRED));
export default {
name: "molding-questions",
mixins: [vehicleQuestionsMixin],
async beforeRouteEnter(to, from, next) {
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
// Settle promises and get results
const promiseResultMap = [
{
resultKey: "cmsContent",
promise: cmsContentPromise,
},
];
const resultMap = await settleAllPromises(promiseResultMap);
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
});
},
data() {
return {
selectedModel: [],
partsQuestionsData: this.$store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS).partsOrQuestions.filter((p) => {
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
return {
glassName: p.glassName,
glassLocation: p.glassLocation,
partQuestions: p.partQuestions,
};
}
}),
currentPartNum: 0,
};
},
computed: {
AlertFewMoreQuestionsHeader() {
return this.getCmsContent("AlertPartsQuestions", "HeadlineText");
},
AlertFewMoreQuestionsCopy() {
return this.getCmsContent("AlertPartsQuestions", "BodyText");
},
},
methods: {
arePagePrerequisitesValid() {
return true; // TODO - DO TRUE TEST OF PAGEDATA
// return Object.keys(store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS)).length > 0;
},
showThisPartQuestionChain(part, i) {
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
if (this.currentPartNum === i || part.answerData?.answerResult.length > 0) { return true; }
return false;
},
backButtonAction() {
// route to move backwards
this.$router.navigate(
this.navigationScenarios.CLICKED_BACK,
this.$route
);
},
async forwardButtonAction() {
const partQuestionAnswersArray = this.partsQuestionsData.map((item) => {
return {
glassLocation: item.glassLocation,
glassName: item.glassName,
result: item.answerData.answerResult,
answeredQuestions: item.answerData.answeredQuestions,
};
});
// save to vuex store as order.damage.partQuestionAnswers (array)
await this.dispatchStoreAction(this.storeActions.SAVE_PART_QUESTION_ANSWERS, partQuestionAnswersArray, false);
// call API parts method
const partsLookup = await this.dispatchStoreAction(storeActions.GET_PARTS)
.catch(() => {
return this.$refs.funnelFooter.removeLoader();
});
const glassNameAndPartsForStore = partsLookup.data.glassNameAndPartsForStore;
const hasCapabilityQuestions = this.hasCapabilityQuestions(glassNameAndPartsForStore);
if (hasCapabilityQuestions) {
// if has capability questions
// go to capability-questions page
this.$router.navigate(this.navigationScenarios.HAS_CAPABILITY_QUESTIONS,this.$route,{},{},{partsOrQuestions: glassNameAndPartsForStore});
} else {
// if single parts only
const collectedGlassParts = this.reducedGlassPartsArray(glassNameAndPartsForStore);
// save to store lineItems.glassParts
this.$store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
// go to heritage quote page
this.$refs.loadingModal.showModal();
navigateToHeritageFunnel();
}
},
},
watch: {
selectedModel(model) {
this.moldingQuestionsData[model.partIndex].answerData = {
answerResult: model.answerResult,
answeredQuestions: model.answeredQuestions,
}
this.currentPartNum = model.partIndex + 1;
},
},
components: {
funnelHeader,
vehicleBanner,
alert,
questionChain,
funnelSubHeader,
funnelFooter,
loadingModal,
Form,
},
};
</script>
<style lang="scss">
.molding-questions {
.question-text {
margin-bottom: .5rem;
span {
text-align: left;
}
}
}
</style>

View file

@ -6,12 +6,14 @@
v-slot="{ meta }" v-slot="{ meta }"
> >
<div class="page-container-grouped-styles part-questions"> <div class="page-container-grouped-styles part-questions">
<loadingModal ref="loadingModal"/>
<funnelHeader cmsWidgetName="FunnelHeaderWidget" /> <funnelHeader cmsWidgetName="FunnelHeaderWidget" />
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage=false /> <vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage=false />
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" /> <funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
<div class="fade-on-route-transition sub-container make-tall"> <div class="fade-on-route-transition sub-container make-tall">
<alert <alert
ref="alertFewMoreQuestions" ref="alertFewMoreQuestions"
cmsWidgetName="AlertFewMoreQuestionsWidget"
class="my-5" class="my-5"
alertClass="alert-warning" alertClass="alert-warning"
:manualHeadline="AlertFewMoreQuestionsHeader" :manualHeadline="AlertFewMoreQuestionsHeader"
@ -31,7 +33,7 @@
<funnel-footer <funnel-footer
ref="funnelFooter" ref="funnelFooter"
cmsWidgetName="FunnelFooterWidget" cmsWidgetName="FunnelFooterWidget"
:isForwardActionDisabled="waitingForLoad || !meta.valid" :isForwardActionDisabled="!meta.valid"
@back-clicked="backButtonAction" @back-clicked="backButtonAction"
@ForwardClicked="forwardButtonAction" @ForwardClicked="forwardButtonAction"
/> />
@ -48,6 +50,7 @@ import alert from "@/ux-components/alert/alert";
import questionChain from "@/common-components/question-chain/question-chain"; import questionChain from "@/common-components/question-chain/question-chain";
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header"; import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
import funnelFooter from "@/common-components/funnel-footer/funnel-footer"; import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
// Supporting Files // Supporting Files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
@ -59,6 +62,8 @@ import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { Form, defineRule } from "vee-validate"; import { Form, defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule("questions-required", required(errorMessages.OPTION_REQUIRED)); defineRule("questions-required", required(errorMessages.OPTION_REQUIRED));
@ -87,11 +92,16 @@ export default {
data() { data() {
return { return {
selectedModel: [], selectedModel: [],
partsQuestionsData: [], partsQuestionsData: this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions.filter((p) => {
waitingForLoad: true, if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
return {
glassName: p.glassName,
glassLocation: p.glassLocation,
partQuestions: p.partQuestions,
};
}
}),
currentPartNum: 0, currentPartNum: 0,
glassNameAndParts: [],
hasMultipleParts: false,
}; };
}, },
computed: { computed: {
@ -102,22 +112,7 @@ export default {
return this.getCmsContent("AlertPartsQuestions", "BodyText"); return this.getCmsContent("AlertPartsQuestions", "BodyText");
}, },
}, },
async mounted() { mixins: [vehicleQuestionsMixin],
const questionData = await this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS);
// Map API result data, to part-questions data structure
this.partsQuestionsData = questionData.partsOrQuestions.filter((p) => {
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
return {
glassName: p.glassName,
glassLocation: p.glassLocation,
partQuestions: p.partQuestions,
};
}
});
this.waitingForLoad = false;
},
methods: { methods: {
showThisPartQuestionChain(part, i) { showThisPartQuestionChain(part, i) {
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
@ -147,43 +142,36 @@ export default {
// call API parts method // call API parts method
const partsLookup = await this.dispatchStoreAction(storeActions.GET_PARTS) const partsLookup = await this.dispatchStoreAction(storeActions.GET_PARTS)
.catch(() => { .catch(() => {
this.$refs.funnelFooter.removeLoader(); return this.$refs.funnelFooter.removeLoader();
}); });
if (!partsLookup) { return } const glassNameAndPartsForStore = partsLookup.data.glassNameAndParts;
this.glassNameAndParts = partsLookup.data.glassNameAndParts; const hasGlassLocationWithMultipleParts = this.hasGlassLocationWithMultipleParts(glassNameAndPartsForStore);
const hasChildPartQuestions = this.hasChildPartQuestions(glassNameAndPartsForStore);
const hasCapabilityQuestions = this.hasCapabilityQuestions(glassNameAndPartsForStore);
// test response data for multiple parts // NAVIGATE FORWARD
this.hasMultipleParts = this.glassNameAndParts.some((glass) => glass.parts?.length > 1); if (hasGlassLocationWithMultipleParts) {
// loop through all glass items
const collectedGlassParts = [];
this.glassNameAndParts.forEach((glass) => {
if (Array.isArray(glass.parts) && glass.parts.length === 1) {
const singlePart = glass.parts[0];
collectedGlassParts.push({
"partNumber": singlePart.partNumber,
"description": singlePart.description,
"color": singlePart.color,
"requiresRecalibration": singlePart.requiresRecalibration,
"childParts": singlePart.childParts,
"price": singlePart.price,
})
}
});
store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
this.navigateForward();
},
async navigateForward() {
if (this.hasMultipleParts) {
// if multiple parts on any glass // if multiple parts on any glass
// go to vehicle-parts page and pass the partsData // go to vehicle-parts page and pass the partsData
this.$router.navigate(this.navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS,this.$route,{},{},{partsOrQuestions: this.glassNameAndParts}); this.$router.navigate(this.navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS,this.$route,{},{},{partsOrQuestions: glassNameAndPartsForStore});
} else if (hasChildPartQuestions) {
// if any childpart questions
// go to molding-questions page and pass the partsData
this.$router.navigate(this.navigationScenarios.HAS_MOLDING_QUESTIONS,this.$route,{},{},{partsOrQuestions: glassNameAndPartsForStore});
} else if (hasCapabilityQuestions) {
// if has capability questions
// go to capability-questions page and pass the partsData
this.$router.navigate(this.navigationScenarios.HAS_CAPABILITY_QUESTIONS,this.$route,{},{},{partsOrQuestions: glassNameAndPartsForStore});
} else { } else {
// if single parts only // if single parts only
// go to quote page const collectedGlassParts = this.reducedGlassPartsArray(glassNameAndPartsForStore);
this.$router.navigate(this.navigationScenarios.ANSWERED_QUESTIONS_WITH_SINGLE_PART,this.$route); // save to store lineItems.glassParts
this.$store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
// go to heritage quote page
this.$refs.loadingModal.showModal();
navigateToHeritageFunnel();
} }
}, },
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
@ -206,18 +194,19 @@ export default {
questionChain, questionChain,
funnelSubHeader, funnelSubHeader,
funnelFooter, funnelFooter,
loadingModal,
Form, Form,
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
.part-questions { .part-questions {
.question-text { .question-text {
margin-bottom: .5rem; margin-bottom: .5rem;
span { span {
text-align: left; text-align: left;
} }
} }
} }
</style> </style>

View file

@ -1,6 +1,6 @@
<template> <template>
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<div v-if="isAvailable && this.answersToDisplay.length > 0" class="replace-options-question" :class="this.answersToDisplay.length < 2 ? 'd-none' : ''" aria-live="polite"> <div v-if="shouldDisplayReplaceOptionsQuestion" class="replace-options-question" :class="this.answersToDisplay.length < 2 ? 'd-none' : ''" aria-live="polite">
<buttonQuestion <buttonQuestion
isWide isWide
:questionText="questionText" :questionText="questionText"
@ -80,11 +80,19 @@ export default ({
return ans; return ans;
}); });
}, },
shouldDisplayReplaceOptionsQuestion() {
return this.isAvailable && this.answersToDisplay.length > 0
}
}, },
watch: { watch: {
isAvailable(val) { isAvailable(val) {
// CHECK TO UPDATE SELECTED VALUES WHEN ISAVAILABLE IS TRUE // CHECK TO UPDATE SELECTED VALUES WHEN ISAVAILABLE IS TRUE
val && this.updateSelectedValues(); val && this.updateSelectedValues();
},
shouldDisplayReplaceOptionsQuestion(shouldDisplayReplaceOptionsQuestion) {
if (!shouldDisplayReplaceOptionsQuestion) {
this.selectedValues = [];
}
} }
}, },
components: { components: {

View file

@ -46,6 +46,7 @@ import store from "@/store";
import { defineRule } from "vee-validate"; import { defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { damageLocationsSelected } from "@/constants/damage-locations-selected";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule("damage-side-required", required(errorMessages.DAMAGE_SIDE_REQUIRED)); defineRule("damage-side-required", required(errorMessages.DAMAGE_SIDE_REQUIRED));
@ -112,7 +113,7 @@ export default ({
this.selectedValues = this.getSideDoorReplacementOptions(this.selectedValues.selectedDoorSides, this.selectedValues.selectedDriverSideReplaceOptions, newValue); this.selectedValues = this.getSideDoorReplacementOptions(this.selectedValues.selectedDoorSides, this.selectedValues.selectedDriverSideReplaceOptions, newValue);
} }
}, },
answersToDisplay(){ answersToDisplay(){
const filteredAnswers = Array.isArray(this.answersFromCms) const filteredAnswers = Array.isArray(this.answersFromCms)
? this.answersFromCms.filter(ans => ? this.answersFromCms.filter(ans =>
{ {
@ -128,10 +129,10 @@ export default ({
}); });
}, },
isDriverSideReplaceOptionsQuestionAvailable(){ isDriverSideReplaceOptionsQuestionAvailable(){
return (Array.isArray(this.selectedDoorSidesValues) && this.selectedDoorSidesValues.includes("DriverSide") && (Array.isArray(this.selectedDamageLocations) && this.selectedDamageLocations.includes("SideDoor"))); return (Array.isArray(this.selectedDoorSidesValues) && this.selectedDoorSidesValues.includes(damageLocationsSelected.DRIVERSIDE) && (Array.isArray(this.selectedDamageLocations) && this.selectedDamageLocations.includes(damageLocationsSelected.SIDEDOOR)));
}, },
isPassengerSideReplaceOptionsQuestionAvailable(){ isPassengerSideReplaceOptionsQuestionAvailable(){
return (Array.isArray(this.selectedDoorSidesValues) && this.selectedDoorSidesValues.includes("PassengerSide") && (Array.isArray(this.selectedDamageLocations) && this.selectedDamageLocations.includes("SideDoor"))); return (Array.isArray(this.selectedDoorSidesValues) && this.selectedDoorSidesValues.includes(damageLocationsSelected.PASSENGERSIDE) && (Array.isArray(this.selectedDamageLocations) && this.selectedDamageLocations.includes(damageLocationsSelected.SIDEDOOR)));
}, },
}, },
components: { components: {

View file

@ -17,7 +17,6 @@
<script> <script>
import buttonQuestion from "@/common-components/button-question/button-question"; import buttonQuestion from "@/common-components/button-question/button-question";
import store from "@/store";
export default ({ export default ({
name: "windshieldDamageTypeQuestion", name: "windshieldDamageTypeQuestion",

View file

@ -55,7 +55,7 @@ defineRule("windshield-damage-type-required", required(errorMessages.WINDSHIELD_
defineRule("windshield-chip-count-required", required(errorMessages.WINDSHIELD_CHIP_COUNT_REQUIRED)); defineRule("windshield-chip-count-required", required(errorMessages.WINDSHIELD_CHIP_COUNT_REQUIRED));
defineRule("windshield-replace-options-required", required(errorMessages.WINSHIELD_REPLACE_OPTIONS_REQUIRED)); defineRule("windshield-replace-options-required", required(errorMessages.WINSHIELD_REPLACE_OPTIONS_REQUIRED));
defineRule("check-for-repair-and-replace", (selectedWindshieldDamageType, [selectedDamageLocations]) => { defineRule("check-for-repair-and-replace", (selectedWindshieldDamageType, selectedDamageLocations) => {
return selectedWindshieldDamageType.toString() != damageLocationsSelected.REPAIR || return selectedWindshieldDamageType.toString() != damageLocationsSelected.REPAIR ||
!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) || !selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) ||
selectedDamageLocations.length === 1; selectedDamageLocations.length === 1;

View file

@ -10,6 +10,7 @@ import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { nextTick } from "vue"; import { nextTick } from "vue";
import baseMixin from "@/mixins/base-mixin.js"; import baseMixin from "@/mixins/base-mixin.js";
import store from "@/store"; import store from "@/store";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
// Mock our module for promises. // Mock our module for promises.
jest.mock("@/helpers/layout-helper.js", () => ({ jest.mock("@/helpers/layout-helper.js", () => ({
@ -21,6 +22,10 @@ jest.mock("@/helpers/cms-content-helper", () => ({
fetchCmsContentForPage: jest.fn(), fetchCmsContentForPage: jest.fn(),
})); }));
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
navigateToHeritageFunnel: jest.fn()
}));
// Mock store // Mock store
jest.mock("@/store", () => { return {}; }, { virtual: true }); jest.mock("@/store", () => { return {}; }, { virtual: true });
@ -211,17 +216,107 @@ describe("vehicle-parts.vue", () => {
}); });
test("ForwardButtonAction triggers a router.navigate change and saves selected parts to store", async () => { test("ForwardButtonAction triggers a router.navigate change if there are child part questions", async () => {
//Arrange //Arrange
store.getters.pageData.mockReturnValueOnce(basePartResponse); store.getters.pageData.mockReturnValueOnce({
store.getters.lineItems = { glassParts: {} } partsOrQuestions: [
store.commit = jest.fn(); {
glassName: "Single",
glassLocation: "Windshield",
parts: [
{
"partNumber": "FW03861GTYN",
"description": "rain sensor, heated glass, auto dimming mirror, solar, 3rd visor band, condensation sensor",
"color": "Green Tint",
"requiresRecalibration": false,
"requiresCapabilityQuestions": false,
"recalibrationType": null,
"childParts": null,
"childPartQuestions": [
{
"questionSequence": 1,
"questionText": "Does the rubber seal around your windshield have a chrome strip running through it?",
"answers": [
{
"answerResult": "WKT D1106 C",
"answerText": "Yes",
"nextQuestionSequence": null
},
{
"answerResult": "WKT D1106 B",
"answerText": "No",
"nextQuestionSequence": null
}
]
}
]
}
],
partQuestions: null
}
]
});
const { wrapper } = setupMocks({
mountOptionsMockData: {
router: {
navigate: jest.fn()
},
route: {
query: {
fmgPage: 'vehicle-parts',
}
},
store: {
getters: store.getters,
commit: store.commit
},
}
});
wrapper.setData({ glassParts: { "Rear-Stationary": { partNumber: 'FW03861GTYN' } } });
//Act
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "vehicle-parts" } },
undefined,
(c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction();
//Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
});
test("ForwardButtonAction triggers a router.navigate change if there are capability questions", async () => {
//Arrange
store.getters.pageData.mockReturnValueOnce({
partsOrQuestions: [
{
glassName: "Single",
glassLocation: "Windshield",
parts: [
{
partNumber: "DB12209GTYN",
description: "heated glass, solar, 1 hole",
color: "Green Tint",
requiresRecalibration: false,
requiresCapabilityQuestions: true,
childParts: null
}
],
partQuestions: null
}
]
});
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
router: { router: {
navigate: jest.fn(),
navigate: jest.fn() navigate: jest.fn()
}, },
route: { route: {
@ -251,6 +346,50 @@ describe("vehicle-parts.vue", () => {
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
}); });
test("ForwardButtonAction saves selected parts to store if no molding or capability questions", async () => {
//Arrange
store.getters.pageData.mockReturnValueOnce(basePartResponse);
store.getters.lineItems = { glassParts: {} }
const { wrapper } = setupMocks({
mountOptionsMockData: {
router: {
navigate: jest.fn()
},
route: {
query: {
fmgPage: 'vehicle-parts',
}
},
store: {
getters: store.getters,
commit: store.commit
},
navigateToHeritageFunnel: jest.fn()
}
});
wrapper.vm.$store.commit = jest.fn();
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
wrapper.setData({ glassParts: { "Rear-Stationary": { partNumber: 'DB12209GTYN' } } });
//Act
vehicleParts.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "vehicle-parts" } },
undefined,
(c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction();
//Assert
expect(wrapper.vm.$store.commit).toHaveBeenCalled();
expect(navigateToHeritageFunnel).toHaveBeenCalled();
});
}); });
function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {} }) { function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {} }) {
@ -288,6 +427,7 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {}
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn(); wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
return { wrapper, apiPromise }; return { wrapper, apiPromise };
} }

View file

@ -1,6 +1,7 @@
<template> <template>
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm"> <Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm">
<div class="page-container-grouped-styles vehicle-parts"> <div class="page-container-grouped-styles vehicle-parts">
<loadingModal ref="loadingModal"/>
<funnelHeader ref="funnelHeader" cmsWidgetName="FunnelHeaderWidget" /> <funnelHeader ref="funnelHeader" cmsWidgetName="FunnelHeaderWidget" />
<vehicleBanner <vehicleBanner
ref="vehicleBanner" ref="vehicleBanner"
@ -49,217 +50,221 @@
</template> </template>
<script> <script>
// Components // Components
import glassPartQuestion from "@/layouts/vehicle-parts/glass-part-question/glass-part-question"; import glassPartQuestion from "@/layouts/vehicle-parts/glass-part-question/glass-part-question";
import funnelHeader from "@/common-components/funnel-header/funnel-header"; import funnelHeader from "@/common-components/funnel-header/funnel-header";
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header"; import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
import funnelFooter from "@/common-components/funnel-footer/funnel-footer"; import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
import alert from "@/ux-components/alert/alert"; import alert from "@/ux-components/alert/alert";
// Supporting Files import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; // Supporting Files
import { settleAllPromises } from "@/helpers/layout-helper"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { settleAllPromises } from "@/helpers/layout-helper";
import store from "@/store"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { Form } from "vee-validate"; import { Form } from "vee-validate";
import { storeActions } from "@/constants/store-actions"; import store from "@/store";
import { storeMutations } from "@/constants/store-mutations.js";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
export default { export default {
name: "vehicle-parts", name: "vehicle-parts",
mixins: [vehicleQuestionsMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
{ {
resultKey: "cmsContent", resultKey: "cmsContent",
promise: cmsContentPromise, promise: cmsContentPromise,
}, },
]; ];
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
// Glass Part Question dynamic component // Glass Part Question dynamic component
Object.keys(vm.$refs) Object.keys(vm.$refs)
.filter( .filter((r) => r.includes(vm.RefPrefix) && vm.$refs[r][0] !== undefined)
(r) => r.includes(vm.RefPrefix) && vm.$refs[r][0] !== undefined .forEach((c) =>
)
.forEach((c) =>
vm.$refs[c][0].initializeComponent({ vm.$refs[c][0].initializeComponent({
ColorQuestionWidget: resultMap.cmsContent.ColorQuestionWidget, ColorQuestionWidget: resultMap.cmsContent.ColorQuestionWidget,
FeatureQuestionWidget: resultMap.cmsContent.FeatureQuestionWidget, FeatureQuestionWidget: resultMap.cmsContent.FeatureQuestionWidget,
}) })
); );
}); });
}, },
data() { data() {
return { return {
glassParts: {}, glassParts: {},
alertWidgetData: Object, alertWidgetData: Object,
alreadyPopulatedPartsData: {}, alreadyPopulatedPartsData: {},
}; };
},
components: {
Form,
glassPartQuestion,
funnelHeader,
vehicleBanner,
funnelSubHeader,
funnelFooter,
alert,
}, },
computed: { computed: {
isForwardActionDisabled() { isForwardActionDisabled() {
return ( return (
Object.keys(this.matchedParts).length !== this.selectedGlassPartNumbers.length !== this.PartsFromApi.partsOrQuestions.length
this.PartsFromApi.partsOrQuestions.length );
); },
}, selectedGlassPartNumbers () {
matchedParts() { // Compile all selected parts from the page.
const matchedParts = []; const numberArray = [];
for (let glassPart of Object.values(this.glassParts)) {
if (glassPart?.partNumber) { numberArray.push(glassPart.partNumber) }
}
return numberArray;
},
PartsOrQuestions() {
const partsData = this.PartsFromApi;
// Match them to the parts from the API. // Map API result data, to vehicle-parts data structure
this.PartsFromApi.partsOrQuestions.forEach((part) => { const mappedData = partsData.partsOrQuestions.map((g) => {
const selectedPartForGlassLocationAndName = return {
this.glassParts[`${part.glassLocation}-${part.glassName}`]; glassName: g.glassName,
const selectedPartData = part.parts.filter( glassLocation: g.glassLocation,
(part) => colorAnswers: g.parts.reduce((arr, p) => {
selectedPartForGlassLocationAndName && arr.push({
part.partNumber == selectedPartForGlassLocationAndName?.partNumber ColorAnswerText: p.color,
)[0]; FeatureAnswers: [
{
FeatureAnswerText: p.description === "" ? p.color : p.description,
PartNumber: p.partNumber,
},
],
});
return arr;
}, []),
};
});
if (selectedPartData) matchedParts.push(selectedPartData); return mappedData;
}); },
return matchedParts; PartsFromApi() {
}, return this.$store.getters.pageData(fmgPageValues.VEHICLE_PARTS);
PartsOrQuestions() { },
const partsData = this.PartsFromApi;
// Map API result data, to vehicle-parts data structure RefPrefix() {
const mappedData = partsData.partsOrQuestions.map((g) => { return "partQuestion";
return { },
glassName: g.glassName,
glassLocation: g.glassLocation,
colorAnswers: g.parts.reduce((arr, p) => {
arr.push({
ColorAnswerText: p.color,
FeatureAnswers: [
{
FeatureAnswerText:
p.description === "" ? p.color : p.description,
PartNumber: p.partNumber,
},
],
});
return arr;
}, []),
};
});
return mappedData;
},
PartsFromApi() {
return store.getters.pageData(fmgPageValues.VEHICLE_PARTS);
},
RefPrefix() {
return "partQuestion";
},
}, },
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
// Check if isRepair is populated and if the pageData we need is here (Parts data) // Check if isRepair is populated and if the pageData we need is here (Parts data)
if ( return store.getters.damage.isRepair != null &&
store.getters.damage.isRepair != null && Object.keys(store.getters.pageData(fmgPageValues.VEHICLE_PARTS)).length !== 0;
Object.keys(store.getters.pageData(fmgPageValues.VEHICLE_PARTS)) },
.length !== 0 backButtonAction() {
) { const hasPartQuestions = this.hasPartQuestions(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions);
return true; const backNavigationScenario = hasPartQuestions ? this.navigationScenarios.CLICKED_BACK_WITH_PART_QUESTION_ANSWERS : this.navigationScenarios.CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS;
}
return false; this.$router.navigate(
}, backNavigationScenario,
backButtonAction() { this.$route
this.$router.navigate(
this.navigationScenarios.CLICKED_BACK,
this.$route
);
},
async forwardButtonAction() {
const selectedGlassPartNumbers = [];
const matchedParts = [];
// Compile all selected parts from the page.
for (let [key, value] of Object.entries(this.glassParts)) {
for (let [glassKey, glassValue] of Object.entries(value)) {
selectedGlassPartNumbers.push(glassValue[0]);
}
}
// Match them to the parts from the API.
for (let [key, value] of Object.entries(
this.PartsFromApi.partsOrQuestions
)) {
for (let [partKey, partValue] of Object.entries(value.parts)) {
const currentPart =
this.PartsFromApi.partsOrQuestions[key].parts[partKey];
const isMatched = selectedGlassPartNumbers.some(
(p) => p === currentPart.partNumber
); );
},
async forwardButtonAction() {
const matchedParts = [];
if (isMatched) { // Match them to the parts from the API.
matchedParts.push(currentPart); for (let [key, value] of Object.entries(
this.PartsFromApi.partsOrQuestions
)) {
for (let [partKey, partValue] of Object.entries(value.parts)) {
const currentPart = this.PartsFromApi.partsOrQuestions[key].parts[partKey];
const isMatched = this.selectedGlassPartNumbers.some(
(p) => p === currentPart.partNumber
);
if (isMatched) {
matchedParts.push({
"glassLocation": value.glassLocation,
"glassName": value.glassName,
"parts": [currentPart]
});
}
}
} }
}
}
// If no parts could be matched, throw an error. const hasChildPartQuestions = this.hasChildPartQuestions(matchedParts);
if (this.isForwardActionDisabled) { const hasCapabilityQuestions = this.hasCapabilityQuestions(matchedParts);
this.$refs.funnelFooter.removeLoader();
throw new Error("Could not match any parts to the selected parts");
}
// Save parts to the store. // If no parts could be matched, throw an error (isForwardActionDisabled is based off of matchedParts)
await this.dispatchStoreAction( if (this.isForwardActionDisabled) {
storeActions.SAVE_GLASS_PARTS, this.$refs.funnelFooter.removeLoader();
matchedParts throw new Error("Could not match any parts to the selected parts");
); }
// Navigate to the next page. // Navigate to the next page
this.$router.navigate( if (hasChildPartQuestions) {
this.navigationScenarios.SELECTED_PARTS, this.$router.navigate(
this.$route this.navigationScenarios.HAS_MOLDING_QUESTIONS,
); this.$route,
}, {},
{},
{partsOrQuestions: matchedParts}
);
} else if (hasCapabilityQuestions) {
this.$router.navigate(
this.navigationScenarios.HAS_CAPABILITY_QUESTIONS,
this.$route,
{},
{},
{partsOrQuestions: matchedParts}
);
LoadInitialPartsData() { } else {
const partsData = this.PartsFromApi; // if single parts only
const alreadyPopulatedPartsData = const collectedGlassParts = this.reducedGlassPartsArray(matchedParts);
this.$store.getters.lineItems.glassParts === null // save to store lineItems.glassParts
? {} this.$store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
: this.$store.getters.lineItems.glassParts;
partsData.partsOrQuestions.map((g) => { // go to heritage quote page
// If the part is already populated, use the value from the store and populate the v-model. this.$refs.loadingModal.showModal();
Object.keys(alreadyPopulatedPartsData).forEach((key) => { navigateToHeritageFunnel();
const partNumber = alreadyPopulatedPartsData[key].partNumber; }
g.parts.forEach((p) => { },
if (p.partNumber === partNumber) {
this.glassParts[g.glassLocation + "-" + g.glassName] = { LoadInitialPartsData() {
[g.glassLocation]: [partNumber], const partsData = this.PartsFromApi;
}; const alreadyPopulatedPartsData =
} this.$store.getters.lineItems.glassParts === null
? {}
: this.$store.getters.lineItems.glassParts;
partsData.partsOrQuestions.map((g) => {
// If the part is already populated, use the value from the store and populate the v-model.
Object.keys(alreadyPopulatedPartsData).forEach((key) => {
const partNumber = alreadyPopulatedPartsData[key].partNumber;
g.parts.forEach((p) => {
if (p.partNumber === partNumber) {
this.glassParts[g.glassLocation + "-" + g.glassName] = {
[g.glassLocation]: [partNumber],
};
}
});
});
}); });
}); },
});
},
}, },
mounted() { mounted() {
this.LoadInitialPartsData(); this.LoadInitialPartsData();
}, },
}; components: {
Form,
glassPartQuestion,
funnelHeader,
vehicleBanner,
funnelSubHeader,
funnelFooter,
alert,
loadingModal,
},
};
</script> </script>

View file

@ -4,7 +4,9 @@ import vinInformation from "@/layouts/vin-lookup/vin-information/vin-information
describe("vinInformation.vue", () => { describe("vinInformation.vue", () => {
it("Should return input class active if isActive is true", async () => { it("Should return input class active if isActive is true", async () => {
// Act // Act
const wrapper = shallowMount(vinInformation); const wrapper = shallowMount(vinInformation, {
mixins: [mockMixin]
});
await wrapper.setData({ await wrapper.setData({
isActive: true, isActive: true,
@ -16,3 +18,9 @@ describe("vinInformation.vue", () => {
expect(wrapper.vm.isActive).toEqual(false); expect(wrapper.vm.isActive).toEqual(false);
}); });
}); });
const mockMixin = {
methods: {
getCmsContent: jest.fn()
}
}

View file

@ -1,11 +1,15 @@
<template> <template>
<div class="vin-information"> <div class="vin-information">
<div class="vin-toggle d-inline-flex" :class="[isActive ? 'active' : '']" @click="toggleClass()"> <div class="vin-toggle d-inline-flex mt-2" :class="[isActive ? 'active' : '']" @click="toggleClass()">
<textLink :text="HeadlineText" linkType="text" href="#!" /> <textLink
linkType="text"
href="#!"
:text="WhereCanIFindMyVINHeadline"
/>
</div> </div>
<div class="vin-info"> <div class="vin-info">
<div class="mt-2" v-html="BodyText"></div> <div class="mt-2" v-html="WhereCanIFindMyVINBodyCopy"></div>
<img :src="OptionalImage" alt="" /> <img :src="WhereCanIFindMyVINImage" alt="" />
</div> </div>
</div> </div>
</template> </template>
@ -13,6 +17,8 @@
<script> <script>
import textLink from "@/ux-components/text-link/text-link"; import textLink from "@/ux-components/text-link/text-link";
//Supporting files
import { settleAllPromises } from "@/helpers/layout-helper";
export default { export default {
name: "vinInformation", name: "vinInformation",
components: { components: {
@ -21,15 +27,23 @@ export default {
data() { data() {
return { return {
isActive: false, isActive: false,
HeadlineText: "Where can I find my VIN?",
BodyText: "<p class='mb-2'>You can find your VIN in a few places:</p> <ol> <li>Driver side windshield</li> <li>Driver side doorjamb</li> <li>Vehicle registration card</li> <li>Auto insurance card or app</li> </ol>",
OptionalImage: "https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/vin_location.svg?sfvrsn=63a9a2cf_3",
}; };
}, },
methods: { methods: {
toggleClass: function(event){ toggleClass: function(event){
this.isActive = !this.isActive; this.isActive = !this.isActive;
} }
},
computed: {
WhereCanIFindMyVINHeadline(){
return this.getCmsContent("WhereCanIFindMyVINToggle", "HeaderText");
},
WhereCanIFindMyVINBodyCopy(){
return this.getCmsContent("WhereCanIFindMyVINToggle", "BodyText");
},
WhereCanIFindMyVINImage(){
return this.getCmsContent("WhereCanIFindMyVINToggle", "Image");
},
} }
} }
@ -72,8 +86,11 @@ export default {
transition: all 250ms ease-out; transition: all 250ms ease-out;
overflow: hidden; overflow: hidden;
opacity: 0; opacity: 0;
p {
margin-bottom: .5rem;
}
img { img {
max-width: 420px; max-width: 100%;
width: 117%; width: 117%;
height: auto; height: auto;
} }

View file

@ -56,19 +56,19 @@
/> />
</div> </div>
</div> </div>
<alert ref="alertInvalidZip" <alert ref="alertInvalidZip"
v-if="displayInvalidZipAlert" v-if="displayInvalidZipAlert"
class="my-4" class="my-4"
cmsWidgetName="AlertInvalidZipWidget" cmsWidgetName="AlertInvalidZipWidget"
alertClass="alert-danger" alertClass="alert-danger"
v-bind:isDismissible="false" v-bind:isDismissible="false"
/> />
<alert <alert
class="my-4" class="my-4"
:manualHeadline="AlertPerfectMatchInsuranceVerifiedHeader" :manualHeadline="AlertPerfectMatchInsuranceVerifiedHeader"
:manualCopy="AlertPerfectMatchInsuranceVerifiedBody" :manualCopy="AlertPerfectMatchInsuranceVerifiedBody"
v-model="customAlertData" v-model="customAlertData"
v-if="vinPopulatedOnPageLoad && isInsuranceVerified" v-if="vinPopulatedOnPageLoad && isInsuranceVerified"
alertClass="alert-success" alertClass="alert-success"
/> />
<alert <alert
@ -173,7 +173,7 @@ export default {
return { return {
vin: this.getVinFromStore(), vin: this.getVinFromStore(),
serviceZipCode: this.getZipFromStore(), serviceZipCode: this.getZipFromStore(),
emailAddress: this.getEmailFromStore(), emailAddress: this.getEmailFromStore(),
isCarIdDifferent: false, isCarIdDifferent: false,
customAlertData: {}, customAlertData: {},
previouslyEnteredCarId: '', previouslyEnteredCarId: '',
@ -198,7 +198,7 @@ export default {
getZipFromStore(){ getZipFromStore(){
return this.$store.getters.order.serviceLocation.zipCode; return this.$store.getters.order.serviceLocation.zipCode;
}, },
attachCustomEvents() { attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => { this.prependActionToMethod(this, this.forwardButtonAction, () => {
this.pushEventToGA( this.pushEventToGA(
this.$route.query[this.queryStrings.FMG_PAGE], this.$route.query[this.queryStrings.FMG_PAGE],
@ -243,9 +243,9 @@ export default {
if (this.serviceZipCode && !isZipValid) { if (this.serviceZipCode && !isZipValid) {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;
return this.$refs.funnelFooter.removeLoader(); return this.$refs.funnelFooter.removeLoader();
} }
this.displayInvalidZipAlert = false; this.displayInvalidZipAlert = false;
// If either lookup fails, remove the loader and stop processing the page. // If either lookup fails, remove the loader and stop processing the page.
if (!resultMap.vehicleLookupResponse || !resultMap.serviceZipValidationResponse.isServiceable) { if (!resultMap.vehicleLookupResponse || !resultMap.serviceZipValidationResponse.isServiceable) {
// If the vehicle result is undefined, the vin entered was invalid. // If the vehicle result is undefined, the vin entered was invalid.
@ -270,7 +270,7 @@ export default {
this.previouslyEnteredCarId = resultMap.vehicleLookupResponse.carId; this.previouslyEnteredCarId = resultMap.vehicleLookupResponse.carId;
this.customAlertData.vehicleInfo = resultMap.vehicleLookupResponse; this.customAlertData.vehicleInfo = resultMap.vehicleLookupResponse;
this.displayMatchedDifferentVehicleAlert = true; this.displayMatchedDifferentVehicleAlert = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(resultMap.vehicleLookupResponse.carId); this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(resultMap.vehicleLookupResponse.carId);
// Update button "Continue with..." // Update button "Continue with..."
@ -292,12 +292,12 @@ export default {
}, false); }, false);
return await this.navigateForward(); return await this.navigateForward();
} }
// If a VIN has already been found. Validate the Service Zip (in case of changes) // If a VIN has already been found. Validate the Service Zip (in case of changes)
const zipValidationResponse = await this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZipCode}); const zipValidationResponse = await this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZipCode});
// Check if Service Zip entered is serviceable // Check if Service Zip entered is serviceable
if (zipValidationResponse.data.isServiceable) { if (zipValidationResponse.data.isServiceable) {
// If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward // If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward
@ -379,8 +379,8 @@ export default {
} }
else { else {
return 'XXXXXXXXXXXXXXXXX'; return 'XXXXXXXXXXXXXXXXX';
} }
}, },
}, },
watch: { watch: {
vin() { vin() {
@ -397,10 +397,10 @@ export default {
vehicleBanner, vehicleBanner,
funnelSubHeader, funnelSubHeader,
textboxQuestion, textboxQuestion,
alert, alert,
vinInformation, vinInformation,
loadingModal, loadingModal,
Form, Form,
}, },
}; };
</script> </script>

View file

@ -2,7 +2,7 @@ import { storeActions } from "@/constants/store-actions";
import { setCookieProperties, getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper"; import { setCookieProperties, getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
import { queryStrings } from "@/constants/query-strings"; import { queryStrings } from "@/constants/query-strings";
import { experimentSettings } from "@/constants/experiments"; import { experimentSettings } from "@/constants/experiments";
import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents } from "@/constants/analytics"; import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents, ValueToLogTypes } from "@/constants/analytics";
import { cookieNames } from "@/constants/cookie-names"; import { cookieNames } from "@/constants/cookie-names";
import baseMixin from "@/mixins/base-mixin"; import baseMixin from "@/mixins/base-mixin";
@ -42,13 +42,14 @@ export default {
baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false); baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
}, },
pushEventToGA(category, action, label, pushToLogApp = false) { pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {
const currentPageName = getPageNameByQueryString(); const currentPageName = getPageNameByQueryString();
const labelToLog = getValueToLog(label, valueToLogType);
const eventToBePushed = { const eventToBePushed = {
'event': GaEvents.GENERIC_EVENT, 'event': GaEvents.GENERIC_EVENT,
'category': category, 'category': category,
'action': action, 'action': action,
'label': label, 'label': labelToLog,
'value': undefined, 'value': undefined,
'path': `/fmg/?${queryStrings.FMG_PAGE}=${currentPageName}` 'path': `/fmg/?${queryStrings.FMG_PAGE}=${currentPageName}`
} }
@ -56,7 +57,7 @@ export default {
pushToDataLayerIfDefined(eventToBePushed); pushToDataLayerIfDefined(eventToBePushed);
if (pushToLogApp) { if (pushToLogApp) {
this.logCustomEvent(category, action, label, undefined); this.logCustomEvent(category, action, labelToLog, undefined);
} }
}, },
@ -97,7 +98,7 @@ export default {
pushToDataLayerIfDefined(experimentWithDimension); pushToDataLayerIfDefined(experimentWithDimension);
}); });
}, },
prependActionToMethod(object, method, actionToPrepend) { prependActionToMethod(object, method, actionToPrepend) {
const baseMethodName = method.name.startsWith('bound ') ? method.name.substring(6) : method.name ; const baseMethodName = method.name.startsWith('bound ') ? method.name.substring(6) : method.name ;
const baseMethod = object[baseMethodName]; const baseMethod = object[baseMethodName];
@ -145,6 +146,9 @@ export default {
}, },
GaLabels() { GaLabels() {
return GaLabels; return GaLabels;
},
ValueToLogTypes() {
return ValueToLogTypes;
} }
}, },
}; };
@ -163,4 +167,11 @@ function getPageNameByQueryString() {
} else { } else {
return ''; return '';
} }
}
function getValueToLog(value, valueToLogType) {
if (valueToLogType != null && valueToLogType === ValueToLogTypes.LAST_5 ) {
return value.slice(-5);
}
return value;
} }

View file

@ -1,7 +1,7 @@
import analyticsMixin from "@/mixins/analytics-mixin"; import analyticsMixin from "@/mixins/analytics-mixin";
import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js"; import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js";
import { storeActions } from "@/constants/store-actions"; import { storeActions } from "@/constants/store-actions";
import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents } from "@/constants/analytics"; import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents, ValueToLogTypes } from "@/constants/analytics";
describe("analyticsMixin.js", () => { describe("analyticsMixin.js", () => {
test("logPageView: calls dispatch with type and payload", () => { test("logPageView: calls dispatch with type and payload", () => {
@ -39,21 +39,71 @@ describe("analyticsMixin.js", () => {
expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled(); expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
}); });
test("pushEventToGA, should call logEvent too", () => { test("pushEventToGA, should call dataLayer push and logCustomEvent too", () => {
// Arrange // Arrange
window.dataLayer = [];
const mockData = { const mockData = {
actionList: [{ actionList: [{
actionName: storeActions.LOG_CUSTOM_EVENT actionName: storeActions.LOG_CUSTOM_EVENT
}], }],
} }
const mocks = setupMocksForJsFiles(mockData); const mocks = setupMocksForJsFiles(mockData);
var mockDataLayer = [];
mockDataLayer.push({
event: 'event',
category: 'category',
action: 'action',
label: 'label',
value: undefined,
path: '/fmg/?fmgPage='
});
// Act // Act
analyticsMixin.methods.pushEventToGA('category', 'action', 'label', true); analyticsMixin.methods.pushEventToGA('category', 'action', 'label', true);
// Assert // Assert
expect(mockDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled(); expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
});
test("pushEventToGA, should call dataLayer push and ValueToLogTypes.LAST_5 only logs last 5 of label", () => {
// Arrange
window.dataLayer = [];
var expectedDataLayer = [];
expectedDataLayer.push({
event: 'event',
category: 'category',
action: 'action',
label: '33333',
value: undefined,
path: '/fmg/?fmgPage='
});
// Act
analyticsMixin.methods.pushEventToGA('category', 'action', '1111122222333333', false, ValueToLogTypes.LAST_5);
// Assert
expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
});
test("pushEventToGA, should call dataLayer push and ValueToLogTypes.LAST_5 logs only the last 3 characters for a 3 character string", () => {
// Arrange
window.dataLayer = [];
var expectedDataLayer = [];
expectedDataLayer.push({
event: 'event',
category: 'category',
action: 'action',
label: '111',
value: undefined,
path: '/fmg/?fmgPage='
});
// Act
analyticsMixin.methods.pushEventToGA('category', 'action', '111', false, ValueToLogTypes.LAST_5);
// Assert
expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
}); });
test("Experiments, should push to dataLayer with default Google Custom Dimension Index", () => { test("Experiments, should push to dataLayer with default Google Custom Dimension Index", () => {

View file

@ -0,0 +1,15 @@
import store from "@/store";
export default {
methods: {
hasSettingEqualTo(settingName, settingValue) {
return store.getters.experimentSettings[settingName] === settingValue;
},
hasSetting(settingName) {
return store.getters.experimentSettings.hasOwnProperty(settingName);
},
getSettingValue(settingName) {
return this.hasSetting(settingName) ? store.getters.experimentSettings[settingName] : null;
}
},
}

View file

@ -0,0 +1,148 @@
import experimentMixin from "@/mixins/experiment-mixin";
import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import store from "@/store";
describe("experiment-mixin", () => {
describe("hasSettingEqualTo", () => {
test("setting exists and value matches => return true", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.hasSettingEqualTo("Setting2", "Value2");
// Assert
expect(result).toEqual(true);
});
test("setting exists and value does not match => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.hasSettingEqualTo("Setting2", "Value3");
// Assert
expect(result).toEqual(false);
});
test("setting does not exist => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.hasSettingEqualTo("SettingBoogly", "Woogly");
// Assert
expect(result).toEqual(false);
});
test("there are no settings => return false", () => {
// Arrange
const { wrapper } = setupMocks({ experimentSettings: {} });
// Act
const result = wrapper.vm.hasSettingEqualTo("Setting2", "Value3");
// Assert
expect(result).toEqual(false);
});
});
describe("hasSetting", () => {
test("has setting => return true", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.hasSetting("Setting4");
// Assert
expect(result).toEqual(true);
});
test("does not have setting => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.hasSetting("BooglyWoogly");
// Assert
expect(result).toEqual(false);
});
test("experimentSettings is empty => return false", () => {
// Arrange
const { wrapper } = setupMocks({ experimentSettings: {} });
// Act
const result = wrapper.vm.hasSetting("Setting4");
// Assert
expect(result).toEqual(false);
});
});
describe("getSettingValue", () => {
test("has setting => return correct value", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.getSettingValue("Setting3");
// Assert
expect(result).toEqual("Value3")
});
test("does not have setting => return null", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const result = wrapper.vm.getSettingValue("Hello");
// Assert
expect(result).toBeNull();
});
test("experimentSettings is empty => return null", () => {
// Arrange
const { wrapper } = setupMocks({ experimentSettings: {} });
// Act
const result = wrapper.vm.getSettingValue("Hello");
// Assert
expect(result).toBeNull();
});
});
});
function setupMocks({ experimentSettings }) {
const mocks = getMountOptions({});
const testExperimentSettings = {
"Setting1": "Value1",
"Setting2": "Value2",
"Setting3": "Value3",
"Setting4": "Value1",
"Setting5": "Value2",
"Setting6": "Value3"
};
store.getters = {
experimentSettings: experimentSettings ?? testExperimentSettings
};
const mockComponent = {
template: "<div></div>",
mixins: [experimentMixin]
};
const wrapper = shallowMount(mockComponent, mocks);
return { wrapper };
}

View file

@ -0,0 +1,43 @@
export default {
methods: {
hasPartQuestions(partsOrQuestions) {
return partsOrQuestions?.some(pq => pq.partQuestions?.length > 0);
},
hasGlassLocationWithMultipleParts(partsOrQuestions) {
return partsOrQuestions?.some(pq => pq.parts?.length > 1);
},
hasChildPartQuestions(partsOrQuestions) {
return partsOrQuestions.some(pq => {
return pq.parts?.some(part => part.childPartQuestions?.length > 0);
});
},
hasCapabilityQuestions(partsOrQuestions) {
return partsOrQuestions.some(pq => {
return pq.parts?.some(part => part.requiresCapabilityQuestions === true);
});
},
// method to only include keys listed for lineItems.glassParts in
// https://safelite.atlassian.net/wiki/spaces/DC/pages/17137665/Catalog+Front-End+State#glassParts
reducedGlassPartsArray(glassParts) {
const reducedGlassParts = [];
glassParts.forEach((glass) => {
if (Array.isArray(glass.parts) && glass.parts.length === 1) {
const singlePart = glass.parts[0];
reducedGlassParts.push({
partNumber: singlePart.partNumber,
description: singlePart.description,
color: singlePart.color,
requiresRecalibration: singlePart.requiresRecalibration,
requiresCapabilityQuestions: singlePart.requiresCapabilityQuestions,
recalibrationType: singlePart.recalibrationType,
childParts: singlePart.childParts,
price: singlePart.price,
});
}
});
return reducedGlassParts;
}
}
}

View file

@ -0,0 +1,161 @@
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { shallowMount } from "@vue/test-utils";
import { setupMocksForJsFiles, getMountOptions } from "@/helpers/unit-test-helper.js";
describe("vehicle-questions-mixin", () => {
describe("hasPartQuestions", () => {
test("has no part questions => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const hasPartQuestions = wrapper.vm.hasPartQuestions([
{
partQuestions: []
}
])
// Assert
expect(hasPartQuestions).toBe(false);
});
test("has undefined part questions => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const hasPartQuestions = wrapper.vm.hasPartQuestions([])
// Assert
expect(hasPartQuestions).toBe(false);
});
test("has part questions => return true", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const hasPartQuestions = wrapper.vm.hasPartQuestions([
{
partQuestions: [{
testProperty: "some value"
}]
}
])
// Assert
expect(hasPartQuestions).toBe(true);
});
});
describe("hasGlassLocationWithMultipleParts", () => {
test("has one part for one glass location => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([
{
glassName: "Something",
glassLocation: "somewhere",
parts: [{
partNumber: "1234567"
}]
}
])
// Assert
expect(hasGlassLocationWithMultipleParts).toBe(false);
});
test("has one part for every glass location => return false", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([
{
glassName: "Something",
glassLocation: "somewhere",
parts: [{
partNumber: "1234567"
}]
},
{
glassName: "Another glass",
glassLocation: "somewhere else",
parts: [{
partNumber: "1234568"
}]
},
{
glassName: "Special glass",
glassLocation: "Another where",
parts: [{
partNumber: "1234569"
}]
}
])
// Assert
expect(hasGlassLocationWithMultipleParts).toBe(false);
});
test("has multiple parts for one glass location => return true", () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([
{
glassName: "Something",
glassLocation: "somewhere",
parts: [{
partNumber: "1234567"
}]
},
{
glassName: "Another glass",
glassLocation: "somewhere else",
parts: [{
partNumber: "1234568"
}]
},
{
glassName: "Special glass",
glassLocation: "Another where",
parts: [
{
partNumber: "1234569"
},
{
partNumber: "1234560"
}
]
}
])
// Assert
expect(hasGlassLocationWithMultipleParts).toBe(true);
});
});
});
function setupMocks({}) {
const baseMixin = setupMocksForJsFiles({});
const mocks = getMountOptions({
router: {
navigate: jest.fn()
},
});
const mockVehicleQuestionComponent = {
template: '<div></div>',
mixins: [vehicleQuestionsMixin, baseMixin.baseMixin]
};
const wrapper = shallowMount(mockVehicleQuestionComponent, mocks);
return { wrapper };
}

View file

@ -1,16 +1,20 @@
import store from "@/store";
import { storeActions } from "@/constants/store-actions.js"; import { storeActions } from "@/constants/store-actions.js";
import { storeMutations } from "@/constants/store-mutations.js"; import { storeMutations } from "@/constants/store-mutations.js";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
export default { export default {
mixins: [vehicleQuestionsMixin],
methods: { methods: {
async navigateForwardWithSingleCarMatch() { async navigateForwardWithSingleCarMatch() {
const result = await this.dispatchStoreAction(storeActions.GET_PARTS_OR_QUESTIONS); const result = await this.dispatchStoreAction(storeActions.GET_PARTS_OR_QUESTIONS);
const partsOrQuestions = result.data.partsOrQuestions; const partsOrQuestions = result.data.partsOrQuestions;
const hasPartsQuestions = partsOrQuestions.some(pq => pq.partQuestions?.length > 0);
const hasGlassLocationWithMultipleParts = partsOrQuestions.some(pq => pq.parts?.length > 1); const hasPartsQuestions = this.hasPartQuestions(partsOrQuestions);
const hasGlassLocationWithMultipleParts = this.hasGlassLocationWithMultipleParts(partsOrQuestions);
const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions);
const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions);
if (hasPartsQuestions) { if (hasPartsQuestions) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data); this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data);
@ -18,11 +22,22 @@ export default {
else if (hasGlassLocationWithMultipleParts) { else if (hasGlassLocationWithMultipleParts) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data); this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data);
} }
else if (hasChildPartQuestions) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS, this.$route, {}, {}, result.data);
}
else if (hasCapabilityQuestions) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS, this.$route, {}, {}, result.data);
}
else { else {
store.commit(storeMutations.UPDATE_GLASS_PARTS, result.data); // if single parts only
const collectedGlassParts = this.reducedGlassPartsArray(result.data.partsOrQuestions);
// save to store lineItems.glassParts
this.$store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
// go to heritage quote page
this.$refs.loadingModal.showModal(); this.$refs.loadingModal.showModal();
navigateToHeritageFunnel(); navigateToHeritageFunnel();
} }
} },
} }
} }

View file

@ -94,7 +94,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, front", "description": "driver side, front",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -109,7 +109,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, 1 hole", "description": "driver side, 1 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -147,7 +147,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, stationary", "description": "heated glass, stationary",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -202,7 +202,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, front", "description": "driver side, front",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -217,7 +217,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, 1 hole", "description": "driver side, 1 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -232,7 +232,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, body side, 1 hole", "description": "driver side, body side, 1 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -247,7 +247,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, stationary", "description": "heated glass, stationary",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -302,7 +302,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, front", "description": "driver side, front",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -317,7 +317,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, 1 hole", "description": "driver side, 1 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -325,7 +325,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, 1 hole", "description": "driver side, 1 hole",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -340,7 +340,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, body side, 1 hole", "description": "driver side, body side, 1 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -348,7 +348,7 @@ describe("vin-pages-mixin", () => {
"description": "driver side, body side, 1 hole", "description": "driver side, body side, 1 hole",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -363,7 +363,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, stationary", "description": "heated glass, stationary",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -371,7 +371,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, stationary", "description": "heated glass, stationary",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -379,7 +379,7 @@ describe("vin-pages-mixin", () => {
"description": "stationary", "description": "stationary",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -387,7 +387,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, movable, 8 hole", "description": "heated glass, movable, 8 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -395,7 +395,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, movable, 8 hole", "description": "heated glass, movable, 8 hole",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -429,7 +429,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, solar, antenna", "description": "heated glass, solar, antenna",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -437,7 +437,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, solar, antenna, w/diversity antenna", "description": "heated glass, solar, antenna, w/diversity antenna",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -469,7 +469,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, 3rd visor band", "description": "solar, 3rd visor band",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": [ "childParts": [
{ {
"partNumber": "MWF03647", "partNumber": "MWF03647",
@ -490,7 +490,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, rear, ex models and above", "description": "solar, driver side, rear, ex models and above",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -505,7 +505,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, front, ex models and above", "description": "solar, driver side, front, ex models and above",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -520,7 +520,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, rear", "description": "solar, driver side, rear",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -535,7 +535,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, solar, antenna", "description": "heated glass, solar, antenna",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -543,7 +543,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, solar, antenna, w/diversity antenna", "description": "heated glass, solar, antenna, w/diversity antenna",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -575,7 +575,7 @@ describe("vin-pages-mixin", () => {
"description": "solar", "description": "solar",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -590,7 +590,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, rear", "description": "solar, driver side, rear",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -598,7 +598,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, rear", "description": "solar, driver side, rear",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -613,7 +613,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, front", "description": "solar, driver side, front",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -621,7 +621,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, front, laminated, soundproofing", "description": "solar, driver side, front, laminated, soundproofing",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -636,7 +636,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, encap", "description": "solar, driver side, encap",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -644,7 +644,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, encap", "description": "solar, driver side, encap",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -652,7 +652,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, antenna, driver side, encap", "description": "solar, antenna, driver side, encap",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -660,7 +660,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, antenna, driver side, encap", "description": "solar, antenna, driver side, encap",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -668,7 +668,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, encap, chrome molding", "description": "solar, driver side, encap, chrome molding",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -676,7 +676,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, driver side, encap, chrome molding", "description": "solar, driver side, encap, chrome molding",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -684,7 +684,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, antenna, driver side, encap, chrome molding", "description": "solar, antenna, driver side, encap, chrome molding",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -692,7 +692,7 @@ describe("vin-pages-mixin", () => {
"description": "solar, antenna, driver side, encap, chrome molding", "description": "solar, antenna, driver side, encap, chrome molding",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -707,7 +707,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, solar, 1 hole", "description": "heated glass, solar, 1 hole",
"color": "Green Tint", "color": "Green Tint",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
}, },
{ {
@ -715,7 +715,7 @@ describe("vin-pages-mixin", () => {
"description": "heated glass, solar, 1 hole", "description": "heated glass, solar, 1 hole",
"color": "Gray Tint Privacy", "color": "Gray Tint Privacy",
"requiresRecalibration": false, "requiresRecalibration": false,
"requiresCapabilityQuestions": false, "requiresCapabilityQuestions": true,
"childParts": null "childParts": null
} }
], ],
@ -736,6 +736,94 @@ describe("vin-pages-mixin", () => {
}); });
}); });
describe("should go to molding-questions", () => {
test("single glass location has child part questions => go to molding-questions", async () => {
// Arrange
const partsOrQuestions = [
{
"glassName": "Stationary",
"glassLocation": "Rear",
"parts": [
{
"partNumber": "FB25724GTYN",
"description": "heated glass, solar, antenna",
"color": "Green Tint",
"requiresRecalibration": false,
"requiresCapabilityQuestions": true,
"childParts": null,
"childPartQuestions": [
{
"questionSequence": 1,
"questionText": "Does the rubber seal around your windshield have a chrome strip running through it?",
"answers": [
{
"answerResult": "WKT D1106 C",
"answerText": "Yes",
"nextQuestionSequence": null
},
{
"answerResult": "WKT D1106 B",
"answerText": "No",
"nextQuestionSequence": null
}
]
}
]
}
],
"partQuestions": null
}
];
const { wrapper } = setupMocks({
partsOrQuestions: partsOrQuestions
});
// Act
await wrapper.vm.navigateForwardWithSingleCarMatch();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
});
});
describe("should go to capability-questions", () => {
test("single glass location has no child part questions but requiresCapabilityQuestions is true => go to capability-questions", async () => {
// Arrange
const partsOrQuestions = [
{
"glassName": "Stationary",
"glassLocation": "Rear",
"parts": [
{
"partNumber": "FB25724GTYN",
"description": "heated glass, solar, antenna",
"color": "Green Tint",
"requiresRecalibration": false,
"requiresCapabilityQuestions": true,
"childParts": null,
"childPartQuestions": null
}
],
"partQuestions": null
}
];
const { wrapper } = setupMocks({
partsOrQuestions: partsOrQuestions
});
// Act
await wrapper.vm.navigateForwardWithSingleCarMatch();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1);
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS, wrapper.vm.$route, {}, {}, { partsOrQuestions });
});
});
describe("should go to heritage funnel", () => { describe("should go to heritage funnel", () => {
test("single glass location selected, has no part questions and has one part => go to heritage funnel", async () => { test("single glass location selected, has no part questions and has one part => go to heritage funnel", async () => {
// Arrange // Arrange
@ -864,14 +952,17 @@ describe("vin-pages-mixin", () => {
partsOrQuestions: partsOrQuestions partsOrQuestions: partsOrQuestions
}); });
store.commit = jest.fn(); wrapper.vm.$store.commit = jest.fn();
const collectedGlassParts = wrapper.vm.reducedGlassPartsArray(partsOrQuestions);
// Act // Act
await wrapper.vm.navigateForwardWithSingleCarMatch(); await wrapper.vm.navigateForwardWithSingleCarMatch();
// Assert // Assert
expect(store.commit).toHaveBeenCalledTimes(1); expect(wrapper.vm.$store.commit).toHaveBeenCalledTimes(1);
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_GLASS_PARTS, { partsOrQuestions }) expect(wrapper.vm.$store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts)
expect(wrapper.vm.$refs.loadingModal.showModal).toHaveBeenCalledTimes(1); expect(wrapper.vm.$refs.loadingModal.showModal).toHaveBeenCalledTimes(1);
expect(navigateToHeritageFunnel).toHaveBeenCalledTimes(1); expect(navigateToHeritageFunnel).toHaveBeenCalledTimes(1);
}); });
@ -895,23 +986,17 @@ function setupMocks({ partsOrQuestions = [] }) {
router: { router: {
navigate: jest.fn() navigate: jest.fn()
}, },
store: {
commit: jest.fn()
}
}); });
const mockVinComponent = { const mockVinComponent = {
components: { loadingModal }, components: { loadingModal },
template: '<loadingModal ref="loadingModal" />', template: '<loadingModal ref="loadingModal" />',
// render() {
// return '<div ref="loadingModal"></div>'
// },
mixins: [vinPagesMixin, baseMixin.baseMixin] mixins: [vinPagesMixin, baseMixin.baseMixin]
}; };
// const mockVinComponent = Vue.component("mockcomponent", {
// template: '<loadingModal ref="loadingModal" />',
// mixins: [vinPagesMixin, baseMixin.baseMixin]
// })
const wrapper = shallowMount(mockVinComponent, mocks); const wrapper = shallowMount(mockVinComponent, mocks);
wrapper.vm.$refs.loadingModal.showModal = jest.fn(); wrapper.vm.$refs.loadingModal.showModal = jest.fn();

View file

@ -53,6 +53,9 @@ const routes = [
// On entering the funnel "fresh", read cookie information, decide what to do next. // On entering the funnel "fresh", read cookie information, decide what to do next.
if (from.redirectedFrom === undefined) { if (from.redirectedFrom === undefined) {
// clear the saveOrderPromise - if it exists in the vuex store but a new instance was created
// the saveOrderPromise will no longer point to a valid promise
baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_ORDER_PROMISE);
const loadOrderResponse = await loadOrderIfPresent(); const loadOrderResponse = await loadOrderIfPresent();
const pageToRedirectTo = await getPageToRouteExistingOrderTo(to, loadOrderResponse); const pageToRedirectTo = await getPageToRouteExistingOrderTo(to, loadOrderResponse);
@ -63,7 +66,6 @@ const routes = [
return next(false); return next(false);
} }
// Assign our fmgPage so it will load normally like the other pages. // Assign our fmgPage so it will load normally like the other pages.
to.query.fmgPage = pageToRedirectTo; to.query.fmgPage = pageToRedirectTo;
} }
@ -142,7 +144,7 @@ router.afterEach((to, from) => {
}); });
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => { router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData) => {
navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData); navigate(scenario, currentRoute, optionalQuery, optionalParams, optionalPageData);
} }
@ -154,7 +156,7 @@ router.navigateToExternalUrl = (url, optionalQuery = {}) => {
// PRIVATE FUNCTIONS // PRIVATE FUNCTIONS
// Navigate to the next route, depending on the scenario. // Navigate to the next route, depending on the scenario.
async function navigate(scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) { async function navigate(scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData) {
if (!scenario) { if (!scenario) {
console.error("No scenario provided. Please review the routing table."); console.error("No scenario provided. Please review the routing table.");
return; return;
@ -167,8 +169,10 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
if (destinationFmgPageValue !== undefined) { if (destinationFmgPageValue !== undefined) {
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one. // We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
// Append page data to the store for the NEXT page, if any. It will be an empty object if none is provided. // Update page data to the store for next page if provided. Otherwise, keep existing page data
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData); if (optionalPageData !== undefined) {
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
}
// if cookie and referralNumber/Date exists OR an emailAddress has been saved // if cookie and referralNumber/Date exists OR an emailAddress has been saved
if ((getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) || store.getters.order.customer?.emailAddress) { if ((getFunnelCookie()?.ReferralNumber && getFunnelCookie()?.ReferralDate) || store.getters.order.customer?.emailAddress) {
@ -190,15 +194,16 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
// Get navigation map depending on the scenario and the current 'page' you're on. // Get navigation map depending on the scenario and the current 'page' you're on.
function getNavigationMap(scenario, currentRoute) { function getNavigationMap(scenario, currentRoute) {
const fmgPageValue = currentRoute.query.fmgPage; const fmgPageValue = currentRoute.query.fmgPage;
const matchedQueryValue = routingTable const matchedQueryValue = routingTable(store)
.filter( .filter(
(item) => (item) =>
item.fmgPageValue === fmgPageValue && item.fmgPageValue === fmgPageValue &&
item.maps.filter((map) => map.scenario === scenario).length > 0 item.maps.filter((map) => map.scenario === scenario).length > 0
) )
.map((m) => m.maps.filter((map) => map.scenario === scenario)); .map((m) => m.maps.filter((map) => map.scenario === scenario))[0]
.filter(x => x.filter === true || x.filter === undefined);
return matchedQueryValue[0][0]; return matchedQueryValue[0];
} }
//---------------------------------------------------------- Private Functions ---------------------------------------------------------- //---------------------------------------------------------- Private Functions ----------------------------------------------------------

View file

@ -8,6 +8,8 @@ const fmgPageValues = {
VIN_LOOKUP: "vin-lookup", VIN_LOOKUP: "vin-lookup",
VEHICLE_PARTS: "vehicle-parts", VEHICLE_PARTS: "vehicle-parts",
PART_QUESTIONS: "part-questions", PART_QUESTIONS: "part-questions",
MOLDING_QUESTIONS: "molding-questions",
CAPABILITY_QUESTIONS: "capability-questions",
LICENSE_PLATE_LOOKUP: "license-plate-lookup", LICENSE_PLATE_LOOKUP: "license-plate-lookup",
REVEAL: "reveal", REVEAL: "reveal",
ESTIMATE: "estimate", ESTIMATE: "estimate",

View file

@ -10,6 +10,8 @@ const navigationScenarios = {
SELECTED_PARTS: "SELECTED_PARTS", SELECTED_PARTS: "SELECTED_PARTS",
SELECTED_VIN_WITH_PART_QUESTIONS: "SELECTED_VIN_WITH_PART_QUESTIONS", SELECTED_VIN_WITH_PART_QUESTIONS: "SELECTED_VIN_WITH_PART_QUESTIONS",
SELECTED_VIN_WITH_MULTIPLE_PARTS: "SELECTED_VIN_WITH_MULTIPLE_PARTS", SELECTED_VIN_WITH_MULTIPLE_PARTS: "SELECTED_VIN_WITH_MULTIPLE_PARTS",
SELECTED_VIN_WITH_MOLDING_QUESTIONS: "SELECTED_VIN_WITH_MOLDING_QUESTIONS",
SELECTED_VIN_WITH_CAPABILITY_QUESTIONS: "SELECTED_VIN_WITH_CAPABILITY_QUESTIONS",
CONTINUING_WITH_SINGLE_PART: "CONTINUING_WITH_SINGLE_PART", CONTINUING_WITH_SINGLE_PART: "CONTINUING_WITH_SINGLE_PART",
CONTINUING_WITH_MULTIPLE_VEHICLES: "CONTINUING_WITH_MULTIPLE_VEHICLES", CONTINUING_WITH_MULTIPLE_VEHICLES: "CONTINUING_WITH_MULTIPLE_VEHICLES",
SELECTED_VIN_HAS_MISMATCHED_GLASS: "SELECTED_VIN_HAS_MISMATCHED_GLASS", SELECTED_VIN_HAS_MISMATCHED_GLASS: "SELECTED_VIN_HAS_MISMATCHED_GLASS",
@ -19,7 +21,11 @@ const navigationScenarios = {
SELECTED_HOME_ADDRESS: "SELECTED_HOME_ADDRESS", SELECTED_HOME_ADDRESS: "SELECTED_HOME_ADDRESS",
ANSWERED_QUESTIONS_WITH_SINGLE_PART: "ANSWERED_QUESTIONS_WITH_SINGLE_PART", ANSWERED_QUESTIONS_WITH_SINGLE_PART: "ANSWERED_QUESTIONS_WITH_SINGLE_PART",
ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS: "ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS", ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS: "ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS",
SELECTED_PROVIDE_VIN_DIFFERENT_WAY: "SELECTED_PROVIDE_VIN_DIFFERENT_WAY" SELECTED_PROVIDE_VIN_DIFFERENT_WAY: "SELECTED_PROVIDE_VIN_DIFFERENT_WAY",
CLICKED_BACK_WITH_PART_QUESTION_ANSWERS: "CLICKED_BACK_WITH_PART_QUESTION_ANSWERS",
CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS: "CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS",
HAS_MOLDING_QUESTIONS: "HAS_MOLDING_QUESTIONS",
HAS_CAPABILITY_QUESTIONS: "HAS_CAPABILITY_QUESTIONS",
}; };
export { navigationScenarios }; export { navigationScenarios };

View file

@ -1,236 +1,305 @@
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
const routingTable = [ // Get store from router/index.js instead of importing it here to get updated values
{ const routingTable = function(store) {
fmgPageValue: fmgPageValues.VEHICLE_YEAR, return [
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_YEAR,
scenario: navigationScenarios.SELECTED_YEAR, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, {
}, scenario: navigationScenarios.SELECTED_YEAR,
], destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
}, },
{ ],
fmgPageValue: fmgPageValues.VEHICLE_MAKE, },
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_MAKE,
scenario: navigationScenarios.SELECTED_MAKE, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL, {
}, scenario: navigationScenarios.SELECTED_MAKE,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL,
scenario: navigationScenarios.CLICKED_BACK, },
destinationFmgPageValue: fmgPageValues.VEHICLE_YEAR, {
}, scenario: navigationScenarios.CLICKED_BACK,
], destinationFmgPageValue: fmgPageValues.VEHICLE_YEAR,
}, },
{ ],
fmgPageValue: fmgPageValues.VEHICLE_MODEL, },
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_MODEL,
scenario: navigationScenarios.SELECTED_MODEL, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, {
}, scenario: navigationScenarios.SELECTED_MODEL,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE,
scenario: navigationScenarios.CLICKED_BACK, },
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, {
}, scenario: navigationScenarios.CLICKED_BACK,
], destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
}, },
{ ],
fmgPageValue: fmgPageValues.VEHICLE_STYLE, },
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_STYLE,
scenario: navigationScenarios.SELECTED_STYLE, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, {
}, scenario: navigationScenarios.SELECTED_STYLE,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
scenario: navigationScenarios.CLICKED_BACK, },
destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL, {
}, scenario: navigationScenarios.CLICKED_BACK,
], destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL,
}, },
{ ],
fmgPageValue: fmgPageValues.VEHICLE_DAMAGE, },
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
scenario: navigationScenarios.CLICKED_BACK, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, {
}, scenario: navigationScenarios.CLICKED_BACK,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE,
scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN, },
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, {
}, scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN,
{ destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, },
destinationFmgPageValue: fmgPageValues.ESTIMATE, {
}, scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
], destinationFmgPageValue: fmgPageValues.ESTIMATE,
}, },
{ ],
fmgPageValue: fmgPageValues.VEHICLE_PARTS, },
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_PARTS,
scenario: navigationScenarios.CLICKED_BACK, maps: [
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, {
}, scenario: navigationScenarios.SELECTED_PARTS,
{ destinationFmgPageValue: fmgPageValues.QUOTE,
scenario: navigationScenarios.SELECTED_PARTS, },
destinationFmgPageValue: fmgPageValues.QUOTE, {
}, scenario: navigationScenarios.CLICKED_FORWARD,
{ destinationFmgPageValue: fmgPageValues.REVEAL,
scenario: navigationScenarios.CLICKED_FORWARD, },
destinationFmgPageValue: fmgPageValues.REVEAL, {
}, scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTION_ANSWERS,
], destinationFmgPageValue: fmgPageValues.PART_QUESTIONS,
}, },
{ {
fmgPageValue: fmgPageValues.REVEAL, scenario: navigationScenarios.CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS,
maps: [ destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
{ },
scenario: navigationScenarios.CLICKED_BACK, ],
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, },
}, {
{ fmgPageValue: fmgPageValues.REVEAL,
scenario: navigationScenarios.SELECTED_PARTS, maps: [
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, {
}, scenario: navigationScenarios.CLICKED_BACK,
], destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
}, },
{ {
fmgPageValue: fmgPageValues.VIN_LOOKUP, scenario: navigationScenarios.SELECTED_PARTS,
maps: [ destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
{ },
scenario: navigationScenarios.CLICKED_BACK, ],
destinationFmgPageValue: fmgPageValues.ESTIMATE, },
}, {
{ fmgPageValue: fmgPageValues.VIN_LOOKUP,
scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, {
}, scenario: navigationScenarios.CLICKED_BACK,
{ destinationFmgPageValue: fmgPageValues.ESTIMATE,
scenario: navigationScenarios.CLICKED_BACK_WITH_VIN, },
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, {
}, scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, },
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS {
}, scenario: navigationScenarios.CLICKED_BACK_WITH_VIN,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, },
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS {
} scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
], destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
}, },
{ {
fmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP, scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
maps: [ destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
{ },
scenario: navigationScenarios.CLICKED_BACK, {
destinationFmgPageValue: fmgPageValues.ESTIMATE, scenario: navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.MOLDING_QUESTIONS
{ },
scenario: navigationScenarios.CLICKED_FORWARD, {
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, scenario: navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS
{ }
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, ],
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS },
}, {
{ fmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP,
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS {
} scenario: navigationScenarios.CLICKED_BACK,
], destinationFmgPageValue: fmgPageValues.ESTIMATE,
}, },
{ {
fmgPageValue: fmgPageValues.ADDRESS_LOOKUP, scenario: navigationScenarios.CLICKED_FORWARD,
maps: [ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
{ },
scenario: navigationScenarios.CLICKED_BACK, {
destinationFmgPageValue: fmgPageValues.ESTIMATE, scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
{ },
scenario: navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, {
destinationFmgPageValue: fmgPageValues.ADDRESS_VEHICLES, scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
}, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
{ },
scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, {
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, scenario: navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.MOLDING_QUESTIONS
{ },
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, {
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS scenario: navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS
{ }
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, ],
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS },
} {
], fmgPageValue: fmgPageValues.ADDRESS_LOOKUP,
}, maps: [
{ {
fmgPageValue: fmgPageValues.ADDRESS_VEHICLES, scenario: navigationScenarios.CLICKED_BACK,
maps: [ destinationFmgPageValue: fmgPageValues.ESTIMATE,
{ },
scenario: navigationScenarios.CLICKED_BACK, {
destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP, scenario: navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES,
}, destinationFmgPageValue: fmgPageValues.ADDRESS_VEHICLES,
{ },
scenario: navigationScenarios.CLICKED_FORWARD, {
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS,
}, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
{ },
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, {
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
{ },
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, {
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
}, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
{ },
scenario: navigationScenarios.SELECTED_PROVIDE_VIN_DIFFERENT_WAY, {
destinationFmgPageValue: fmgPageValues.ESTIMATE scenario: navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS,
} destinationFmgPageValue: fmgPageValues.MOLDING_QUESTIONS
], },
}, {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS,
fmgPageValue: fmgPageValues.ESTIMATE, destinationFmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS
maps: [ }
{ ],
scenario: navigationScenarios.CLICKED_BACK, },
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, {
}, fmgPageValue: fmgPageValues.ADDRESS_VEHICLES,
{ maps: [
scenario: navigationScenarios.SELECTED_MANUAL_VIN, {
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, scenario: navigationScenarios.CLICKED_BACK,
}, destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP,
{ },
scenario: navigationScenarios.SELECTED_LICENSE_PLATE, {
destinationFmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP, scenario: navigationScenarios.CLICKED_FORWARD,
}, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
{ },
scenario: navigationScenarios.SELECTED_HOME_ADDRESS, {
destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP, scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
}, destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
], },
}, {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
fmgPageValue: fmgPageValues.PART_QUESTIONS, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
maps: [ },
{ {
scenario: navigationScenarios.CLICKED_BACK, scenario: navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP destinationFmgPageValue: fmgPageValues.MOLDING_QUESTIONS
}, },
{ {
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS, scenario: navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS destinationFmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS
}, },
{ {
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_SINGLE_PART, scenario: navigationScenarios.SELECTED_PROVIDE_VIN_DIFFERENT_WAY,
destinationFmgPageValue: fmgPageValues.QUOTE, destinationFmgPageValue: fmgPageValues.ESTIMATE
}, }
] ],
}, },
]; {
fmgPageValue: fmgPageValues.ESTIMATE,
maps: [
{
scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
},
{
scenario: navigationScenarios.SELECTED_MANUAL_VIN,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
},
{
scenario: navigationScenarios.SELECTED_LICENSE_PLATE,
destinationFmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP,
},
{
scenario: navigationScenarios.SELECTED_HOME_ADDRESS,
destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP,
},
],
},
{
fmgPageValue: fmgPageValues.PART_QUESTIONS,
maps: [
{
scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP
},
{
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
},
{
scenario: navigationScenarios.HAS_MOLDING_QUESTIONS,
destinationFmgPageValue: fmgPageValues.MOLDING_QUESTIONS,
},
{
scenario: navigationScenarios.HAS_CAPABILITY_QUESTIONS,
destinationFmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS,
},
{
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_SINGLE_PART,
destinationFmgPageValue: fmgPageValues.QUOTE,
},
]
},
{
fmgPageValue: fmgPageValues.MOLDING_QUESTIONS,
maps: [
{
scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
},
{
scenario: navigationScenarios.HAS_CAPABILITY_QUESTIONS,
destinationFmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS,
},
]
},
{
fmgPageValue: fmgPageValues.CAPABILITY_QUESTIONS,
maps: [
{
scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
},
]
},
];
}
export { routingTable }; export { routingTable };

View file

@ -8,6 +8,7 @@ import { storeActions } from "@/constants/store-actions";
import { applicationConfig } from "@/constants/application-config"; import { applicationConfig } from "@/constants/application-config";
import { experimentTriggers } from "@/constants/experiments"; import { experimentTriggers } from "@/constants/experiments";
import { damageLocationsSelected } from "@/constants/damage-locations-selected"; import { damageLocationsSelected } from "@/constants/damage-locations-selected";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
// Export State // Export State
const getDefaultState = () => { const getDefaultState = () => {
@ -50,8 +51,7 @@ const getDefaultState = () => {
partQuestionAnswers: null, partQuestionAnswers: null,
}, },
lineItems: { lineItems: {
glassParts: null, glassParts: null
otherParts: null
}, },
payment: { payment: {
isInsurance: null, isInsurance: null,
@ -69,10 +69,10 @@ const getDefaultState = () => {
pageData: {}, pageData: {},
savedSessionTimeout: getDateForSavedSessionTimeout(), savedSessionTimeout: getDateForSavedSessionTimeout(),
saveOrderPromise: null, saveOrderPromise: null,
saveQuoteId: null, savedSessionId: null,
crmCustomerId: null, crmCustomerId: null,
lastPageVisited: null, lastPageVisited: null,
experiments: {}, experiments: [],
triggeredSiteEntry: false triggeredSiteEntry: false
}, },
} }
@ -213,8 +213,8 @@ export const mutations = {
updateSaveOrderPromise(state, saveOrderPromise){ updateSaveOrderPromise(state, saveOrderPromise){
state.applicationUser.saveOrderPromise = saveOrderPromise; state.applicationUser.saveOrderPromise = saveOrderPromise;
}, },
updateSaveQuoteId(state, saveQuoteId) { updateSavedSessionId(state, savedSessionId) {
state.applicationUser.saveQuoteId = saveQuoteId; state.applicationUser.savedSessionId = savedSessionId;
}, },
updateCrmCustomerId(state, crmCustomerId) { updateCrmCustomerId(state, crmCustomerId) {
state.applicationUser.crmCustomerId = crmCustomerId; state.applicationUser.crmCustomerId = crmCustomerId;
@ -269,11 +269,15 @@ export const mutations = {
}, },
resetGlassPartsState(state) { resetGlassPartsState(state) {
state.order.lineItems.glassParts = null; state.order.lineItems.glassParts = null;
state.order.damage.partQuestionAnswers = null;
state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = null;
}, },
resetState(state) { resetState(state) {
Object.assign(state, getDefaultState()); Object.assign(state, getDefaultState());
}, },
resetSaveOrderPromise(state) {
state.applicationUser.saveOrderPromise = null;
},
// Misc Mutations // Misc Mutations
updateStateWithOrderInformation(state, orderInformation) { updateStateWithOrderInformation(state, orderInformation) {
state.order.referralNumber = orderInformation.referralNumber; state.order.referralNumber = orderInformation.referralNumber;
@ -358,16 +362,17 @@ export const getters = {
serviceZipCode: state.order.serviceLocation.zipCode, serviceZipCode: state.order.serviceLocation.zipCode,
parentAccountNumber: state.order.accountNumber, parentAccountNumber: state.order.accountNumber,
isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified,
orderPartNumbers: [...Object.values(state.order.lineItems.glassParts), ...Object.values(state.order.lineItems.otherParts)], // orderPartNumbers: [...Object.values(state.order.lineItems.glassParts ?? {}), ...Object.values(state.order.lineItems.otherParts ?? {})],
orderPartTypes: [...Object.keys(state.order.lineItems.glassParts), ...Object.keys(state.order.lineItems.otherParts)], // orderPartTypes: [...Object.keys(state.order.lineItems.glassParts ?? {}), ...Object.keys(state.order.lineItems.otherParts ?? {})],
hasRecalibrationPart: Object.values(state.order.lineItems.glassParts).filter(x => x.requiresRecalibration)?.length > 0, // hasRecalibrationPart: Object.values(state.order.lineItems.glassParts ?? {}).filter(x => x.requiresRecalibration)?.length > 0,
selectedMultiGlass: state.order.damage.glassToReplace.length > 1, // selectedMultiGlass: state.order.damage.glassToReplace.length > 1,
selectedWindshieldGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.WINDSHIELD), // selectedWindshieldGlass: Object.keys(state.order.damage.glassToReplace ?? []).map(x => x.split("-")[0]).includes(damageLocationsSelected.WINDSHIELD),
selectedBackGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.BACK), // selectedBackGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.BACK),
selectedDriverSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.DRIVER), // selectedDriverSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.DRIVER),
selectedPassengerSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.PASSENGER) // selectedPassengerSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.PASSENGER)
} }
} },
experimentSettings: (state) => state.applicationUser.experiments.map(x => x.settings).reduce((r, c) => Object.assign(r, c), {})
} }
// Export Actions // Export Actions
@ -490,6 +495,9 @@ export const actions = {
resetState(context) { resetState(context) {
context.commit(storeMutations.RESET_STATE); context.commit(storeMutations.RESET_STATE);
}, },
resetSaveOrderPromise(context) {
context.commit(storeMutations.RESET_SAVE_ORDER_PROMISE);
},
// Content API Actions // Content API Actions
getRouteInfo(context, { pageName }) { getRouteInfo(context, { pageName }) {
@ -530,12 +538,12 @@ export const actions = {
}, },
// Misc Actions // Misc Actions
updateStoreWithSaveOrderResponse(context, { referralNumber, referralDate, referralCorrelationId, accountNumber, saveQuoteId, crmCustomerId }) { updateStoreWithSaveOrderResponse(context, { referralNumber, referralDate, referralCorrelationId, accountNumber, savedSessionId, crmCustomerId }) {
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber); context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate); context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate);
context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId); context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId);
context.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, accountNumber); context.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, accountNumber);
context.commit(storeMutations.UPDATE_SAVE_QUOTE_ID, saveQuoteId); context.commit(storeMutations.UPDATE_SAVED_SESSION_ID, savedSessionId);
context.commit(storeMutations.UPDATE_CRM_CUSTOMER_ID, crmCustomerId); context.commit(storeMutations.UPDATE_CRM_CUSTOMER_ID, crmCustomerId);
}, },
@ -738,7 +746,7 @@ export const actions = {
existingPromoCode: null, existingPromoCode: null,
lastPage: applicationUser.lastPageVisited, lastPage: applicationUser.lastPageVisited,
crmCustomerId: applicationUser.crmCustomerId, crmCustomerId: applicationUser.crmCustomerId,
saveQuoteId: applicationUser.saveQuoteId, savedSessionId: applicationUser.savedSessionId,
}, },
}); });
@ -754,7 +762,10 @@ export const actions = {
accountNumber: accountNumber?.toString() accountNumber: accountNumber?.toString()
}, },
}).then((response) => { }).then((response) => {
context.commit(storeMutations.RESET_STATE); // clear the state if the existing referral number does not equal what is returned from loadOrder
if (context.state.order.referralNumber != response.data.referralNumber) {
context.commit(storeMutations.RESET_STATE);
}
context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data); context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data);
return response; return response;
}); });

View file

@ -574,7 +574,7 @@ describe("Actions", () => {
applicationUser: { applicationUser: {
lastPageVisited: "test-page", lastPageVisited: "test-page",
crmCustomerId: "xxx-xxx-xxx", crmCustomerId: "xxx-xxx-xxx",
saveQuoteId: "xxx-xxx-xxx" savedSessionId: "xxx-xxx-xxx"
} }
}; };
context.state = { context.state = {
@ -630,7 +630,7 @@ describe("Actions", () => {
referralDate: new Date().toUTCString(), referralDate: new Date().toUTCString(),
referralCorrelationId: "xxx-xxx-xxx", referralCorrelationId: "xxx-xxx-xxx",
accountNumber: "167132", accountNumber: "167132",
saveQuoteId: "xxx-xxx-xxx", savedSessionId: "xxx-xxx-xxx",
crmCustomerId: "xxx-xxx-xxx", crmCustomerId: "xxx-xxx-xxx",
}); });
@ -639,7 +639,7 @@ describe("Actions", () => {
expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_DATE, new Date().toUTCString()); expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_DATE, new Date().toUTCString());
expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx"); expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx");
expect(commit).toBeCalledWith(storeMutations.UPDATE_PARENT_ACCT_NUMBER, "167132"); expect(commit).toBeCalledWith(storeMutations.UPDATE_PARENT_ACCT_NUMBER, "167132");
expect(commit).toBeCalledWith(storeMutations.UPDATE_SAVE_QUOTE_ID, "xxx-xxx-xxx"); expect(commit).toBeCalledWith(storeMutations.UPDATE_SAVED_SESSION_ID, "xxx-xxx-xxx");
expect(commit).toBeCalledWith(storeMutations.UPDATE_CRM_CUSTOMER_ID, "xxx-xxx-xxx"); expect(commit).toBeCalledWith(storeMutations.UPDATE_CRM_CUSTOMER_ID, "xxx-xxx-xxx");
}); });

View file

@ -20,7 +20,7 @@
<label <label
tabindex="-1" tabindex="-1"
:for="buttonID" :for="buttonID"
:aria-labelledby="buttonID" :aria-label="buttonLabel"
class="d-flex flex-column justify-content-center py-3 px-4" class="d-flex flex-column justify-content-center py-3 px-4"
@mouseup="triggerButton()" @mouseup="triggerButton()"
> >
@ -78,6 +78,7 @@ export default {
validationRules: String, validationRules: String,
selectedValues: [Array, String], selectedValues: [Array, String],
hasError: Boolean, hasError: Boolean,
valueToLogType: String,
}, },
data() { data() {
return { return {
@ -92,10 +93,6 @@ export default {
: this.selectedValues[0]; : this.selectedValues[0];
} }
}, },
unmounted() { // needed to clear this button's selectedValues if it is removed
this.checkValue = false;
this.handleCheckChange();
},
methods: { methods: {
displayLoader() { displayLoader() {
this.isLoaderDisplayed = true; this.isLoaderDisplayed = true;
@ -120,7 +117,7 @@ export default {
this.handleCheckChange(); this.handleCheckChange();
} }
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true); this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true, this.valueToLogType);
}, },
handleCheckChange() { handleCheckChange() {
const emitEvent = { const emitEvent = {

View file

@ -3,6 +3,7 @@
class="list-group list-button rounded-3 d-flex flex-column w-100 mb-2" class="list-group list-button rounded-3 d-flex flex-column w-100 mb-2"
:class="[(errors.length > 0 || hasError) ? 'has-error' : '']" :class="[(errors.length > 0 || hasError) ? 'has-error' : '']"
@keyup.space="triggerButton" @keyup.space="triggerButton"
@keyup.enter="triggerButton"
@keyup.up="handleKeyupArrow" @keyup.up="handleKeyupArrow"
@keyup.down="handleKeyupArrow" @keyup.down="handleKeyupArrow"
@keyup.left="handleKeyupArrow" @keyup.left="handleKeyupArrow"
@ -15,11 +16,12 @@
:aria-required="isRequired" :aria-required="isRequired"
v-model="checkValue" v-model="checkValue"
@change="handleInputChange" @change="handleInputChange"
:aria-label="value"
> >
<label <label
tabindex="-1" tabindex="-1"
:for="buttonID" :for="buttonID"
:aria-labelledby="buttonID" :aria-label="buttonLabel"
class="d-flex flex-column justify-content-center py-3 px-4" class="d-flex flex-column justify-content-center py-3 px-4"
@mouseup="triggerButton" @mouseup="triggerButton"
> >
@ -73,10 +75,12 @@ export default {
// Field initial value // Field initial value
type: [String, Number], type: [String, Number],
default: "", default: "",
}, },
validationRules: String, validationRules: String,
selectedValues: [Array, String], selectedValues: [Array, String],
hasError: Boolean, hasError: Boolean,
valueToLogType: String,
}, },
data() { data() {
return { return {
@ -91,10 +95,6 @@ export default {
: this.selectedValues[0]; : this.selectedValues[0];
} }
}, },
unmounted() { // needed to clear this button's selectedValues if it is removed
this.checkValue = false;
this.handleCheckChange();
},
methods: { methods: {
displayLoader() { displayLoader() {
this.isLoaderDisplayed = true; this.isLoaderDisplayed = true;
@ -114,7 +114,7 @@ export default {
this.displayLoader(); this.displayLoader();
this.handleCheckChange(); this.handleCheckChange();
} }
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true); this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true, this.valueToLogType);
}, },
handleCheckChange() { handleCheckChange() {
const emitEvent = { const emitEvent = {

View file

@ -14,7 +14,6 @@ describe("list-card.vue", () => {
groupID: "checkbox-demo-1", groupID: "checkbox-demo-1",
groupName: "Checkbox 1", groupName: "Checkbox 1",
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -33,7 +32,6 @@ describe("list-card.vue", () => {
groupID: "radio-demo-1", groupID: "radio-demo-1",
groupName: "radio 1", groupName: "radio 1",
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -53,7 +51,6 @@ describe("list-card.vue", () => {
groupName: "radio 1", groupName: "radio 1",
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
buttonLabelSubCopy: "Test", buttonLabelSubCopy: "Test",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -73,7 +70,6 @@ describe("list-card.vue", () => {
groupName: "radio 1", groupName: "radio 1",
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
buttonLabelSubCopy: "Test", buttonLabelSubCopy: "Test",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -93,7 +89,6 @@ describe("list-card.vue", () => {
groupName: "radio 1", groupName: "radio 1",
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
buttonLabelSubCopy: "Test", buttonLabelSubCopy: "Test",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -113,7 +108,6 @@ describe("list-card.vue", () => {
groupName: "radio 1", groupName: "radio 1",
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
isRequired: true, isRequired: true,
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -135,7 +129,6 @@ describe("list-card.vue", () => {
isRequired: true, isRequired: true,
isWide: true, isWide: true,
buttonLabelSubCopy: "", buttonLabelSubCopy: "",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -157,7 +150,6 @@ describe("list-card.vue", () => {
isRequired: true, isRequired: true,
isWide: true, isWide: true,
buttonLabelSubCopy: "Button Subcopy", buttonLabelSubCopy: "Button Subcopy",
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -178,7 +170,6 @@ describe("list-card.vue", () => {
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
isRequired: true, isRequired: true,
isWide: false, isWide: false,
modelValue: ["List Card Checkbox"],
}, },
}); });
@ -199,13 +190,13 @@ describe("list-card.vue", () => {
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
isRequired: true, isRequired: true,
isWide: false, isWide: false,
modelValue: ["List Card Checkbox"], buttonID: 'list-card-id',
buttonID: 'list-card-id' selectedValues: "List Card Checkbox"
}, },
}); });
wrapper.vm.handleCheckChange(); wrapper.vm.handleCheckChange();
// Assert // Assert
expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{value: "List Card Checkbox", checkValue: "List Card Checkbox", buttonId: 'list-card-id'}]); expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{value: "List Card Checkbox", checkValue: true, buttonId: 'list-card-id'}]);
}); });
it("Should set checkValue data if selectedButtonIDs has value(s)", async () => { it("Should set checkValue data if selectedButtonIDs has value(s)", async () => {
@ -220,12 +211,11 @@ describe("list-card.vue", () => {
buttonImage: "windshield-damage.svg", buttonImage: "windshield-damage.svg",
isRequired: true, isRequired: true,
isWide: false, isWide: false,
modelValue: ["List Card Checkbox"], selectedValues: "Car-Front"
selectedValues: ["Car-Front"]
}, },
}); });
// Assert // Assert
expect(wrapper.componentVM.checkValue).toEqual("Car-Front"); expect(wrapper.componentVM.checkValue).toEqual(false);
}); });
it("Should set an initial value for validation if selectedValues include the value", async () => { it("Should set an initial value for validation if selectedValues include the value", async () => {
@ -234,7 +224,6 @@ describe("list-card.vue", () => {
propsData: { propsData: {
value: "Windshield", value: "Windshield",
groupName: "radio 1", groupName: "radio 1",
modelValue: ["Windshield"],
selectedValues: ["Windshield"], selectedValues: ["Windshield"],
}, },
}); });

View file

@ -7,11 +7,11 @@
isWide ? 'horizontal' : '', isWide ? 'horizontal' : '',
(errors.length > 0 || hasError) ? 'has-error' : '', (errors.length > 0 || hasError) ? 'has-error' : '',
]" ]"
@keyup.space="triggerButton()" @keyup.space="triggerButton"
@keyup.up="handleKeyupArrow()" @keyup.up="handleKeyupArrow"
@keyup.down="handleKeyupArrow()" @keyup.down="handleKeyupArrow"
@keyup.left="handleKeyupArrow()" @keyup.left="handleKeyupArrow"
@keyup.right="handleKeyupArrow()" @keyup.right="handleKeyupArrow"
> >
<input <input
:type="isMultiSelect ? 'checkbox' : 'radio'" :type="isMultiSelect ? 'checkbox' : 'radio'"
@ -26,7 +26,7 @@
<label <label
tabindex="-1" tabindex="-1"
:for="buttonID" :for="buttonID"
:aria-labelledby="buttonID" :aria-label="buttonLabel"
class="d-flex w-100 align-items-center px-2 h-100" class="d-flex w-100 align-items-center px-2 h-100"
:class="getLabelClasses" :class="getLabelClasses"
@mouseup="triggerButton" @mouseup="triggerButton"
@ -87,33 +87,27 @@ export default {
colLength: String, colLength: String,
validationRules: String, validationRules: String,
selectedValues: [Array, String], selectedValues: [Array, String],
modelValue: Object,
hasError: Boolean, hasError: Boolean,
valueToLogType: String,
}, },
data() { data() {
return { return {
checkValue: null, checkValue: null,
} }
}, },
created() { mounted() {
if (Array.isArray(this.selectedValues)) { if (Array.isArray(this.validateValue)) {
this.checkValue = this.isMultiSelect this.checkValue = this.isValueSelectedByArray(this.selectedValues);
? this.selectedValues.includes(this.value) const isSelectedByValidator = this.isValueSelectedByArray(this.validateValue);
: this.selectedValues[0];
} if (this.checkValue != isSelectedByValidator) {
else if (Array.isArray(this.modelValue)) { this.handleChange(this.value);
this.checkValue = this.isMultiSelect }
? this.modelValue.includes(this.value)
: this.modelValue[0];
} }
else { else {
this.checkValue = this.selectedValues == this.value || this.modelValue == this.value; this.checkValue = this.selectedValues == this.value;
} }
}, },
unmounted() { // needed to clear this button's selectedValues if it is removed
this.checkValue = false;
this.handleCheckChange();
},
computed: { computed: {
getLabelClasses() { getLabelClasses() {
if (this.isWide) { if (this.isWide) {
@ -128,10 +122,15 @@ export default {
}, },
}, },
methods: { methods: {
isValueSelectedByArray(arr) {
return this.isMultiSelect
? arr.includes(this.value)
: arr[0];
},
handleInputChange() { handleInputChange() {
if(!this.selectingInitiatesLoad) { if(!this.selectingInitiatesLoad) {
this.handleCheckChange(); this.handleCheckChange();
} }
}, },
handleKeyupArrow() { handleKeyupArrow() {
if (this.isMultiSelect) { if (this.isMultiSelect) {
@ -148,7 +147,7 @@ export default {
this.handleCheckChange(); this.handleCheckChange();
} }
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true); this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true, this.valueToLogType);
}, },
handleCheckChange() { handleCheckChange() {
const emitEvent = { const emitEvent = {
@ -159,20 +158,13 @@ export default {
this.handleChange(this.value); this.handleChange(this.value);
this.$emit("isCheckedChanged", emitEvent); this.$emit("isCheckedChanged", emitEvent);
this.$emit("update:modelValue", emitEvent);
}, },
}, },
watch: { watch: {
// Changing this will impact pre-selection data loads on vehicle-parts. // Changing this will impact pre-selection data loads on vehicle-parts.
// If changed, please regression test that vehicle-parts data still loads correctly with previous selections. // If changed, please regression test that vehicle-parts data still loads correctly with previous selections.
modelValue(newVal) {
if (newVal !== undefined) {
this.checkValue = newVal.value;
}
},
selectedValues(newVal) { selectedValues(newVal) {
if (typeof newVal === "string") { if (typeof newVal === "string") {
this.handleChange(newVal);
this.checkValue = newVal == this.value; this.checkValue = newVal == this.value;
} }
else if (newVal !== undefined) { else if (newVal !== undefined) {
@ -198,11 +190,16 @@ export default {
const { const {
handleChange, handleChange,
errors, errors,
value
} = useField(toRef(props, "groupName"), toRef(props, "validationRules"), fieldOptions); } = useField(toRef(props, "groupName"), toRef(props, "validationRules"), fieldOptions);
// First land on the blank, unselected page, no handleChange
// Land on page with initial values, handleChange
const validateValue = value;
return { return {
handleChange, handleChange,
errors, errors,
validateValue,
fieldOptions, // only need to expose this for unit test purposes fieldOptions, // only need to expose this for unit test purposes
}; };
}, },

View file

@ -1,6 +1,7 @@
import { shallowMount } from "@vue/test-utils"; import { shallowMount } from "@vue/test-utils";
import radio from "./radio"; import radio from "./radio";
import { nextTick } from "vue"; import { nextTick } from "vue";
import { GaActions } from "@/constants/analytics";
describe("radio.vue", () => { describe("radio.vue", () => {
it("Should return group name", async () => { it("Should return group name", async () => {
@ -64,6 +65,13 @@ describe("radio.vue", () => {
it("Should emit button value on click", async () => { it("Should emit button value on click", async () => {
// Act // Act
const wrapper = shallowMount(radio, { const wrapper = shallowMount(radio, {
global: {
mocks: {
'$route': { query: { fmgPage: 'page-name' } },
GaActions: GaActions,
pushEventToGA: jest.fn(),
}
},
propsData: { propsData: {
buttonLabel: "Windshield", buttonLabel: "Windshield",
value: "List Card Checkbox", value: "List Card Checkbox",
@ -77,12 +85,20 @@ describe("radio.vue", () => {
}); });
wrapper.vm.handleCheckChange(); wrapper.vm.handleCheckChange();
// Assert // Assert
expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{"buttonID": "List Card Checkbox", value: "List Card Checkbox", checkValue: false}]); expect(wrapper.emitted()["isCheckedChanged"][0]).toEqual([{"buttonID": "List Card Checkbox", value: "List Card Checkbox", checkValue: false}]);;
expect(wrapper.vm.pushEventToGA).toHaveBeenCalled();
}); });
it("Should set checkValue data if selectedButtonIDs has value(s)", async () => { it("Should set checkValue data if selectedButtonIDs has value(s)", async () => {
// Act // Act
const wrapper = shallowMount(radio, { const wrapper = shallowMount(radio, {
global: {
mocks: {
'$route': { query: { fmgPage: 'page-name' } },
GaActions: GaActions,
pushEventToGA: jest.fn(),
}
},
propsData: { propsData: {
buttonLabel: "Windshield", buttonLabel: "Windshield",
buttonID: "List Card Checkbox", buttonID: "List Card Checkbox",

View file

@ -25,6 +25,8 @@
<script> <script>
import { useField } from "vee-validate"; import { useField } from "vee-validate";
import { queryStrings } from "@/constants/query-strings";
export default { export default {
name: "radio", name: "radio",
props: { props: {
@ -39,7 +41,8 @@ export default {
screenReaderOnlyText: String, screenReaderOnlyText: String,
selectedValues: String, selectedValues: String,
hasError: Boolean, hasError: Boolean,
validationRules: String validationRules: String,
valueToLogType: String,
}, },
data() { data() {
return { return {
@ -65,6 +68,8 @@ export default {
this.$emit("isCheckedChanged", emitEvent); this.$emit("isCheckedChanged", emitEvent);
this.$emit("update:modelValue", emitEvent); this.$emit("update:modelValue", emitEvent);
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, this.value.toString(), true, this.valueToLogType);
}, },
}, },
setup(props) { setup(props) {