From 10bad18b5689e31e344b50aed9c3f3aaf74e0807 Mon Sep 17 00:00:00 2001 From: bmauger Date: Fri, 18 Mar 2022 12:18:43 -0400 Subject: [PATCH 01/10] WIP Do not merge. --- src/layouts/vin-lookup/vin-lookup.vue | 78 ++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 8dbb6cdc9..2920be727 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -1,9 +1,8 @@ @@ -50,134 +24,14 @@ import funnelFooter from "@/common-components/funnel-footer/funnel-footer"; import textboxQuestion from "@/common-components/textbox-question/textbox-question"; import vinInformation from "@/layouts/vin-lookup/vin-information/vin-information"; -// Supporting files -import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; -import { settleAllPromises } from "@/helpers/layout-helper"; -import { storeActions } from "@/constants/store-actions"; -import store from "@/store"; -import { storeMutations } from "@/constants/store-mutations"; -import baseMixin from "@/mixins/base-mixin"; -import { Form, defineRule } from "vee-validate"; -import { required } from "@/helpers/validation-rules"; -import { errorMessages } from "@/constants/error-messages"; - -// DEFINE VALIDATION RULES -defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED)); - export default { name: "vin-lookup", - async beforeRouteEnter(to, from, next) { - // Call APIs - const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); - const damageOptionsPromise = - baseMixin.methods.dispatchNonBlockingStoreAction( - storeActions.GET_DAMAGE_OPTIONS, - { carId: store.getters.vehicle.carId } - ); - - // Settle promises and get results - const promiseResultMap = [ - { - resultKey: "cmsContent", - promise: cmsContentPromise, - }, - { - resultKey: "damageOptions", - promise: damageOptionsPromise, - }, - ]; - - const resultMap = await settleAllPromises(promiseResultMap); - - // Call the "next" function to complete the transition to this page. - next((vm) => { - vm.$refs.funnelHeader.initializeComponent( - resultMap.cmsContent.FunnelHeaderWidget - ); - vm.$refs.vehicleBanner.initializeComponent( - resultMap.cmsContent.VehicleBannerWidget - ); - vm.$refs.funnelSubHeader.initializeComponent( - resultMap.cmsContent.FunnelSubHeaderWidget - ); - vm.$refs.funnelFooter.initializeComponent( - resultMap.cmsContent.FunnelFooterWidget - ); - }); - }, - methods: { - arePagePrerequisitesValid() { - return true; - }, - resetDependentState() { - store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - }, - backButtonAction() { - // route to move backwards - this.$router.navigate( - this.navigationScenarios.CLICKED_BACK, - this.$route - ); - }, - async forwardButtonAction(zip, plate) { - const zipValidation = await this.validateZip(zip); - const vinLookup = await this.lookupVin(plate); - if (!zipValidation.isServiceable) { - this.newServiceZipRequired = true; - return; - } - if (!vinLookup.vin) { - this.vinNotValid = true; - return; - } - if (vinLookup.vehicle.carId !== store.getters.vehicle.carId) { - this.vinDoesNotMatchCarId = true; - return; - } - const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction( - this.storeActions.GET_PARTS_OR_QUESTIONS, - { - carId: store.getters.vehicle.carId, - glassArray: store.getters.damage.glassToReplace, - zipCode: zip, - vin: vinLookup.vin - }, - false - ); - this.navigateForward(partsData); - }, - navigateForward(partsData){ - if(partsData.data.partsOrQuestions.partQuestions.length){ - this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_PARTS_QUESTION, this.$route, {}, {}, partsData.data); - return; - } else if(!partsData.data.partsOrQuestions.partQuestions.length && partsData.data.partsOrQuestions.parts.length > 1) { - this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_PARTS, this.$route, {}, {}, partsData.data); - return; - } else { - this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_SINGLE_PART, this.$route); - } - }, - validateZip(zip) { - return baseMixin.methods.dispatchNonBlockingStoreAction( - storeActions.VALIDATE_ZIP, - { zip } - ); - }, - lookupVin(plate, state) { - return baseMixin.methods.dispatchNonBlockingStoreAction( - storeActions.LOOKUP_VIN_BY_PLATE, - { plate, state } - ); - }, - }, components: { funnelHeader, vehicleBanner, funnelSubHeader, - textboxQuestion, vinInformation, funnelFooter, - Form, }, }; From 44c4fcfd6a787aecb6ba674e611d929a911cebd2 Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 25 Mar 2022 09:52:12 -0400 Subject: [PATCH 07/10] CSR-98 Fix tests --- src/helpers/unit-test-helper.js | 27 +++++++++---------- .../vehicle-parts/vehicle-parts.spec.js | 7 ++--- src/layouts/vehicle-parts/vehicle-parts.vue | 3 ++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 20ee5990a..c6c766956 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -12,22 +12,19 @@ export function getMountOptions(mockData) { //this is mocking if you use the mixin directly(baseMixin.methods.dispatchNonBlockingStoreAction) vs this.dispatchNonBlockingStoreAction setupBaseMixinDispatchNonBlockingStoreAction(mockData); // if (mockData.actionList !== undefined) { - // // baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); - // // baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { - // // let actionFilterResult = mockData.actionList.filter( - // // (x) => x.actionName == actionName - // // ); + // baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); + // baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { + // let actionFilterResult = mockData.actionList.filter( + // (x) => x.actionName == actionName + // ); - // // if (actionFilterResult.length > 0 && actionFilterResult.length === 1) { - // // return Promise.resolve({ - // // data: actionFilterResult[0].data, - // // }); - // // } - // // }); - - + // if (actionFilterResult.length > 0 && actionFilterResult.length === 1) { + // return Promise.resolve({ + // data: actionFilterResult[0].data, + // }); + // } + // }); // } - mocks.dispatchNonBlockingStoreAction = jest.fn(); mocks.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { @@ -62,8 +59,8 @@ export function getMountOptions(mockData) { } function setupBaseMixinDispatchNonBlockingStoreAction(mockData) { - baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); if (mockData.actionList !== undefined) { + baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { let actionFilterResult = mockData.actionList.filter( (x) => x.actionName == actionName diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js index 74196c524..428fe8a3b 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.spec.js +++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js @@ -193,7 +193,7 @@ describe("vehicle-parts.vue", () => { test("PageData / isRepair populated in Vuex. arePagePrerequisitesValid should be true ", async () => { //Arrange - store.getters.pageData.mockReturnValueOnce(basePartResponse); + store.getters.pageData.mockReturnValue(basePartResponse); store.getters.lineItems = { glassParts: {} } const { wrapper } = setupMocks({ @@ -211,6 +211,7 @@ describe("vehicle-parts.vue", () => { }, } }); + console.info(store.getters.damage.isRepair) //Act vehicleParts.beforeRouteEnter.call( @@ -222,9 +223,9 @@ describe("vehicle-parts.vue", () => { let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); await nextTick(); - + console.log(arePagePrerequisitesValid) //Assert - expect(arePagePrerequisitesValid).toBe(true); + // expect(arePagePrerequisitesValid).toBe(true); }); test("Initial data, should populate this.glassParts", async () => { diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 11f0811bf..c02edfd27 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -154,8 +154,9 @@ export default { methods: { arePagePrerequisitesValid() { // Check if isRepair is populated and if the pageData we need is here (Parts data) + console.log(store.getters.pageData(fmgPageValues.VEHICLE_PARTS)) if ( - (store.getters.damage.isRepair) && + (store.getters.damage.isRepair != null) && Object.keys(store.getters.pageData(fmgPageValues.VEHICLE_PARTS)) .length !== 0 ) { From d4579137aeb72987319ca1b9222eab697df37ef1 Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 25 Mar 2022 09:59:43 -0400 Subject: [PATCH 08/10] CSR-98 Cleanup --- src/global-methods.js | 8 +------- src/helpers/heritage-integration-helper.js | 2 -- src/helpers/unit-test-helper.js | 14 -------------- src/layouts/vehicle-parts/vehicle-parts.spec.js | 5 ++--- 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index 8efd163aa..f0675c02d 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -5,14 +5,8 @@ import httpStatusCodes from "http-status-codes"; export default { callHttpClient({ method, endpoint, payload }) { return new Promise((resolve, reject) => { - // TODO CSR-98 TEMP FOR TESTING - var apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL; + const apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL; - if (endpoint.includes("order")) { - apiGatewayUrl = "https://localhost:44346"; - } - - // const apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL; const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass", }); diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js index 14dacb8eb..0147c25e5 100644 --- a/src/helpers/heritage-integration-helper.js +++ b/src/helpers/heritage-integration-helper.js @@ -264,8 +264,6 @@ function setConceptCookieProperties(properties) { Removes concept cookie from browser. */ function deleteConceptCookie() { - // If this cookie is ever created from the concept funnel, will need to add another - // line with the path=/fmg/ document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`; } diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index c6c766956..00fa5f675 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -11,20 +11,6 @@ export function getMountOptions(mockData) { //this is mocking if you use the mixin directly(baseMixin.methods.dispatchNonBlockingStoreAction) vs this.dispatchNonBlockingStoreAction setupBaseMixinDispatchNonBlockingStoreAction(mockData); - // if (mockData.actionList !== undefined) { - // baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); - // baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { - // let actionFilterResult = mockData.actionList.filter( - // (x) => x.actionName == actionName - // ); - - // if (actionFilterResult.length > 0 && actionFilterResult.length === 1) { - // return Promise.resolve({ - // data: actionFilterResult[0].data, - // }); - // } - // }); - // } mocks.dispatchNonBlockingStoreAction = jest.fn(); mocks.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js index 428fe8a3b..6613fe6ad 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.spec.js +++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js @@ -211,7 +211,6 @@ describe("vehicle-parts.vue", () => { }, } }); - console.info(store.getters.damage.isRepair) //Act vehicleParts.beforeRouteEnter.call( @@ -223,9 +222,9 @@ describe("vehicle-parts.vue", () => { let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); await nextTick(); - console.log(arePagePrerequisitesValid) + //Assert - // expect(arePagePrerequisitesValid).toBe(true); + expect(arePagePrerequisitesValid).toBe(true); }); test("Initial data, should populate this.glassParts", async () => { From 0eaec7e5f8f9a14c6f9511e8906573d416a18f20 Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 25 Mar 2022 10:06:57 -0400 Subject: [PATCH 09/10] CSR-98 Remove experiments used for local testing --- src/helpers/heritage-integration-helper.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js index 0147c25e5..ecaa6548b 100644 --- a/src/helpers/heritage-integration-helper.js +++ b/src/helpers/heritage-integration-helper.js @@ -186,9 +186,7 @@ export async function navigateToHeritageFunnel() { externalUrls.HERITAGE_FUNNEL, { corid: store.getters.order.referralCorrelationId, - src: "concept-funnel", - cns: "all", - experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=ServAreaNoRemove_V7_TEST=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" + src: "concept-funnel" } ); } From 950ca93ad8e38810b8c6945febc1d44aa84d5b57 Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 25 Mar 2022 11:39:14 -0400 Subject: [PATCH 10/10] CSR-98 Fix tests --- src/helpers/heritage-integration-helper.js | 7 +++++-- src/helpers/heritage-integration-helper.spec.js | 3 +-- src/router/router-constants/routing-table.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/helpers/heritage-integration-helper.js b/src/helpers/heritage-integration-helper.js index ecaa6548b..960ab4e65 100644 --- a/src/helpers/heritage-integration-helper.js +++ b/src/helpers/heritage-integration-helper.js @@ -1,3 +1,4 @@ +import * as self from "./heritage-integration-helper"; import { storeActions } from "@/constants/store-actions.js"; import { cookieNames } from "@/constants/cookie-names"; import { queryStrings } from "@/constants/query-strings"; @@ -36,7 +37,7 @@ export async function saveOrder() { */ export async function loadOrderIfPresent() { console.log("attempting to load referral...."); - const conceptCookie = this.getConceptCookie(); + const conceptCookie = self.getConceptCookie(); // Do nothing if there is no cookie or no correlation id. if (conceptCookie === null || conceptCookie.ReferralCorrelationId === null) { @@ -177,10 +178,12 @@ export function isSavedSessionStillActive() { /* Used to navigate to the heritage funnel with the correct query string and url. */ + export async function navigateToHeritageFunnel() { // Create the order (or save existing order) when navigating to Heritage Funnel. - await this.saveOrder(); + // console.log(exports) + await self.saveOrder(); router.navigateToExternalUrl( externalUrls.HERITAGE_FUNNEL, diff --git a/src/helpers/heritage-integration-helper.spec.js b/src/helpers/heritage-integration-helper.spec.js index ff91d68c6..54ba8e9f6 100644 --- a/src/helpers/heritage-integration-helper.spec.js +++ b/src/helpers/heritage-integration-helper.spec.js @@ -102,8 +102,7 @@ describe("saveOrder", () => { { actionName: storeActions.SET_REFERRAL_INFORMATION } - ], - router: router + ] } const mocks = setupMocksForJsFiles(mockData); diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index d928f8696..760dac76a 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -1,6 +1,6 @@ import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; -import { applicationConfig } from "../../constants/application-config"; +import { applicationConfig } from "@/constants/application-config"; const routingTable = [ {