From 635913934242d928c32248a5931fc10ecea30abd Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 2 Aug 2022 12:17:35 -0400 Subject: [PATCH 01/12] CSR-690 Implement navigation to and from heritage --- src/constants/store-mutations.js | 1 + src/global-methods.js | 7 +++- .../heritage-integration/cookie-helper.js | 3 +- .../heritage-integration/navigation-helper.js | 42 ++++++++++++++----- .../heritage-integration/session-helper.js | 25 +++++++---- .../capability-questions.vue | 2 +- src/layouts/estimate/estimate.vue | 5 +-- .../molding-questions/molding-questions.vue | 2 +- src/layouts/vehicle-damage/vehicle-damage.vue | 5 +-- src/layouts/vehicle-make/vehicle-make.vue | 5 ++- src/layouts/vehicle-parts/vehicle-parts.vue | 11 +++-- src/mixins/vehicle-questions-mixin.js | 8 ++-- src/router/index.js | 2 + src/router/router-constants/fmgPage-values.js | 3 +- src/store/index.js | 22 +++++++--- 15 files changed, 95 insertions(+), 48 deletions(-) diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 508f59bf7..44e43ff3e 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -39,6 +39,7 @@ const storeMutations = { UPDATE_REFERRAL_DATE: "updateReferralDate", UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId", UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber", + UPDATE_EON: "updateEON", UPDATE_SAVED_SESSION_ID: "updateSavedSessionId", UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId", diff --git a/src/global-methods.js b/src/global-methods.js index ffda1e77f..4a2026764 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -9,7 +9,12 @@ import { headerKeys } from "@/constants/header-keys"; export default { callHttpClient({ method, endpoint, payload, logApiCall = true }) { return new Promise((resolve, reject) => { - const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + // const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + + let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + if (endpoint.includes("/order/")) + cfDistroUrl = "https://localhost:44346" + const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); const headers = { [headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings) diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index 775a64fec..fa475beff 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -1,6 +1,7 @@ import { cookieNames } from "@/constants/cookie-names"; import store from "@/store"; import { applicationConfig } from "@/constants/application-config"; +// import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; /* Will update the cookie if present, or create a new one if not. @@ -15,7 +16,7 @@ export function updateOrCreateFunnelCookie() { // Set up cookie with all the props. setFunnelCookieProperties({ LastTouched: new Date().toUTCString(), - SavedSessionTimeoutDate: store.getters.applicationUser.savedSessionTimeout, + // SavedSessionTimeoutDate: getDateForSavedSessionTimeout(), DidHeritageFunnelUpdateLast: false, ShouldResetState: false, ReferralNumber: store.getters.order.referralNumber, diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 3ebb7ded8..c3ec9445a 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -16,7 +16,7 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita if (toRoute.query[queryStrings.START_TYPE] === 'fmg') { // If they have an existing order, return 'heritage' for the page name. if (existingHeritageOrder) { - return 'heritage'; + return fmgPageValues.HERITAGE; } return await getLatestPageForRedirection(); @@ -61,11 +61,16 @@ async function getLatestPageForRedirection() { // If this is a non-CTA navigation, determine where to send the user based on page prerequisites. // This also works if a user has a 'fmg' start_type query string but no current order. // That shouldn't happen, but it's possible. - const vehicleMakeComponent = (await lazyLoadComponent('vehicle-make')()).default; - const vehicleModelComponent = (await lazyLoadComponent('vehicle-model')()).default; - const vehicleStyleComponent = (await lazyLoadComponent('vehicle-style')()).default; - const vehicleDamageComponent = (await lazyLoadComponent('vehicle-damage')()).default; - + const vehicleMakeComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MAKE);//(await lazyLoadComponent('vehicle-make')()).default; + const vehicleModelComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MODEL);//(await lazyLoadComponent('vehicle-model')()).default; + const vehicleStyleComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_STYLE);//(await lazyLoadComponent('vehicle-style')()).default; + const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE);//(await lazyLoadComponent('vehicle-damage')()).default; + const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE); + const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP); + const partQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.PART_QUESTIONS);//(await lazyLoadComponent('part-questions')()).default; + const vehiclePartsComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_PARTS); + const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_QUESTIONS); + const capabilityQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.CAPABILITY_QUESTIONS);//(await lazyLoadComponent('capability-questions')()).default if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VEHICLE_YEAR; @@ -75,15 +80,28 @@ async function getLatestPageForRedirection() { return fmgPageValues.VEHICLE_MODEL; } else if (!vehicleDamageComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VEHICLE_STYLE; - } else if (store.getters.damage.isRepair == null || !store.getters.vehicle.carId) { + } else if (!estimateComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VEHICLE_DAMAGE; } else { - if (store.getters.vehicle.vin) { + if (capabilityQuestionsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.CAPABILITY_QUESTIONS; + } + else if (moldingQuestionsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.MOLDING_QUESTIONS; + } + else if (vehiclePartsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.VEHICLE_PARTS; + } + else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) { + return fmgPageValues.PART_QUESTIONS; + } + else if (store.getters.vehicle.vin) { return fmgPageValues.VIN_LOOKUP; - } else { + } + else { return fmgPageValues.ESTIMATE; } - } + } } /* @@ -126,4 +144,8 @@ function isVinRelatedPage(toRoute) { fmgPageValue === fmgPageValues.ADDRESS_LOOKUP || fmgPageValue === fmgPageValues.ADDRESS_VEHICLES || fmgPageValue === fmgPageValues.ESTIMATE; +} + +async function getLazyLoadedComponent(pageName) { + return (await lazyLoadComponent(pageName)()).default; } \ No newline at end of file diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index ca50a4e7b..c03288b42 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -28,23 +28,34 @@ export function isAnalyticsSessionStillActive() { */ export function isSavedSessionStillActive() { if (getFunnelCookie() !== null) { - const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate); + const savedSessionTimeStamp = new Date(getSavedSessionTimeoutDate()); const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp); - if (isSavedSessionTimedOut) { - return false; - } - - return true; + return !isSavedSessionTimedOut; } } /* -Function to get the date for the saved session timeout. +Function to calculate the date for the saved session timeout. */ export function getDateForSavedSessionTimeout() { const currentDate = new Date(new Date().toUTCString()) currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) return currentDate.toUTCString(); +} + +/** Function to get saved session timeout date based on values in the cookie */ +function getSavedSessionTimeoutDate() { + console.log("getFunnelCookie()?.LastTouched: ", getFunnelCookie()?.LastTouched) + let lastTouched = new Date(getFunnelCookie()?.LastTouched); + lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); + let savedSessionTimeoutDate = lastTouched; + savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); + + // const test = lastTouched + // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) + // : getDateForSavedSessionTimeout(); + + return savedSessionTimeoutDate; } \ No newline at end of file diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index 69fc8aad5..a29aa3779 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -112,7 +112,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - return true; // TODO - DO TRUE TEST OF PAGEDATA + return false; // TODO - DO TRUE TEST OF PAGEDATA // return Object.keys(store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS)).length > 0; }, showThisPartQuestionChain(part, i) { diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index 3949d4c41..3cc6b1149 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -80,10 +80,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - if(store.getters.damage.isRepair!=null){ - return true; - } - return false; + return store.getters.damage.isRepair != null; }, backButtonAction() { // route to move backwards diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index d2b469a36..f575c9240 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -115,7 +115,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - return true; // TODO - DO TRUE TEST OF PAGEDATA + return false; // TODO - DO TRUE TEST OF PAGEDATA // return Object.keys(store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS)).length > 0; }, showThisPartQuestionChain(part, i) { diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 7d61814f8..a00c91a85 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -155,10 +155,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - if(store.getters.vehicle.carId){ - return true; - } - return false; + return store.getters.vehicle.carId; }, attachCustomEvents(){ diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index 8cd77c545..4a2eff8f9 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -76,9 +76,10 @@ export default { ); }, arePagePrerequisitesValid() { - if (store.getters.vehicle.year){ - return true; + if (store.getters.vehicle.year){ + return true; } + return false; }, }, diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 290910217..103af885b 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -155,11 +155,11 @@ export default { methods: { arePagePrerequisitesValid() { // Check if isRepair is populated and if the pageData we need is here (Parts data) - return store.getters.damage.isRepair != null && + return store.getters.damage.isRepair != null && store.getters.pageData(fmgPageValues.VEHICLE_PARTS) && Object.keys(store.getters.pageData(fmgPageValues.VEHICLE_PARTS)).length !== 0; }, backButtonAction() { - const hasPartQuestions = this.hasPartQuestions(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS).partsOrQuestions); + const hasPartQuestions = this.hasPartQuestions(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions); const backNavigationScenario = hasPartQuestions ? this.navigationScenarios.CLICKED_BACK_WITH_PART_QUESTION_ANSWERS : this.navigationScenarios.CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS; this.$router.navigate( @@ -175,7 +175,6 @@ export default { 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( @@ -184,9 +183,9 @@ export default { if (isMatched) { matchedParts.push({ - "glassLocation": value.glassLocation, - "glassName": value.glassName, - "parts": [currentPart] + glassLocation: value.glassLocation, + glassName: value.glassName, + parts: [currentPart] }); } } diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 7a86066a8..1a28fe028 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -2,18 +2,18 @@ export default { methods: { hasPartQuestions(partsOrQuestions) { - return partsOrQuestions.some(pq => pq.partQuestions?.length > 0); + return partsOrQuestions?.some(pq => pq.partQuestions?.length > 0); }, hasGlassLocationWithMultipleParts(partsOrQuestions) { - return partsOrQuestions.some(pq => pq.parts?.length > 1); + return partsOrQuestions?.some(pq => pq.parts?.length > 1); }, hasChildPartQuestions(partsOrQuestions) { - return partsOrQuestions.some(pq => { + return partsOrQuestions?.some(pq => { return pq.parts?.some(part => part.childPartQuestions?.length > 0); }); }, hasCapabilityQuestions(partsOrQuestions) { - return partsOrQuestions.some(pq => { + return partsOrQuestions?.some(pq => { return pq.parts?.some(part => part.requiresCapabilityQuestions === true); }); }, diff --git a/src/router/index.js b/src/router/index.js index 767b9ab18..4295ae491 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -224,6 +224,8 @@ function navigateToUrl(url, optionalQuery = {}) { externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]); } + externalUrl.searchParams.append("experiments", "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"); + window.location.assign(externalUrl); } diff --git a/src/router/router-constants/fmgPage-values.js b/src/router/router-constants/fmgPage-values.js index 404a89de9..d924e30de 100644 --- a/src/router/router-constants/fmgPage-values.js +++ b/src/router/router-constants/fmgPage-values.js @@ -14,7 +14,8 @@ const fmgPageValues = { REVEAL: "reveal", ESTIMATE: "estimate", ADDRESS_VEHICLES: "address-vehicles", - QUOTE: "quote" + QUOTE: "quote", + HERITAGE: "heritage" }; export { fmgPageValues }; diff --git a/src/store/index.js b/src/store/index.js index 44dfccfcc..28d231316 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -60,11 +60,12 @@ const getDefaultState = () => { referralDate: null, referralCorrelationId: null, accountNumber: 0, + eon: null }, applicationUser: { eventBus: [], pageData: {}, - savedSessionTimeout: getDateForSavedSessionTimeout(), + // savedSessionTimeout: getDateForSavedSessionTimeout(), saveOrderPromise: null, savedSessionId: null, crmCustomerId: null, @@ -139,6 +140,9 @@ export const mutations = { updateParentAcctNumber(state, parentAcctNumber) { state.order.accountNumber = parentAcctNumber; }, + updateEON(state, eon) { + state.order.eon = eon; + }, updateIsInsurance(state, isInsurance) { state.order.payment.isInsurance = isInsurance; }, @@ -279,6 +283,7 @@ export const mutations = { state.order.referralNumber = orderInformation.referralNumber; state.order.referralDate = orderInformation.referralDate; state.order.referralCorrelationId = orderInformation.referralCorrelationId; + state.order.eon = orderInformation.eon; state.order.vehicle = Object.assign(state.order.vehicle, { year: orderInformation.vehicle?.year, @@ -504,10 +509,11 @@ export const actions = { }, // Misc Actions - updateStoreWithSaveOrderResponse(context, { referralNumber, referralDate, referralCorrelationId, accountNumber, savedSessionId, crmCustomerId }) { + updateStoreWithSaveOrderResponse(context, { referralNumber, referralDate, referralCorrelationId, eon, accountNumber, savedSessionId, crmCustomerId }) { context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber); context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate); context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId); + context.commit(storeMutations.UPDATE_EON, eon); context.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, accountNumber); context.commit(storeMutations.UPDATE_SAVED_SESSION_ID, savedSessionId); context.commit(storeMutations.UPDATE_CRM_CUSTOMER_ID, crmCustomerId); @@ -574,10 +580,11 @@ export const actions = { }, // Misc Actions - setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId }) { + setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId, eon }) { context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber); context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate); context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId); + context.commit(storeMutations.UPDATE_EON, eon); }, GetExperimentsByUser(context, { userId }) { @@ -650,6 +657,7 @@ export const actions = { const damage = context.getters.damage; const order = context.state.order; const applicationUser = context.getters.applicationUser; + const lineItems = context.state.order.lineItems; return globalMethods.callHttpClient({ method: endpoints.SaveOrder.method, @@ -680,6 +688,9 @@ export const actions = { customer: { emailAddress: order.customer.emailAddress, }, + lineItems: { + glassParts: lineItems.glassParts + }, serviceLocation: { streetAddress: order.serviceLocation.address, city: order.serviceLocation.city, @@ -693,7 +704,6 @@ export const actions = { lastPage: applicationUser.lastPageVisited, crmCustomerId: applicationUser.crmCustomerId, savedSessionId: applicationUser.savedSessionId, - }, }); }, @@ -708,8 +718,8 @@ export const actions = { accountNumber: accountNumber?.toString() }, }).then((response) => { - // clear the state if the existing referral number does not equal what is returned from loadOrder - if (context.state.order.referralNumber != response.data.referralNumber) { + // clear the state if the existing EON does not equal what is returned from loadOrder + if (context.state.order.eon && context.state.order.eon != response.data.eon) { context.commit(storeMutations.RESET_STATE); } context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data); From 7d7896a0121a74308028d8159733e7e0b03025d0 Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 2 Aug 2022 15:32:11 -0400 Subject: [PATCH 02/12] CSR-690 Fix issue with part-questions back --- src/helpers/heritage-integration/session-helper.js | 1 - src/layouts/part-questions/part-questions.vue | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index c03288b42..cf58846f0 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -47,7 +47,6 @@ export function getDateForSavedSessionTimeout() { /** Function to get saved session timeout date based on values in the cookie */ function getSavedSessionTimeoutDate() { - console.log("getFunnelCookie()?.LastTouched: ", getFunnelCookie()?.LastTouched) let lastTouched = new Date(getFunnelCookie()?.LastTouched); lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); let savedSessionTimeoutDate = lastTouched; diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index db237ce2b..a4ccaff48 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -175,7 +175,8 @@ export default { } }, arePagePrerequisitesValid() { - return Object.keys(store.getters.pageData(fmgPageValues.PART_QUESTIONS)).length > 0; + const partQuestionsFromPageData = store.getters.pageData(fmgPageValues.PART_QUESTIONS); + return partQuestionsFromPageData && Object.keys(partQuestionsFromPageData).length > 0; }, }, watch: { From 9248a5b3b2817f8db0251e309a03161c02af2b30 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 3 Aug 2022 12:01:43 -0400 Subject: [PATCH 03/12] CSR-690 --- src/helpers/heritage-integration/cookie-helper.js | 4 ++-- src/layouts/vehicle-damage/vehicle-damage.vue | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index fa475beff..4af74bb80 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -1,7 +1,7 @@ import { cookieNames } from "@/constants/cookie-names"; import store from "@/store"; import { applicationConfig } from "@/constants/application-config"; -// import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; +import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; /* Will update the cookie if present, or create a new one if not. @@ -16,7 +16,7 @@ export function updateOrCreateFunnelCookie() { // Set up cookie with all the props. setFunnelCookieProperties({ LastTouched: new Date().toUTCString(), - // SavedSessionTimeoutDate: getDateForSavedSessionTimeout(), + SavedSessionTimeoutDate: getDateForSavedSessionTimeout(), DidHeritageFunnelUpdateLast: false, ShouldResetState: false, ReferralNumber: store.getters.order.referralNumber, diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index a00c91a85..42e150c90 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -155,7 +155,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - return store.getters.vehicle.carId; + return store.getters.vehicle.carId != null; }, attachCustomEvents(){ From 74b86c80d2af35a6dbc81e1d034a25aa3765c078 Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 5 Aug 2022 08:36:23 -0400 Subject: [PATCH 04/12] CSR-690 Add savedSessionTimeoutDate stuff back --- .../heritage-integration/cookie-helper.js | 4 ++-- .../heritage-integration/session-helper.js | 22 +++++++++---------- src/store/index.js | 13 ++++++++++- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index 4af74bb80..f466bb9b8 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -1,7 +1,7 @@ import { cookieNames } from "@/constants/cookie-names"; import store from "@/store"; import { applicationConfig } from "@/constants/application-config"; -import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; +// import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; /* Will update the cookie if present, or create a new one if not. @@ -16,7 +16,7 @@ export function updateOrCreateFunnelCookie() { // Set up cookie with all the props. setFunnelCookieProperties({ LastTouched: new Date().toUTCString(), - SavedSessionTimeoutDate: getDateForSavedSessionTimeout(), + SavedSessionTimeoutDate: store.getters.applicationUser.savedSessionTimeout, DidHeritageFunnelUpdateLast: false, ShouldResetState: false, ReferralNumber: store.getters.order.referralNumber, diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index cf58846f0..a5118a21d 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -28,7 +28,7 @@ export function isAnalyticsSessionStillActive() { */ export function isSavedSessionStillActive() { if (getFunnelCookie() !== null) { - const savedSessionTimeStamp = new Date(getSavedSessionTimeoutDate()); + const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate); const isSavedSessionTimedOut = (new Date(new Date().toUTCString()) > savedSessionTimeStamp); return !isSavedSessionTimedOut; @@ -46,15 +46,15 @@ export function getDateForSavedSessionTimeout() { } /** Function to get saved session timeout date based on values in the cookie */ -function getSavedSessionTimeoutDate() { - let lastTouched = new Date(getFunnelCookie()?.LastTouched); - lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); - let savedSessionTimeoutDate = lastTouched; - savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); +// function getSavedSessionTimeoutDate() { +// let lastTouched = new Date(getFunnelCookie()?.LastTouched); +// lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); +// let savedSessionTimeoutDate = lastTouched; +// savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); - // const test = lastTouched - // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) - // : getDateForSavedSessionTimeout(); +// // const test = lastTouched +// // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) +// // : getDateForSavedSessionTimeout(); - return savedSessionTimeoutDate; -} \ No newline at end of file +// return savedSessionTimeoutDate; +// } \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 28d231316..7db358c1e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -65,7 +65,7 @@ const getDefaultState = () => { applicationUser: { eventBus: [], pageData: {}, - // savedSessionTimeout: getDateForSavedSessionTimeout(), + savedSessionTimeout: getDateForSavedSessionTimeout(), saveOrderPromise: null, savedSessionId: null, crmCustomerId: null, @@ -271,6 +271,9 @@ export const mutations = { state.order.lineItems.glassParts = null; state.order.damage.partQuestionAnswers = null; state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = null; + state.applicationUser.pageData[fmgPageValues.VEHICLE_PARTS] = null; + state.applicationUser.pageData[fmgPageValues.MOLDING_QUESTIONS] = null; + state.applicationUser.pageData[fmgPageValues.CAPABILITY_QUESTIONS] = null; }, resetState(state) { Object.assign(state, getDefaultState()); @@ -746,6 +749,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_YEAR, year); @@ -766,6 +770,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_MAKE, make); @@ -785,6 +790,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_MODEL, model); @@ -802,6 +808,7 @@ export const actions = { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); //Save new values context.commit(storeMutations.UPDATE_STYLE, style); @@ -832,6 +839,7 @@ export const actions = { //Reset dependent state when changing if (vehicleInfo.vin !== context.state.order.vehicle.vin) { context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); @@ -850,6 +858,7 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values @@ -865,6 +874,7 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values @@ -890,6 +900,7 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values From 4980a7bc914cb1a2a7c249aa900d5bc0f9fd7fe4 Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 9 Aug 2022 10:16:29 -0400 Subject: [PATCH 05/12] CSR-690 Clear parts questions when coming back from heritage with a different vehicle --- src/store/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index 7db358c1e..014ba7ec7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -288,6 +288,13 @@ export const mutations = { state.order.referralCorrelationId = orderInformation.referralCorrelationId; state.order.eon = orderInformation.eon; + if (state.order.vehicle.vin !== orderInformation.vehicle?.vin) { + state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = null; + state.applicationUser.pageData[fmgPageValues.VEHICLE_PARTS] = null; + state.applicationUser.pageData[fmgPageValues.MOLDING_QUESTIONS] = null; + state.applicationUser.pageData[fmgPageValues.CAPABILITY_QUESTIONS] = null; + } + state.order.vehicle = Object.assign(state.order.vehicle, { year: orderInformation.vehicle?.year, make: orderInformation.vehicle?.make, From 11016372a380f369f1938d7670d09e04fe43fd3e Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 09:13:43 -0400 Subject: [PATCH 06/12] CSR-690 Fix tests --- .../heritage-integration/navigation-helper.js | 2 +- .../navigation-helper.spec.js | 260 +++++------------- src/store/store.spec.js | 23 +- 3 files changed, 82 insertions(+), 203 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index c3ec9445a..e459a32b4 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -95,7 +95,7 @@ async function getLatestPageForRedirection() { else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.PART_QUESTIONS; } - else if (store.getters.vehicle.vin) { + else if (vinLookupComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VIN_LOOKUP; } else { diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index 0e615aef5..8cc72284b 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -5,9 +5,11 @@ import { storeActions } from "@/constants/store-actions"; import { setupMocksForJsFiles, getMockOrderInfo } from "@/helpers/unit-test-helper.js"; import { externalUrls } from "@/router/router-constants/externalUrl-values"; import { queryStrings } from "@/constants/query-strings"; +import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import store from "@/store"; import router from "@/router"; +import { lazy } from "yup"; // Mock Lazy Load jest.mock("@/router/dynamic-routing/component-loader.js", () => ({ @@ -23,43 +25,9 @@ describe("getPageToRouteExistingOrderTo", () => { }; // Mock out the lazy load calls for all components. - lazyLoadComponent - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(false) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(false) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(false) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(false) - } - } - } - }); + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: false + }) // Act const result = await getPageToRouteExistingOrderTo(toRoute, false); @@ -75,43 +43,11 @@ describe("getPageToRouteExistingOrderTo", () => { }; // Mock out the lazy load calls for all components. - lazyLoadComponent - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(false) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(false) - } - } - } - }); + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: false, + }) // Act const result = await getPageToRouteExistingOrderTo(toRoute, false); @@ -127,46 +63,13 @@ describe("getPageToRouteExistingOrderTo", () => { }; // Mock out the lazy load calls for all components. - lazyLoadComponent - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }); - - store.getters.damage.isRepair = undefined; - store.getters.vehicle.carId = 'C00000'; + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: false + }) // Act const result = await getPageToRouteExistingOrderTo(toRoute, false); @@ -175,54 +78,25 @@ describe("getPageToRouteExistingOrderTo", () => { expect(result).toBe('vehicle-damage'); }); - test("getPageToRouteExistingOrderTo, should return vin-lookup", async () => { + test("getPageToRouteExistingOrderTo, user has YMMS and no vehicle questions should return vin-lookup", async () => { // Arrange const toRoute = { query: {} }; // Mock out the lazy load calls for all components. - lazyLoadComponent - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }); - - store.getters.damage.isRepair = true; - store.getters.vehicle.carId = 'C00000'; - store.getters.vehicle.vin = "1FADP3F26DL212886" + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: false, + [fmgPageValues.VIN_LOOKUP]: true, + }) // Act const result = await getPageToRouteExistingOrderTo(toRoute, false); @@ -231,54 +105,26 @@ describe("getPageToRouteExistingOrderTo", () => { expect(result).toBe('vin-lookup'); }); - test("getPageToRouteExistingOrderTo, should return estimate", async () => { + test("getPageToRouteExistingOrderTo, user has YMMS but no questions or carId should return estimate", async () => { // Arrange const toRoute = { query: {} }; // Mock out the lazy load calls for all components. - lazyLoadComponent - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }) - .mockReturnValueOnce(() => { - return { - default: { - methods: { - arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(true) - } - } - } - }); + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: false, + [fmgPageValues.VIN_LOOKUP]: false, + }) - store.getters.damage.isRepair = true; - store.getters.vehicle.carId = 'C00000'; - store.getters.vehicle.vin = null; // Act const result = await getPageToRouteExistingOrderTo(toRoute, false); @@ -401,4 +247,22 @@ describe("navigateToHeritageFunnel", () => { expect(router.navigateToExternalUrl).toHaveBeenCalled(); saveOrderFunction.mockRestore(); }); -}); \ No newline at end of file +}); + +/** + * `arePagePrerequisitesValidObject` is an object where the keys are fmgPageValue names and the values are booleans that indicate + * whether arePagePrerequisitesValid is true or false + */ +function mockLazyLoadComponentReturnValues(arePagePrerequisitesValidObject = {}) { + lazyLoadComponent.mockImplementation((pageName) => { + return async () => { + return Promise.resolve({ + default: { + methods: { + arePagePrerequisitesValid: jest.fn().mockReturnValueOnce(arePagePrerequisitesValidObject[pageName]) + } + } + }) + } + }) +} diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 29f8a88ed..84b8a46d7 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -575,12 +575,13 @@ describe("Actions", () => { lastPageVisited: "test-page", crmCustomerId: "xxx-xxx-xxx", savedSessionId: "xxx-xxx-xxx" - } + }, }; context.state = { order: { serviceLocation: {}, - customer: {} + customer: {}, + lineItems: {} }, }; @@ -793,13 +794,27 @@ describe("Actions", () => { // Act - const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: 'C010101', vin: "XXXXX" }, registrationInfo: { zipCode: "80020" }, serviceLocationInfo: { state: "CO" }, customerEmail: "test@safleite.com" }; + const payload = { + isCarIdDifferent: true, + isSelectedGlassAvailableForVehicle: false, + vehicleInfo: { + carId: 'C010101', vin: "XXXXX" + }, + registrationInfo: { + zipCode: "80020" + }, + serviceLocationInfo: { + state: "CO" + }, + customerEmail: "test@safleite.com" + }; actions.saveVinLookup(context, payload); // Assert expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); + expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); From 00d62b483fa73470bc132de6348abd7b720351f7 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 09:18:41 -0400 Subject: [PATCH 07/12] CSR-690 Cleanup --- src/global-methods.js | 7 +------ .../navigation-helper.spec.js | 1 - .../heritage-integration/session-helper.js | 16 +--------------- .../capability-questions.vue | 2 +- .../molding-questions/molding-questions.vue | 2 +- src/layouts/vehicle-make/vehicle-make.vue | 6 +----- src/router/index.js | 2 -- 7 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index 4a2026764..ffda1e77f 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -9,12 +9,7 @@ import { headerKeys } from "@/constants/header-keys"; export default { callHttpClient({ method, endpoint, payload, logApiCall = true }) { return new Promise((resolve, reject) => { - // const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; - - let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; - if (endpoint.includes("/order/")) - cfDistroUrl = "https://localhost:44346" - + const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); const headers = { [headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings) diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index 8cc72284b..85e3878ff 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -9,7 +9,6 @@ import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import store from "@/store"; import router from "@/router"; -import { lazy } from "yup"; // Mock Lazy Load jest.mock("@/router/dynamic-routing/component-loader.js", () => ({ diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index a5118a21d..b71602f3c 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -43,18 +43,4 @@ export function getDateForSavedSessionTimeout() { const currentDate = new Date(new Date().toUTCString()) currentDate.setDate(currentDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) return currentDate.toUTCString(); -} - -/** Function to get saved session timeout date based on values in the cookie */ -// function getSavedSessionTimeoutDate() { -// let lastTouched = new Date(getFunnelCookie()?.LastTouched); -// lastTouched = lastTouched ? lastTouched : new Date().toUTCString(); -// let savedSessionTimeoutDate = lastTouched; -// savedSessionTimeoutDate.setDate(savedSessionTimeoutDate.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS); - -// // const test = lastTouched -// // ? lastTouched.setDate(lastTouched.getDate() + applicationConfig.SAVED_SESSION_TIMEOUT_DAYS) -// // : getDateForSavedSessionTimeout(); - -// return savedSessionTimeoutDate; -// } \ No newline at end of file +} \ No newline at end of file diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index a29aa3779..69fc8aad5 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -112,7 +112,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - return false; // TODO - DO TRUE TEST OF PAGEDATA + return true; // TODO - DO TRUE TEST OF PAGEDATA // return Object.keys(store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS)).length > 0; }, showThisPartQuestionChain(part, i) { diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index f575c9240..d2b469a36 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -115,7 +115,7 @@ export default { }, methods: { arePagePrerequisitesValid() { - return false; // TODO - DO TRUE TEST OF PAGEDATA + return true; // TODO - DO TRUE TEST OF PAGEDATA // return Object.keys(store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS)).length > 0; }, showThisPartQuestionChain(part, i) { diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index 4a2eff8f9..e769c4290 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -76,11 +76,7 @@ export default { ); }, arePagePrerequisitesValid() { - if (store.getters.vehicle.year){ - return true; - } - - return false; + return store.getters.vehicle.year != null; }, }, diff --git a/src/router/index.js b/src/router/index.js index f1f9a2f69..525664dd5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -207,8 +207,6 @@ function navigateToUrl(url, optionalQuery = {}) { externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]); } - externalUrl.searchParams.append("experiments", "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"); - window.location.assign(externalUrl); } From f827282805ed31b7fb087bbd02ceb008d46e526a Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 09:29:36 -0400 Subject: [PATCH 08/12] CSR-690 Cleanup --- src/helpers/heritage-integration/cookie-helper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index f466bb9b8..775a64fec 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -1,7 +1,6 @@ import { cookieNames } from "@/constants/cookie-names"; import store from "@/store"; import { applicationConfig } from "@/constants/application-config"; -// import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; /* Will update the cookie if present, or create a new one if not. From 92aca422b9f39d55e096d95bf3ca55f7a0eec967 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 09:30:35 -0400 Subject: [PATCH 09/12] CSR-690 Cleanup --- .../heritage-integration/navigation-helper.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index e459a32b4..6079c5375 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -61,16 +61,16 @@ async function getLatestPageForRedirection() { // If this is a non-CTA navigation, determine where to send the user based on page prerequisites. // This also works if a user has a 'fmg' start_type query string but no current order. // That shouldn't happen, but it's possible. - const vehicleMakeComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MAKE);//(await lazyLoadComponent('vehicle-make')()).default; - const vehicleModelComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MODEL);//(await lazyLoadComponent('vehicle-model')()).default; - const vehicleStyleComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_STYLE);//(await lazyLoadComponent('vehicle-style')()).default; - const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE);//(await lazyLoadComponent('vehicle-damage')()).default; + const vehicleMakeComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MAKE); + const vehicleModelComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_MODEL); + const vehicleStyleComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_STYLE); + const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE); const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE); const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP); - const partQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.PART_QUESTIONS);//(await lazyLoadComponent('part-questions')()).default; + const partQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.PART_QUESTIONS); const vehiclePartsComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_PARTS); const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_QUESTIONS); - const capabilityQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.CAPABILITY_QUESTIONS);//(await lazyLoadComponent('capability-questions')()).default + const capabilityQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.CAPABILITY_QUESTIONS); if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VEHICLE_YEAR; From 92e226c61062bd64eb1b5afbf3b4a2b5bd76de46 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 11:55:31 -0400 Subject: [PATCH 10/12] CSR-690 Add tests --- .../navigation-helper.spec.js | 173 ++++++++++++++++-- .../vehicle-parts/vehicle-parts.spec.js | 70 ++++++- src/layouts/vehicle-parts/vehicle-parts.vue | 5 +- 3 files changed, 226 insertions(+), 22 deletions(-) diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index 85e3878ff..eba5f5f49 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -16,8 +16,7 @@ jest.mock("@/router/dynamic-routing/component-loader.js", () => ({ })); describe("getPageToRouteExistingOrderTo", () => { - - test("getPageToRouteExistingOrderTo, should return vehicle-year", async () => { + test("should return vehicle-year", async () => { // Arrange const toRoute = { query: {} @@ -32,10 +31,29 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, false); //Assert - expect(result).toBe('vehicle-year'); + expect(result).toBe(fmgPageValues.VEHICLE_YEAR); }); - test("getPageToRouteExistingOrderTo, should return vehicle-model", async () => { + test("should return vehicle-make", async () => { + // Arrange + const toRoute = { + query: {} + }; + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: false + }) + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute, false); + + //Assert + expect(result).toBe(fmgPageValues.VEHICLE_MAKE); + }); + + test("should return vehicle-model", async () => { // Arrange const toRoute = { query: {} @@ -52,10 +70,31 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, false); //Assert - expect(result).toBe('vehicle-model'); + expect(result).toBe(fmgPageValues.VEHICLE_MODEL); }); - test("getPageToRouteExistingOrderTo, should return vehicle-damage", async () => { + test("should return vehicle-style", async () => { + // Arrange + const toRoute = { + query: {} + }; + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: false, + }) + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute, false); + + //Assert + expect(result).toBe(fmgPageValues.VEHICLE_STYLE); + }); + + test("should return vehicle-damage", async () => { // Arrange const toRoute = { query: {} @@ -74,10 +113,10 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, false); //Assert - expect(result).toBe('vehicle-damage'); + expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE); }); - test("getPageToRouteExistingOrderTo, user has YMMS and no vehicle questions should return vin-lookup", async () => { + test("user has YMMS and no vehicle questions > should return vin-lookup", async () => { // Arrange const toRoute = { query: {} @@ -101,10 +140,10 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, false); //Assert - expect(result).toBe('vin-lookup'); + expect(result).toBe(fmgPageValues.VIN_LOOKUP); }); - test("getPageToRouteExistingOrderTo, user has YMMS but no questions or carId should return estimate", async () => { + test("user has YMMS but no questions or carId > should return estimate", async () => { // Arrange const toRoute = { query: {} @@ -128,10 +167,118 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, false); //Assert - expect(result).toBe('estimate'); + expect(result).toBe(fmgPageValues.ESTIMATE); }); - test("getPageToRouteExistingOrderTo, existing order, should return heritage", async () => { + test("user has capability questions and molding questions > should return capability questions", async () => { + // Arrange + const toRoute = { + query: {} + }; + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: true, + [fmgPageValues.MOLDING_QUESTIONS]: true, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: false, + [fmgPageValues.VIN_LOOKUP]: false, + }) + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute, false); + + //Assert + expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS); + }); + + test("user has molding questions and part questions > should return molding questions", async () => { + // Arrange + const toRoute = { + query: {} + }; + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: true, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + }) + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute, false); + + //Assert + expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS); + }); + + test("user has vehicle parts questions > should return vehicle-parts", async () => { + // Arrange + const toRoute = { + query: {} + }; + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: true, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + }) + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute, false); + + //Assert + expect(result).toBe(fmgPageValues.VEHICLE_PARTS); + }); + + test("user has part questions > should return part-questions", async () => { + // Arrange + const toRoute = { + query: {} + }; + + // Mock out the lazy load calls for all components. + mockLazyLoadComponentReturnValues({ + [fmgPageValues.VEHICLE_MAKE]: true, + [fmgPageValues.VEHICLE_MODEL]: true, + [fmgPageValues.VEHICLE_STYLE]: true, + [fmgPageValues.VEHICLE_DAMAGE]: true, + [fmgPageValues.ESTIMATE]: true, + [fmgPageValues.CAPABILITY_QUESTIONS]: false, + [fmgPageValues.MOLDING_QUESTIONS]: false, + [fmgPageValues.VEHICLE_PARTS]: false, + [fmgPageValues.PART_QUESTIONS]: true, + [fmgPageValues.VIN_LOOKUP]: false, + }) + + // Act + const result = await getPageToRouteExistingOrderTo(toRoute, false); + + //Assert + expect(result).toBe(fmgPageValues.PART_QUESTIONS); + }); + + test("existing order > should return heritage", async () => { // Arrange const toRoute = { query: { @@ -143,7 +290,7 @@ describe("getPageToRouteExistingOrderTo", () => { const result = await getPageToRouteExistingOrderTo(toRoute, true); // Assert - expect(result).toBe("heritage"); + expect(result).toBe(fmgPageValues.HERITAGE); }) }); diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js index 9f766c7e9..bd7911da4 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.spec.js +++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js @@ -11,6 +11,7 @@ import { nextTick } from "vue"; import baseMixin from "@/mixins/base-mixin.js"; import store from "@/store"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; +import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; // Mock our module for promises. jest.mock("@/helpers/layout-helper.js", () => ({ @@ -145,7 +146,7 @@ describe("vehicle-parts.vue", () => { test("Initial data, should populate this.glassParts", async () => { //Arrange - store.getters.pageData.mockReturnValueOnce(basePartResponse); + store.getters.pageData.mockReturnValue(basePartResponse); store.getters.lineItems = { glassParts: [{ partNumber: 'DB12209YPYNOEM' }] } const { wrapper } = setupMocks({ @@ -178,12 +179,8 @@ describe("vehicle-parts.vue", () => { expect(wrapper.vm.glassParts).toEqual({ "Rear-Stationary": { "Rear": ['DB12209YPYNOEM'] } }); }); - test("BackButtonAction triggers a router.navigate change", async () => { - + test("User had part questions > BackButtonAction triggers a router.navigate change with correct scenario", async () => { //Arrange - store.getters.pageData.mockReturnValueOnce(basePartResponse); - store.getters.lineItems = { glassParts: null } - const { wrapper } = setupMocks({ mountOptionsMockData: { router: { @@ -196,7 +193,25 @@ describe("vehicle-parts.vue", () => { } }, store: { - getters: store.getters + getters: { + pageData: () => { + return { + partsOrQuestions: [ + { + glassName: "Stationary", + glassLocation: "Rear", + parts: null, + partQuestions: [{ + testProperty: "some value" + }] + } + ] + } + }, + lineItems: { + glassParts: null + } + } }, } }); @@ -212,7 +227,46 @@ describe("vehicle-parts.vue", () => { wrapper.vm.backButtonAction(); //Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITH_PART_QUESTION_ANSWERS, wrapper.vm.$route); + + }); + + test("User did not have part questions > BackButtonAction triggers a router.navigate change with correct scenario", async () => { + //Arrange + const { wrapper } = setupMocks({ + mountOptionsMockData: { + router: { + navigate: jest.fn(), + navigate: jest.fn() + }, + route: { + query: { + fmgPage: 'vehicle-parts', + } + }, + store: { + getters: { + pageData: () => basePartResponse, + lineItems: { + glassParts: null + } + } + }, + } + }); + + //Act + vehicleParts.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "vehicle-parts" } }, + undefined, + (c) => c(wrapper.vm) + ); + + wrapper.vm.backButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS, wrapper.vm.$route); }); diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 103af885b..10cf64ce9 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -67,6 +67,7 @@ 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"; +import { assertParenthesizedExpression } from "@babel/types"; export default { name: "vehicle-parts", @@ -126,7 +127,7 @@ export default { return { glassName: g.glassName, glassLocation: g.glassLocation, - colorAnswers: g.parts.reduce((arr, p) => { + colorAnswers: g.parts?.reduce((arr, p) => { arr.push({ ColorAnswerText: p.color, FeatureAnswers: [ @@ -160,6 +161,8 @@ export default { }, backButtonAction() { const hasPartQuestions = this.hasPartQuestions(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions); + // console.log(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)) + // console.log(hasPartQuestions) const backNavigationScenario = hasPartQuestions ? this.navigationScenarios.CLICKED_BACK_WITH_PART_QUESTION_ANSWERS : this.navigationScenarios.CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS; this.$router.navigate( From 37095ce910f652ba806257a875d32bb93dcc8119 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 11:56:01 -0400 Subject: [PATCH 11/12] CSR-690 Cleanup --- src/layouts/vehicle-parts/vehicle-parts.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 10cf64ce9..c7f1424a1 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -161,8 +161,6 @@ export default { }, backButtonAction() { const hasPartQuestions = this.hasPartQuestions(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions); - // console.log(this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)) - // console.log(hasPartQuestions) const backNavigationScenario = hasPartQuestions ? this.navigationScenarios.CLICKED_BACK_WITH_PART_QUESTION_ANSWERS : this.navigationScenarios.CLICKED_BACK_WITHOUT_PART_QUESTION_ANSWERS; this.$router.navigate( From 7395d1e2c07c08f31e8f93611a295a5d0144cef7 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 12:20:47 -0400 Subject: [PATCH 12/12] CSR-690 Edit arePagePrequisitesValid logic --- src/layouts/estimate/estimate.vue | 5 ++++- src/layouts/vehicle-damage/vehicle-damage.vue | 5 ++++- src/layouts/vehicle-make/vehicle-make.vue | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index 3cc6b1149..85f277482 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -80,7 +80,10 @@ export default { }, methods: { arePagePrerequisitesValid() { - return store.getters.damage.isRepair != null; + if(store.getters.damage.isRepair != null){ + return true; + } + return false; }, backButtonAction() { // route to move backwards diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 42e150c90..23d317815 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -155,7 +155,10 @@ export default { }, methods: { arePagePrerequisitesValid() { - return store.getters.vehicle.carId != null; + if (store.getters.vehicle.carId) { + return true; + } + return false; }, attachCustomEvents(){ diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index e769c4290..309e74863 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -76,7 +76,10 @@ export default { ); }, arePagePrerequisitesValid() { - return store.getters.vehicle.year != null; + if (store.getters.vehicle.year){ + return true; + } + return false; }, },