From 02dc99b2fff359b1c5bf55b74732ec88e2341922 Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 17 Apr 2023 16:54:55 -0400 Subject: [PATCH] Updated for 314 and 316 --- src/constants/damage-custom-labels.js | 4 +- src/constants/damage-locations-cms.js | 8 +- src/constants/damage-locations-selected.js | 32 +-- src/constants/dynamic-strings.js | 6 +- src/constants/part-type-strings.js | 6 +- src/constants/vin-lookup-methods.js | 4 +- src/helpers/cms-content-helper.js | 65 +++-- .../site-sub-header/site-sub-header.spec.js | 10 +- .../site-sub-header/site-sub-header.vue | 6 +- .../service-package-question.vue | 36 +-- .../service-package-radio.spec.js | 127 ++++++++++ .../service-packages/service-packages.vue | 32 +-- src/mixins/vehicle-questions-mixin.spec.js | 185 +-------------- src/router/router-constants/issPage-values.js | 46 ++-- src/router/router-constants/routing-table.js | 224 +++++++++--------- src/store/index.js | 201 +++++++++------- vue.config.js | 6 +- 17 files changed, 488 insertions(+), 510 deletions(-) create mode 100644 src/layouts/service-packages/service-package-question/service-package-radio/service-package-radio.spec.js diff --git a/src/constants/damage-custom-labels.js b/src/constants/damage-custom-labels.js index 72448788..ca9e5271 100644 --- a/src/constants/damage-custom-labels.js +++ b/src/constants/damage-custom-labels.js @@ -1,8 +1,8 @@ const damageCustomLabels = Object.freeze({ - MATCH: 'match', + MATCH: 'match', REAR_WINDOW: 'rear window', SIDE_WINDOW: 'side window', - WINDSHIELD: 'windshield' + WINDSHIELD: 'windshield' }); export default damageCustomLabels; diff --git a/src/constants/damage-locations-cms.js b/src/constants/damage-locations-cms.js index 01c63d27..1326ef9f 100644 --- a/src/constants/damage-locations-cms.js +++ b/src/constants/damage-locations-cms.js @@ -1,8 +1,8 @@ const damageLocationsCms = { - WINDSHIELD: "WINDSHIELD", - SIDEDOOR: "SIDEDOOR", - REARWINDOW: "REARWINDOW", - DRIVERSIDE: "DRIVERSIDE", + WINDSHIELD: "WINDSHIELD", + SIDEDOOR: "SIDEDOOR", + REARWINDOW: "REARWINDOW", + DRIVERSIDE: "DRIVERSIDE", PASSENGERSIDE: "PASSENGERSIDE" }; diff --git a/src/constants/damage-locations-selected.js b/src/constants/damage-locations-selected.js index 58a9bd24..f152e02f 100644 --- a/src/constants/damage-locations-selected.js +++ b/src/constants/damage-locations-selected.js @@ -1,21 +1,21 @@ const damageLocationsSelected = { - WINDSHIELD: "Windshield", - SIDEDOOR: "SideDoor", - REARWINDOW: "RearWindow", - REPAIR: "Repair", - REPLACE: "Replace", - DRIVER: "Driver", - PASSENGER: "Passenger", - FRONT: "Front", - REAR: "Rear", - BACK: "Back", - QUARTER: "Quarter", - VENT: "Vent", - SINGLE: "Single", - DRIVERSIDE: "DriverSide", + WINDSHIELD: "Windshield", + SIDEDOOR: "SideDoor", + REARWINDOW: "RearWindow", + REPAIR: "Repair", + REPLACE: "Replace", + DRIVER: "Driver", + PASSENGER: "Passenger", + FRONT: "Front", + REAR: "Rear", + BACK: "Back", + QUARTER: "Quarter", + VENT: "Vent", + SINGLE: "Single", + DRIVERSIDE: "DriverSide", PASSENGERSIDE: "PassengerSide", - STATIONARY: "Stationary", - SLIDER: "Slider" + STATIONARY: "Stationary", + SLIDER: "Slider" }; export { damageLocationsSelected }; diff --git a/src/constants/dynamic-strings.js b/src/constants/dynamic-strings.js index e59f3a0c..b81c0f30 100644 --- a/src/constants/dynamic-strings.js +++ b/src/constants/dynamic-strings.js @@ -1,8 +1,8 @@ const dynamicStrings = { GLOBAL_STATE: "globalState", - CUSTOM: "custom", - ROUTER_LINK: "routerLink:", - MODAL_LINK: "modalLink" + CUSTOM: "custom", + ROUTER_LINK: "routerLink:", + MODAL_LINK: "modalLink" }; export { dynamicStrings }; \ No newline at end of file diff --git a/src/constants/part-type-strings.js b/src/constants/part-type-strings.js index d9c62491..8e4a4951 100644 --- a/src/constants/part-type-strings.js +++ b/src/constants/part-type-strings.js @@ -1,7 +1,7 @@ const partTypeStrings = { - FRONT_WIPER: 'FRONT WIPER', - REAR_WIPER: 'REAR WIPER', - RAIN_DEFENSE: 'RAIN DEFENSE', + FRONT_WIPER: 'FRONT WIPER', + REAR_WIPER: 'REAR WIPER', + RAIN_DEFENSE: 'RAIN DEFENSE', RECALIBRATION: 'RECALIBRATION' }; diff --git a/src/constants/vin-lookup-methods.js b/src/constants/vin-lookup-methods.js index b1369360..6af7e969 100644 --- a/src/constants/vin-lookup-methods.js +++ b/src/constants/vin-lookup-methods.js @@ -1,7 +1,7 @@ const vinLookupMethodSelections = Object.freeze({ - MANUALVIN: 'ManualVin', + MANUALVIN: 'ManualVin', LICENSEPLATE: 'LicensePlate', - HOMEADDRESS: 'HomeAddress' + HOMEADDRESS: 'HomeAddress' }); export {vinLookupMethodSelections}; diff --git a/src/helpers/cms-content-helper.js b/src/helpers/cms-content-helper.js index 6e0ba758..0472be9c 100644 --- a/src/helpers/cms-content-helper.js +++ b/src/helpers/cms-content-helper.js @@ -2,9 +2,9 @@ import { dynamicStrings } from '@/constants/dynamic-strings'; import { useMainStore } from '@/store'; export function fetchCmsContentForPage(issPage) { - const store = useMainStore() - const clientName = store.issConfig.clientName; - const accountNumber = store.issConfig.accountNumber; + const store = useMainStore() + const clientName = store.issConfig.clientName; + const accountNumber = store.issConfig.accountNumber; const clientOverride = (clientName.length > 0 && accountNumber > 0); return store.getPageData(issPage) @@ -43,7 +43,7 @@ export function fetchCmsContentForPage(issPage) { // clientResponse = contains the widgets from the client override page. (null if none) function processPageData(baseResponse, clientResponse) { const pageDataFromCms = {}; - let widgets = []; + let widgets = []; if (!baseResponse?.data?.Result) { console.error('No result data found'); // Something has gone terribly wrong. @@ -93,7 +93,7 @@ function processPageData(baseResponse, clientResponse) { widgets.forEach((widget) => { // Global state value replacement. - let widgetWithReplacements = findAndReplaceGlobalStateValues( + const widgetWithReplacements = findAndReplaceGlobalStateValues( widget.Model, widget.Name ); @@ -107,7 +107,7 @@ function processPageData(baseResponse, clientResponse) { } pageDataFromCms[widgetWithReplacements.Name] = [ - widgetWithReplacements.Model, + widgetWithReplacements.Model ]; }); @@ -125,7 +125,7 @@ function processPageData(baseResponse, clientResponse) { function findAndReplaceGlobalStateValues(widgetModel, widgetName) { const objWithReplacements = { Name: widgetName, - Model: {}, + Model: {} }; Object.keys(widgetModel).forEach((key) => { @@ -176,22 +176,27 @@ function processWidgetItemForReplacement(widgetModel, key) { } function mapStringToModal(str) { - let startIndex = str.indexOf('{' + dynamicStrings.MODAL_LINK); - let linkToReplace = str.substring(startIndex, str.length); + const startIndex = str.indexOf('{' + dynamicStrings.MODAL_LINK); + const linkToReplace = str.substring(startIndex, str.length); linkToReplace = linkToReplace.substring(0, linkToReplace.indexOf('}') + 1); - let params = linkToReplace.substring((dynamicStrings.MODAL_LINK).length + 2, linkToReplace.length -1) - let splitParams = params.split(','); - let bodyText = '' + splitParams[1] + ''; - - return str.replace(linkToReplace, bodyText); + const params = linkToReplace.substring((dynamicStrings.MODAL_LINK).length + 2, linkToReplace.length -1) + const splitParams = params.split(','); + + const bodyText = '' + splitParams[1] + ''; + let returnVal = str.replace(linkToReplace, bodyText); + + if (returnVal.includes(dynamicStrings.MODAL_LINK)) { + returnVal = mapStringToModal(returnVal) + } + return returnVal } // Function to convert a string, into a matching global state item. function mapStringToState(str) { // Pull all matches out of the string. - const regexExp = new RegExp('{(.*?):(.*?)}', 'g'); - const regexMatches = [...str.matchAll(regexExp)]; + const regexExp = new RegExp('{([^{}]*?):([^{}]*?)}', 'g'); + const regexMatches = [...str.matchAll(regexExp)]; const globalStateMatches = regexMatches.filter(match => { return match[1] === dynamicStrings.GLOBAL_STATE; }); @@ -203,7 +208,8 @@ function mapStringToState(str) { // Reset store state for each match. const valueFromStore = getStoreValueFromString(match[2]); if (!valueFromStore) { - return ''; + console.warning('Unable to resolve global state data.'); + return '' // if we can't map our string to state data, return an empty string. } const stringWithReplacement = str.replace(match[0], valueFromStore); @@ -220,16 +226,18 @@ function mapStringToState(str) { } function getStoreValueFromString(str) { + if (!str) return ''; + let storeOrStateObject = useMainStore(); for (const s of str.split('.')) { - if (s === 'getters') continue; + if (s === 'getters') continue; //For backward compatability if (storeOrStateObject[s] != undefined) { storeOrStateObject = storeOrStateObject[s]; } else { - return '' + break; } } - return storeOrStateObject; + return storeOrStateObject ?? ''; } /////////////////////////////////// @@ -247,9 +255,11 @@ export function processIfStatements(str, ifConditionKeyword, replacePlaceholderC const containsRelevantIfStatement = new RegExp('{if:' + ifConditionKeyword + ':.+?}', 'g').test( str ); - //str = str.replace(/\r?\n|\r/g, ''); const hasEmbeddedCrLf = /\r?\n|\r/g.test(str); + if (hasEmbeddedCrLf) { + console.warning('Processing of conditional string was skipped. String has embedded carriage return/linefeed.'); + } if (!containsRelevantIfStatement || hasEmbeddedCrLf) { return str; } else { @@ -404,6 +414,7 @@ function getIfStatementRegexExpression() { // End of If Statement Processing Logic // ////////////////////////////////////////// + export function doesCopyContainTextLink(copy) { return copy.includes(dynamicStrings.TEXT_LINK); } @@ -412,11 +423,19 @@ export function doesCopyContainRouterLink(copy) { return copy.includes(this.dynamicStrings.ROUTER_LINK); } +/** + * splits copy on { ... } such as {routerlink: ...} + * @returns array of strings + */ export function splitCopyOnCMSPlaceHolder(copy) { // splits copy on { ... } such as {routerlink: ...} return copy.split(/{(.*?)}/g); } +/** + * Returns string2 of input following this pattern: {string1:string2,string3} + * @returns string + */ export function getRouterLinkRouteFromCopy(copy) { // sample input: {routerLink:estimate,provide your VIN} // first split would return 'estimate,provide your VIN' @@ -424,6 +443,10 @@ export function getRouterLinkRouteFromCopy(copy) { return copy.split(':')[1].split(',')[0]; } +/** + * Returns string3 of input following this pattern: { string1: string2, string3 } + * @returns string + */ export function getRouterLinkDisplayTextFromCopy(copy) { // sample input: {routerLink:estimate,provide your VIN} // first split would return 'estimate,provide your VIN' diff --git a/src/iss-components/site-sub-header/site-sub-header.spec.js b/src/iss-components/site-sub-header/site-sub-header.spec.js index 22ece651..56231b5a 100644 --- a/src/iss-components/site-sub-header/site-sub-header.spec.js +++ b/src/iss-components/site-sub-header/site-sub-header.spec.js @@ -6,18 +6,22 @@ describe("site sub header", () => { const subHeaderText = "let's fix your glass"; const mockMixin = { methods: { - getCmsContent: jest.fn().mockImplementation(()=> { + getCmsContent: jest.fn().mockImplementation((widgetName, text)=> { return subHeaderText; }) } }; it("should contain the cms content", () => { - const wrapper = shallowMount(siteSubHeader, { + const wrapper = shallowMount(siteSubHeader, { + propsData: { + justification: '', + issContainingPage: '' + }, mixins: [mockMixin] }); - wrapper.getCmsContent = jest.fn(); + //wrapper.getCmsContent = jest.fn(); const actual = wrapper.find("span"); expect(actual.html()).toContain(subHeaderText); }); diff --git a/src/iss-components/site-sub-header/site-sub-header.vue b/src/iss-components/site-sub-header/site-sub-header.vue index cfa65e34..94510321 100644 --- a/src/iss-components/site-sub-header/site-sub-header.vue +++ b/src/iss-components/site-sub-header/site-sub-header.vue @@ -39,7 +39,8 @@ import buttonBack from "@/iss-components/site-sub-header/button-back/button-back return this.getCmsContent(this.cmsWidgetName, "SubHeaderText") }, subText() { - return this.getCmsContent(this.cmsWidgetName, "SecondaryText") + const subText = this.getCmsContent(this.cmsWidgetName, "SecondaryText"); + return subText ?? ''; }, backButtonAccessibleText() { return this.getCmsContent(this.cmsWidgetName, "BackButtonAccessibleText") @@ -48,13 +49,12 @@ import buttonBack from "@/iss-components/site-sub-header/button-back/button-back return this.subText ? "dark-header" : "light-header"; }, justifySubheader() { - console.log('-->' + (this.justification.toLowerCase() === 'left')); return (this.justification?.toLowerCase() === 'left') ? 'justify-content-left' : 'justify-content-center'; }, alternateFormatting() { - return (this.issContainingPage === 'service-packages') ? + return (this.issContainingPage?.toLowerCase() === 'service-packages') ? 'service-packages-subtext mt-4 mb-2 px-5' : 'small'; } diff --git a/src/layouts/service-packages/service-package-question/service-package-question.vue b/src/layouts/service-packages/service-package-question/service-package-question.vue index d640014d..ca759639 100644 --- a/src/layouts/service-packages/service-package-question/service-package-question.vue +++ b/src/layouts/service-packages/service-package-question/service-package-question.vue @@ -52,35 +52,36 @@ }, computed: { nullSafeAvailableLineItems() { + console.log('Available Line Items = ' + this.availableLineItems) return this.availableLineItems ?? []; }, servicePackageAnswers() { if (!this.cmsWidgetName) return {}; const cmsAnswersContent = [ { - Name: 'EconomyServicePackage', + Name: 'TierOne', cmsWidgetName: 'EconomyServicePackage' }, { - Name: 'StandardServicePackage', + Name: 'TierTwo', cmsWidgetName: 'StandardServicePackage' }, { - Name: 'PremiumServicePackage', + Name: 'TierThree', cmsWidgetName: 'PremiumServicePackage' } ]; - + //if cms content has not yet loaded, skip if (this.getCmsContent(cmsAnswersContent[0].cmsWidgetName, 'HeaderText') == '') { return {}; } const modifiedAnswers = cmsAnswersContent.map((answer) => ({ - value: answer.Name, - buttonLabel: this.getHeaderTextFromCms(answer.cmsWidgetName), - buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.cmsWidgetName), - buttonBodyCopy: this.getBodyTextFromCms(answer.cmsWidgetName), - buttonAuxiliaryCopy: 'TODO', //this.getPackagePriceString(answer.Name), - buttonFooterCopy: this.getFooterTextFromCms(answer.cmsWidgetName) + value: answer.Name, + buttonLabel: this.getHeaderTextFromCms(answer.cmsWidgetName), + buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.cmsWidgetName), + buttonBodyCopy: this.getBodyTextFromCms(answer.cmsWidgetName), + buttonAuxiliaryCopy: this.getPackagePriceString(answer.Name), + buttonFooterCopy: this.getFooterTextFromCms(answer.cmsWidgetName) } )); return modifiedAnswers; @@ -161,14 +162,10 @@ }, getPackagePriceString(packageName) { const formattedPriceFloat = parseFloat(this.getPackagePrice(packageName)).toFixed(2); - return 'As little as $' + formattedPriceFloat; + return '$' + formattedPriceFloat; }, getPackagePrice(packageName) { - let priceFloat = this.isInsuranceSelected - ? 0 - : baseMixin.methods.getTierOnePackagePrice( - baseMixin.methods.filterOutFees(this.nullSafeAvailableLineItems) - ); + let priceFloat = 0; if (packageName === packageNames.TIER_TWO) { priceFloat += this.getTierTwoPackageVapsPrice(); } else if (packageName === packageNames.TIER_THREE) { @@ -186,7 +183,7 @@ item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER) || (priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER) ) { - vapsPrice += baseMixin.methods.getTotalLineItemPrice(item); + vapsPrice += this.getTotalLineItemPrice(item); } }); return vapsPrice; @@ -205,7 +202,7 @@ (priceRainDefense && item.partType.toUpperCase() === partTypeStrings.RAIN_DEFENSE) ) { - vapsPrice += baseMixin.methods.getTotalLineItemPrice(item); + vapsPrice += this.getTotalLineItemPrice(item); } }); return vapsPrice; @@ -348,6 +345,9 @@ (glassToReplace) => glassToReplace.glassLocation === glassLocation ) ?? []; return !!glassLocationMatches.length; + }, + getTotalLineItemPrice(lineItem) { + return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice } }, components: { diff --git a/src/layouts/service-packages/service-package-question/service-package-radio/service-package-radio.spec.js b/src/layouts/service-packages/service-package-question/service-package-radio/service-package-radio.spec.js new file mode 100644 index 00000000..622d439e --- /dev/null +++ b/src/layouts/service-packages/service-package-question/service-package-radio/service-package-radio.spec.js @@ -0,0 +1,127 @@ +import { mount } from "@vue/test-utils" +import servicePackageRadio from "./service-package-radio" +import inputButtonWrapperMixin from "@/mixins/input-button-wrapper-mixin" + +describe("service-package-radio.vue", () => { + it("Should include buttonLabel in html", async () => { + // Arrange + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: mockProps, + }, + }) + + // Act + const outputHtml = wrapper.html() + + // Assert + expect(outputHtml).toEqual(expect.stringContaining(mockProps["buttonLabel"])) + }) + + it("Should include buttonLabelAuxillaryCopy in html", async () => { + // Arrange + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: mockProps, + }, + }) + + // Act + const outputHtml = wrapper.html() + + // Assert + expect(outputHtml).toEqual(expect.stringContaining(mockProps["buttonLabelAuxillaryCopy"])) + }) + + it("Should include buttonLabelSubCopy in html", async () => { + // Arrange + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: mockProps, + }, + }) + + // Act + const outputHtml = wrapper.html() + + // Assert + expect(outputHtml).toEqual(expect.stringContaining(mockProps["buttonLabelSubCopy"])) + }) + it("Should include buttonFooterCopy in html", async () => { + // Arrange + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: mockProps, + }, + }) + + // Act + const outputHtml = wrapper.html() + + // Assert + expect(outputHtml).toEqual(expect.stringContaining(mockProps["buttonFooterCopy"])) + }) + it("Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when provided with a dashed (x5) buttonBodyCopy", async () => { + // Arrange + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: mockProps, + }, + }) + // Act + const results = wrapper.vm.getArrayOfListItemsFromRawCmsCopy(wrapper.vm.buttonBodyCopy) + + // Assert + expect(results.length).toBe(5) + }) + it("Should get strings from getArrayOfListItemsFromRawCmsCopy without dashes when provided with a dashed buttonBodyCopy", async () => { + // Arrange + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: mockProps, + }, + }) + + // Act + const results = wrapper.vm.getArrayOfListItemsFromRawCmsCopy(wrapper.vm.buttonBodyCopy) + + // Assert + const fileredResults = results.filter((result) => { + return result.includes(" -"); + }) + expect(fileredResults.length).toBe(0) + }) + it("Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when buttonBodyCopy has 6 total dashes, but one is empty ", async () => { + // Arrange + const moddedProps = mockProps + moddedProps["buttonBodyCopy"] = "- buttonBodyCopy test copy - 2 - 3 - 4 - 5 -" + let { wrapper } = setupMocks({ + mountOptionsMockData: { + propsData: moddedProps, + }, + }) + + // Act + const results = wrapper.vm.getArrayOfListItemsFromRawCmsCopy(wrapper.vm.buttonBodyCopy) + + // Assert + expect(results.length).toBe(5) + }) +}) + +const mockProps = { + buttonLabel: 'buttonLabel test copy', + buttonLabelAuxillaryCopy: 'buttonLabelAuxillaryCopy test copy', + buttonLabelSubCopy: 'buttonLabelSubCopy test copy', + buttonBodyCopy: '- buttonBodyCopy test copy - 2 - 3 - 4 - 5', + buttonFooterCopy: 'buttonFooterCopy test copy' +} + +function setupMocks({ mountOptionsMockData = {} }) { + const wrapper = mount(servicePackageRadio, { + ...mountOptionsMockData, + mixins: [inputButtonWrapperMixin] + }) + + return { wrapper } +} diff --git a/src/layouts/service-packages/service-packages.vue b/src/layouts/service-packages/service-packages.vue index 10015e54..13f67a47 100644 --- a/src/layouts/service-packages/service-packages.vue +++ b/src/layouts/service-packages/service-packages.vue @@ -58,9 +58,9 @@ // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); - const wipersPromise = store.getWipers(); - const rainDefensePromise = store.getRainDefense(); - const supportingItemsPromise = store.getSupportingItems(); + const wipersPromise = await store.getWipers(); + const rainDefensePromise = await store.getRainDefense(); + const supportingItemsPromise = await store.getSupportingItems(); const promiseResultMap = [ { resultKey: 'cmsContent', @@ -91,14 +91,14 @@ ...clonedGlassParts, ]; - //const pricingResults = await store.getPriceOrderItems(availableLineItems); + const pricingResults = await store.getPriceOrderItems(availableLineItems); // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); vm.pricedGlassParts = clonedGlassParts; vm.supportingItems = resultMap.supportingItems; - vm.availableLineItems = availableLineItems; //pricingResults; + vm.availableLineItems = pricingResults; }); }, data() { @@ -128,32 +128,18 @@ this.selectedVaps = vapsItemsSelected; }, backButtonAction() { - this.$router.navigate( - this.navigationScenarios.CLICKED_BACK, - this.$route - ); + this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, forwardButtonAction() { - //SAVE_PARENT_ACCOUNT_NUMBER, - //if (this.$store.order.payment.parentAccountNumber != - // applicationConfig.CASH_PARENT_ACCOUNT_NUMBER) { - // this.supportingItems = this.filterOutFees(this.supportingItems); - //} - //if (this.pricedGlassParts.length > 0) { - // this.storeActions.SAVE_GLASS_PARTS, - // this.pricedGlassParts, - //} - //this.storeActions.SAVE_SUPPORTING_ITEMS, - //this.supportingItems, - //this.storeActions.SAVE_VAPS, this.selectedVaps - //navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); + //TODO: save items + this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, this.$route); } }, components: { siteHeader, siteFooter, siteSubHeader, - Form, + Form, /* eslint-disable-line */ textBlock, servicePackageQuestion, loadingModal diff --git a/src/mixins/vehicle-questions-mixin.spec.js b/src/mixins/vehicle-questions-mixin.spec.js index 2e0c213d..2ee9bffc 100644 --- a/src/mixins/vehicle-questions-mixin.spec.js +++ b/src/mixins/vehicle-questions-mixin.spec.js @@ -285,8 +285,7 @@ describe("vehicle-questions-mixin", () => { const testCases = [ [issPageValues.PART_QUESTIONS, issPageValues.VEHICLE_PARTS, true], [issPageValues.VEHICLE_PARTS, issPageValues.VEHICLE_PARTS, false], - [issPageValues.QUOTE, issPageValues.VEHICLE_PARTS, false], - [issPageValues.QUOTE, issPageValues.QUOTE, false], + [issPageValues.VEHICLE_PARTS, issPageValues.REVEAL, false], [issPageValues.VEHICLE_PARTS, issPageValues.PART_QUESTIONS, false], [issPageValues.PART_QUESTIONS, issPageValues.CAPABILITY_QUESTIONS, true], [issPageValues.MOLDING_QUESTIONS, issPageValues.CAPABILITY_QUESTIONS, true], @@ -310,8 +309,7 @@ describe("vehicle-questions-mixin", () => { const testCases = [ [issPageValues.PART_QUESTIONS, issPageValues.VEHICLE_PARTS, false], [issPageValues.VEHICLE_PARTS, issPageValues.VEHICLE_PARTS, false], - [issPageValues.QUOTE, issPageValues.VEHICLE_PARTS, true], - [issPageValues.QUOTE, issPageValues.QUOTE, false], + [issPageValues.VEHICLE_PARTS, issPageValues.SERVICE_LOCATION, true], [issPageValues.VEHICLE_PARTS, issPageValues.PART_QUESTIONS, true], [issPageValues.PART_QUESTIONS, issPageValues.CAPABILITY_QUESTIONS, false], [issPageValues.MOLDING_QUESTIONS, issPageValues.CAPABILITY_QUESTIONS, false], @@ -2079,188 +2077,9 @@ describe("vehicle-questions-mixin", () => { ); }); }); - - // TODO KO UNSKIP FOR QUOTE MVP - describe.skip("should go to quote page", () => { - test("single glass location selected, has no part questions and has one part => go to heritage funnel", async () => { - // Arrange - const partsOrQuestions = [ - { - glassName: "Single", - glassLocation: "Windshield", - parts: [ - { - partNumber: "FW04186GTYN", - description: "solar, soundproofing, lane keep assist", - color: "Green Tint", - requiresRecalibration: true, - requiresCapabilityQuestions: false, - childParts: [ - { - partNumber: "GGG 3563 KIT", - partType: "MOULDING", - description: "Kit, Top & Sides ", - }, - ], - }, - ], - partQuestions: null, - }, - ]; - - const { wrapper } = setupMocks({ - partsOrQuestions: partsOrQuestions, - }); - - // Act - await wrapper.vm.navigateForward(partsOrQuestions); - - // Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); - expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - { query: { issPage: "vin-lookup" } } - ); - }); - - test("multiple glass locations selected, each has one part and no part questions => go to heritage funnel", async () => { - // Arrange - const partsOrQuestions = [ - { - glassName: "Single", - glassLocation: "Windshield", - parts: [ - { - partNumber: "FW04186GTYN", - description: "solar, soundproofing, lane keep assist", - color: "Green Tint", - requiresRecalibration: true, - requiresCapabilityQuestions: false, - childParts: [ - { - partNumber: "GGG 3563 KIT", - partType: "MOULDING", - description: "Kit, Top & Sides ", - }, - ], - }, - ], - partQuestions: null, - }, - { - glassName: "Back", - glassLocation: "Driver", - parts: [ - { - partNumber: "FD25457GTYN", - description: "solar, driver side, rear", - color: "Green Tint", - requiresRecalibration: false, - requiresCapabilityQuestions: false, - childParts: null, - }, - ], - partQuestions: null, - }, - { - glassName: "Front", - glassLocation: "Driver", - parts: [ - { - partNumber: "FD27090GTYN", - description: "solar, driver side, front", - color: "Green Tint", - requiresRecalibration: false, - requiresCapabilityQuestions: false, - childParts: null, - }, - ], - partQuestions: null, - }, - { - glassName: "Vent", - glassLocation: "Driver", - parts: [ - { - partNumber: "FV25459GTNN", - description: "solar, driver side, rear", - color: "Green Tint", - requiresRecalibration: false, - requiresCapabilityQuestions: false, - childParts: null, - }, - ], - partQuestions: null, - }, - { - glassName: "Stationary", - glassLocation: "Rear", - parts: [ - { - partNumber: "FB25460GTYN", - description: "heated glass, solar", - color: "Green Tint", - requiresRecalibration: false, - requiresCapabilityQuestions: false, - childParts: null, - }, - ], - partQuestions: null, - }, - ]; - - const { wrapper } = setupMocks({ - partsOrQuestions: partsOrQuestions, - }); - - - // Act - await wrapper.vm.navigateForward(partsOrQuestions); - - // Assert - expect(useMainStore.updateGlassParts).toHaveBeenCalledTimes(1); - expect(wrapper.vm.$router.navigate).toHaveBeenCalledTimes(1); - expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - { query: { issPage: "vin-lookup" } } - ); - }); - }); }); describe("navigateBack", () => { - - test("current page is quote and there are capability questions => go to capability questions", () => { - // Arrange - const { wrapper } = setupMocks({ issPage: issPageValues.QUOTE }); - wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true); - - // Act - wrapper.vm.navigateBack(); - - // Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_BACK_WITH_CAPABILITY_QUESTIONS, - { query: { issPage: issPageValues.QUOTE } } - ); - }); - - test("current page is quote and there are part questions and molding questions => go to molding questions", () => { - // Arrange - const { wrapper } = setupMocks({ issPage: issPageValues.QUOTE }); - wrapper.vm.hasPartQuestions = jest.fn().mockReturnValue(true); - wrapper.vm.hasChildPartQuestions = jest.fn().mockReturnValue(true); - - // Act - wrapper.vm.navigateBack(); - - // Assert - expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_BACK_WITH_MOLDING_QUESTIONS, - { query: { issPage: issPageValues.QUOTE } } - ); - }); - test("current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts", () => { // Arrange const { wrapper } = setupMocks({ issPage: issPageValues.MOLDING_QUESTIONS }); diff --git a/src/router/router-constants/issPage-values.js b/src/router/router-constants/issPage-values.js index f696f140..d53ec8bf 100644 --- a/src/router/router-constants/issPage-values.js +++ b/src/router/router-constants/issPage-values.js @@ -1,28 +1,28 @@ export const issPageValues = { - ENTRY_PAGE: 'entry-page', - WELCOME_PAGE: 'welcome-page', + ENTRY_PAGE: 'entry-page', + WELCOME_PAGE: 'welcome-page', - ADDRESS_LOOKUP: 'address-lookup', - ADDRESS_VEHICLES: 'address-vehicles', - CAPABILITY_QUESTIONS: 'capability-questions', - ESTIMATE: 'estimate', - COVERAGE_STATEMENT: 'coverage-statement', - LICENSE_PLATE_LOOKUP: 'license-plate-lookup', - MOLDING_QUESTIONS: 'molding-questions', - PART_QUESTIONS: 'part-questions', + ADDRESS_LOOKUP: 'address-lookup', + ADDRESS_VEHICLES: 'address-vehicles', + CAPABILITY_QUESTIONS: 'capability-questions', + ESTIMATE: 'estimate', + COVERAGE_STATEMENT: 'coverage-statement', + LICENSE_PLATE_LOOKUP: 'license-plate-lookup', + MOLDING_QUESTIONS: 'molding-questions', + PART_QUESTIONS: 'part-questions', POLICY_HOLDER_DETAILS: 'policy-holder-details', - PROVIDER_PREFERENCE: 'provider-preference', - REVEAL: 'reveal', - REVIEW_ORDER: 'review-order', - SERVICE_LOCATION: 'service-location', - SERVICE_PACKAGE: 'service-package', - VEHICLE_DAMAGE: 'vehicle-damage', - VEHICLE_LOOKUP: 'vehicle-lookup', - VEHICLE_MAKE: 'vehicle-make', - VEHICLE_MODEL: 'vehicle-model', - VEHICLE_PARTS: 'vehicle-parts', - VEHICLE_STYLE: 'vehicle-style', - VEHICLE_YEAR: 'vehicle-year', - VIN_LOOKUP: 'vin-lookup' + PROVIDER_PREFERENCE: 'provider-preference', + REVEAL: 'reveal', + REVIEW_ORDER: 'review-order', + SERVICE_LOCATION: 'service-location', + SERVICE_PACKAGE: 'service-package', + VEHICLE_DAMAGE: 'vehicle-damage', + VEHICLE_LOOKUP: 'vehicle-lookup', + VEHICLE_MAKE: 'vehicle-make', + VEHICLE_MODEL: 'vehicle-model', + VEHICLE_PARTS: 'vehicle-parts', + VEHICLE_STYLE: 'vehicle-style', + VEHICLE_YEAR: 'vehicle-year', + VIN_LOOKUP: 'vin-lookup' }; \ No newline at end of file diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index a73527eb..7a50a394 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -1,5 +1,5 @@ -import { issPageValues } from "@/router/router-constants/issPage-values"; -import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; +import { issPageValues } from '@/router/router-constants/issPage-values'; +import { navigationScenarios } from '@/router/router-constants/navigation-scenarios'; // Get store from router/index.js instead of importing it here to get updated values const routingTable = function(store) { @@ -14,8 +14,8 @@ const routingTable = function(store) { { scenario: navigationScenarios.SELECTED_YEAR, destinationIssPageValue: issPageValues.VEHICLE_MAKE - }, - ], + } + ] }, { issPageValue: issPageValues.VEHICLE_MAKE, @@ -27,19 +27,19 @@ const routingTable = function(store) { { scenario: navigationScenarios.SELECTED_MAKE, destinationIssPageValue: issPageValues.VEHICLE_MODEL - }, - ], + } + ] }, { issPageValue: issPageValues.VEHICLE_MODEL, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_MAKE, + destinationIssPageValue: issPageValues.VEHICLE_MAKE }, { scenario: navigationScenarios.SELECTED_MODEL, - destinationIssPageValue: issPageValues.VEHICLE_STYLE, + destinationIssPageValue: issPageValues.VEHICLE_STYLE } ] }, @@ -48,11 +48,11 @@ const routingTable = function(store) { maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_MODEL, + destinationIssPageValue: issPageValues.VEHICLE_MODEL }, { scenario: navigationScenarios.SELECTED_STYLE, - destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE } ] }, @@ -61,298 +61,298 @@ const routingTable = function(store) { maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_STYLE, + destinationIssPageValue: issPageValues.VEHICLE_STYLE }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, - }, - ], + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP + } + ] }, { issPageValue: issPageValues.VEHICLE_LOOKUP, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.SELECTED_MANUAL_VIN, - destinationIssPageValue: issPageValues.VIN_LOOKUP, + destinationIssPageValue: issPageValues.VIN_LOOKUP }, { scenario: navigationScenarios.SELECTED_LICENSE_PLATE, - destinationIssPageValue: issPageValues.LICENSE_PLATE_LOOKUP, + destinationIssPageValue: issPageValues.LICENSE_PLATE_LOOKUP }, { scenario: navigationScenarios.SELECTED_HOME_ADDRESS, - destinationIssPageValue: issPageValues.ADDRESS_LOOKUP, - }, - ], + destinationIssPageValue: issPageValues.ADDRESS_LOOKUP + } + ] }, { issPageValue: issPageValues.VIN_LOOKUP, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, - destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.LICENSE_PLATE_LOOKUP, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, - destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, - }, - ], + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS + } + ] }, { issPageValue: issPageValues.PART_QUESTIONS, maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP, + destinationIssPageValue: issPageValues.VIN_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.VEHICLE_PARTS, maps: [ { scenario: navigationScenarios.CLICKED_FORWARD, - destinationIssPageValue: issPageValues.REVEAL, + destinationIssPageValue: issPageValues.REVEAL }, { scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP, + destinationIssPageValue: issPageValues.VIN_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.MOLDING_QUESTIONS, maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP, + destinationIssPageValue: issPageValues.VIN_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.CAPABILITY_QUESTIONS, maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP, + destinationIssPageValue: issPageValues.VIN_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.ADDRESS_LOOKUP, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES, - destinationIssPageValue: issPageValues.ADDRESS_VEHICLES, + destinationIssPageValue: issPageValues.ADDRESS_VEHICLES }, { scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, - destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.ADDRESS_VEHICLES, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.ADDRESS_LOOKUP, + destinationIssPageValue: issPageValues.ADDRESS_LOOKUP }, { scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, - destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, - }, - ], + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT + } + ] }, { issPageValue: issPageValues.ENTRY_PAGE, @@ -364,8 +364,8 @@ const routingTable = function(store) { { scenario: navigationScenarios.MOVE_FORWARD_ENTRY_PAGE, destinationIssPageValue: issPageValues.WELCOME_PAGE - }, - ], + } + ] }, { issPageValue: issPageValues.WELCOME_PAGE, @@ -377,8 +377,8 @@ const routingTable = function(store) { { scenario: navigationScenarios.CLICKED_FORWARD_WELCOME_PAGE, destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS - }, - ], + } + ] }, { issPageValue: issPageValues.POLICY_HOLDER_DETAILS, @@ -390,58 +390,58 @@ const routingTable = function(store) { { scenario: navigationScenarios.CLICKED_FORWARD_POLICY_HOLDER_DETAILS, destinationIssPageValue: issPageValues.VEHICLE_YEAR - }, - ], + } + ] }, { issPageValue: issPageValues.COVERAGE_STATEMENT, maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP, + destinationIssPageValue: issPageValues.VIN_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP }, { scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS, - destinationIssPageValue: issPageValues.PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE, - destinationIssPageValue: issPageValues.VEHICLE_PARTS, + destinationIssPageValue: issPageValues.VEHICLE_PARTS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_MOLDING_QUESTIONS, - destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS }, { scenario: navigationScenarios.CLICKED_BACK_WITH_CAPABILITY_QUESTIONS, - destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS }, { scenario: navigationScenarios.CLICKED_FORWARD_COVERAGE_STATEMENT, - destinationIssPageValue: issPageValues.PROVIDER_PREFERENCE, - }, - ], + destinationIssPageValue: issPageValues.PROVIDER_PREFERENCE + } + ] }, { issPageValue: issPageValues.PROVIDER_PREFERENCE, maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.COVERAGE_STATEMENT, + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, - destinationIssPageValue: issPageValues.SERVICE_LOCATION, - }, - ], + destinationIssPageValue: issPageValues.SERVICE_LOCATION + } + ] }, { issPageValue: issPageValues.SERVICE_PACKAGE, - maps: [ + maps: [ { scenario: navigationScenarios.CLICKED_BACK, destinationIssPageValue: issPageValues.SERVICE_LOCATION diff --git a/src/store/index.js b/src/store/index.js index 692ea89d..d7344473 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -30,8 +30,8 @@ const getDefaultState = () => { state: null, zipCode: null, firstName: null, - lastName: null, - }, + lastName: null + } }, damage: { isRepair: null, @@ -39,7 +39,7 @@ const getDefaultState = () => { glassToReplace: null, partQuestionAnswers: null, moldingQuestionAnswers: null, - capabilityQuestionAnswers: null, + capabilityQuestionAnswers: null }, policy: { policyNumber: null, @@ -47,7 +47,7 @@ const getDefaultState = () => { damageCause: null, damageState: null, damageCity: null, - isDamageGlassOnly: null, + isDamageGlassOnly: null }, customer: { address: { @@ -55,12 +55,12 @@ const getDefaultState = () => { streetAddress2: null, city: null, state: null, - zipCode: null, + zipCode: null }, firstName: null, lastName: null, emailAddress: null, - phoneNumber: null, + phoneNumber: null }, serviceLocation: { address: null, @@ -78,11 +78,11 @@ const getDefaultState = () => { payment: { isInsurance: true, insuranceCoverage: { - isVerified: false, - }, + isVerified: false + } }, referralNumber: null, - referralDate: null, + referralDate: null }, applicationUser: { experiments: [], @@ -93,7 +93,7 @@ const getDefaultState = () => { savedSessionId: null, crmCustomerId: null, lastPageVisited: null, - triggeredSiteEntry: false, + triggeredSiteEntry: false }, issConfig: { clientName: "Generic Insurance", // this is the default and will be overriden by the client's name @@ -102,7 +102,7 @@ const getDefaultState = () => { accountNumber: 0, enableTPAFlow: false, returnURL: null, - returnURL2: null, + returnURL2: null } }; }; @@ -232,8 +232,8 @@ export const useMainStore = defineStore({ licenseLastName: licenseLastName, licenseStreetAddress: licenseStreetAddress, licenseZip: licenseZip, - licenseState: licenseState, - }, + licenseState: licenseState + } }); }, @@ -242,14 +242,14 @@ export const useMainStore = defineStore({ method: endpoints.GetRouteInfo.method, endpoint: endpoints.GetRouteInfo.url(applicationConfig.APPLICATION_ABBREVIATION), payload: { - pageName: pageName, + pageName: pageName }, }); }, getHomepageName() { return globalMethods.callHttpClient({ method: endpoints.GetHomepageInfo.method, - endpoint: endpoints.GetHomepageInfo.url(applicationConfig.APPLICATION_ABBREVIATION), + endpoint: endpoints.GetHomepageInfo.url(applicationConfig.APPLICATION_ABBREVIATION) }); }, @@ -257,7 +257,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetPageData.method, endpoint: endpoints.GetPageData.url(applicationConfig.APPLICATION_ABBREVIATION, pageName), - payload: {}, + payload: {} }); }, @@ -266,7 +266,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetVehicleYears.method, endpoint: endpoints.GetVehicleYears.url, - payload: {}, + payload: {} }); }, @@ -274,7 +274,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetVehicleMakes.method, endpoint: endpoints.GetVehicleMakes.url + this.order.vehicle.year, - payload: {}, + payload: {} }); }, @@ -282,7 +282,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetVehicleModels.method, endpoint: `${endpoints.GetVehicleModels.url}/${this.order.vehicle.year}/${this.order.vehicle.make}`, - payload: {}, + payload: {} }); }, @@ -290,7 +290,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetVehicleStyles.method, endpoint: `${endpoints.GetVehicleStyles.url}/${this.order.vehicle.year}/${this.order.vehicle.make}/${this.order.vehicle.model}`, - payload: {}, + payload: {} }); }, @@ -298,7 +298,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ methods: endpoints.GetDamageOptions.method, endpoint: `${endpoints.GetDamageOptions.url}/${carId}`, - payload: {}, + payload: {} }); }, getIsVinbyAddressPermissible(){ @@ -306,36 +306,36 @@ export const useMainStore = defineStore({ const response = globalMethods.callHttpClient({ method:endpoints.IsVinbyAddressPermissible.method, endpoint:`${endpoints.IsVinbyAddressPermissible.url}?state=${this.order.customer.address.state}`, - payload: {}, + payload: {} }); return response; } catch (responseError) { return { error: { - status: responseError.status, - }, + status: responseError.status + } }; } }, async lookupVinByPlate(licensePlate, licenseState) { - try { - const response = await globalMethods.callHttpClient({ - method: endpoints.LookupVinByPlate.method, - endpoint: endpoints.LookupVinByPlate.url, - payload: { - licensePlate: licensePlate, - licenseState: licenseState, - }, - }); + try { + const response = await globalMethods.callHttpClient({ + method: endpoints.LookupVinByPlate.method, + endpoint: endpoints.LookupVinByPlate.url, + payload: { + licensePlate: licensePlate, + licenseState: licenseState + } + }); - return response; - } catch (responseError) { - return { - error: { - status: responseError.status, - }, - }; - } + return response; + } catch (responseError) { + return { + error: { + status: responseError.status + } + }; + } }, // PartsOrQuestions API Actions @@ -360,8 +360,8 @@ export const useMainStore = defineStore({ carId: carId, glassPieces: glassArrayForPayload, zip: zipCode, - vin: vin, - }, + vin: vin + } }); // Flatten location and name properties @@ -395,8 +395,8 @@ export const useMainStore = defineStore({ glassPieces: glassArrayForPayload, answerResults: resultsArrayForPayload, zip: zipCode, - vin: vin, - }, + vin: vin + } }); // Flatten location and name properties @@ -410,7 +410,7 @@ export const useMainStore = defineStore({ getCapabilityQuestions(carId, partNumber) { return globalMethods.callHttpClient({ method: endpoints.GetCapabilityQuestions.method, - endpoint: `${endpoints.GetCapabilityQuestions.url}/${carId}/${partNumber}`, + endpoint: `${endpoints.GetCapabilityQuestions.url}/${carId}/${partNumber}` }); }, @@ -428,14 +428,14 @@ export const useMainStore = defineStore({ method: endpoints.GetPartFromCapabilityAnswer.method, endpoint: endpoints.GetPartFromCapabilityAnswer.url, payload: { - part, - capabilityAnswerResults: capabilityQuestionAnswersForPart, - }, + part, + capabilityAnswerResults: capabilityQuestionAnswersForPart + } }); }, - getWipers() { + async getWipers() { const carId = this.order.vehicle.carId; - ///WARNING WARNING DANGER WILL ROBINSON + ///WARNING ///TODO: this is temp test code until serviceLocation is complete. //const serviceZipCode = this.order.serviceLocation.zipCode; const serviceZipCode = '44902'; @@ -451,7 +451,7 @@ export const useMainStore = defineStore({ }); }, - getRainDefense() { + async getRainDefense() { return globalMethods .callHttpClient({ method: endpoints.GetRainDefense.method, @@ -465,12 +465,13 @@ export const useMainStore = defineStore({ }, - getSupportingItems() { + async getSupportingItems() { const glassPartsArray = this.order.lineItems.glassParts ?? []; - const carId = this.order.vehicle.carId; - const isRepair = this.order.damage.isRepair; - const numberOfChips = this.order.damage.numberOfChips; - return globalMethods + const carId = this.order.vehicle.carId; + const isRepair = this.order.damage.isRepair; + const numberOfChips = this.order.damage.numberOfChips; + + return globalMethods .callHttpClient({ method: endpoints.GetSupportingItems.method, endpoint: endpoints.GetSupportingItems.url, @@ -491,35 +492,35 @@ export const useMainStore = defineStore({ getLineItemQueryStringForPricing(availableLineItems); const vehicle = this.order.vehicle; - //TEMP - zipCodeToUse = "44902"; - let accountNumber = 0; - ctuToUse = 0; - //eon + ///WARNING + ///TODO: this is temp test code until serviceLocation is complete. + /// and ctu is available. Also, EON may need to be implemented. + zipCodeToUse = "44902" + ctuToUse = "01820" let queryString = - `ParentAccountNumber=${accountNumber}` + + `ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}` + `&CTU=${ctuToUse}` + `&CarId=${vehicle.carId}` + `&Make=${vehicle.make}` + `&Model=${vehicle.model}` + `&Year=${vehicle.year}` + + `&EON=0` + `&ZipCode=${zipCodeToUse}` + `${availableLineItemsFormattedForRequest}`; - //const lineItemServerData = order.lineItems.serverData; - //if (lineItemServerData) { - // queryString += `&ServerData=$(encodeURIComponent(lineItemServerData)}`; - //} + const response = await globalMethods + .callHttpClient({ + method: endpoints.GetPriceOrderItems.method, + endpoint: `${endpoints.GetPriceOrderItems.url}?${queryString}` + }).catch((error) => { + console.error(error); + return []; + }); - //return globalMethods - // .callHttpClient({ - // method: endpoints.GetPriceOrderItems.method, - // endpoint: `${endpoints.GetPriceOrderItems.url}?${queryString}` - // }).catch((error) => { - // console.error(error); - // return []; - // }); + availableLineItems = addPricesToLineItems(availableLineItems, response.data.lineItems) + + return availableLineItems; }, lookupVehicleByVin(vin) { @@ -537,7 +538,7 @@ export const useMainStore = defineStore({ .callHttpClient({ methods: endpoints.GetVehicle.method, endpoint: `${endpoints.GetVehicle.url}/${this.order.vehicle.year}/${this.order.vehicle.make}/${this.order.vehicle.model}/${this.order.vehicle.style}`, - payload: {}, + payload: {} }) .then((response) => { this.updateVehicle(response.data); @@ -859,7 +860,7 @@ export const useMainStore = defineStore({ this.updateCapabilityQuestionAnswers(null); this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, - data: null, + data: null }); } @@ -934,9 +935,9 @@ export const useMainStore = defineStore({ userPartitionNumber: experiment.userPartitionNumber, assignmentId: experiment.assignmentId, sessionKey: sessionKey, - pageName: pageName, - }, - }, + pageName: pageName + } + } }); }, logPageView({ userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId, experimentsForUser }) @@ -957,7 +958,7 @@ export const useMainStore = defineStore({ method: endpoints.LogPageView.method, endpoint: endpoints.LogPageView.url, payload: payload, - logApiCall: false, + logApiCall: false }); }, logCustomEvent({ userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId, experimentsForUser}) @@ -976,14 +977,14 @@ export const useMainStore = defineStore({ label: label, value: value, shouldUseSessionId: shouldUseSessionId, - experimentsForUser: experimentsForUser, + experimentsForUser: experimentsForUser }; return globalMethods.callHttpClient({ method: endpoints.LogCustomEvent.method, endpoint: endpoints.LogCustomEvent.url, payload: payload, - logApiCall: false, + logApiCall: false }); }, initializeSession({ userId, sessionId, userAgent, referrer }) { @@ -995,14 +996,14 @@ export const useMainStore = defineStore({ userAgent: userAgent, operatorId: "WEB", userName: "SafeliteISS", - referrer: referrer, + referrer: referrer }; return globalMethods.callHttpClient({ method: endpoints.InitializeSession.method, endpoint: endpoints.InitializeSession.url, payload: payload, - logApiCall: false, + logApiCall: false }); }, @@ -1021,7 +1022,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetExperimentsByUser.method, endpoint: `${endpoints.GetExperimentsByUser.url}/${userId}`, - payload: {}, + payload: {} }); }, @@ -1035,13 +1036,13 @@ export const useMainStore = defineStore({ userId: userId, triggerEvent: triggerEvent, triggerValue: triggerValue, - experimentOrder: this.experimentOrder, + experimentOrder: this.experimentOrder }; const response = await globalMethods.callHttpClient({ method: endpoints.RunExperimentsForTrigger.method, endpoint: endpoints.RunExperimentsForTrigger.url, - payload: payload, + payload: payload }); this.updateExperiments(response.data.experiments); @@ -1050,14 +1051,14 @@ export const useMainStore = defineStore({ async validateZip({ zip }) { return await globalMethods.callHttpClient({ methods: endpoints.ValidateZip.method, - endpoint: `${endpoints.ValidateZip.url}/${zip}`, + endpoint: `${endpoints.ValidateZip.url}/${zip}` }); }, async validateClientTag(clientTag) { return await globalMethods.callHttpClient({ methods: endpoints.ValidateClientTag.method, - endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`, + endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}` }); }, @@ -1208,7 +1209,7 @@ function convertGlassPieceNamingForApi(glassArray) { glassArray.forEach((glass) => { converted.push({ location: glass.glassLocation, - name: glass.glassName, + name: glass.glassName }); }); return converted; @@ -1221,7 +1222,7 @@ function convertResultsForApi(resultsArray) { converted.push({ location: answer.glassLocation, name: answer.glassName, - result: answer.result, + result: answer.result }); }); return converted; @@ -1249,6 +1250,22 @@ function getAllPartNumbers(partsOrQuestions) { : []; } +function addPricesToLineItems(lineItems, pricingLineItems) { + lineItems.forEach((lineItem) => { + const lineItemIndex = pricingLineItems.findIndex( + (pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber + ) + if (lineItem.childParts) { + addPricesToLineItems(lineItem.childParts, pricingLineItems) + } + const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0] + lineItem.laborAmount = pricedLineItem.laborAmount + lineItem.sellingPrice = pricedLineItem.sellingPrice + lineItem.kitPrice = pricedLineItem.kitPrice + }); + return lineItems; +} + function getLineItemQueryStringForPricing(lineItems) { return lineItems .map((lineItem) => { diff --git a/vue.config.js b/vue.config.js index 1deb871a..1be86b05 100644 --- a/vue.config.js +++ b/vue.config.js @@ -3,6 +3,7 @@ process.env.VUE_APP_CURRENT_ENVIRONMENT = "Localhost"; process.env.VUE_APP_GOOGLE_PLACES_API_KEY = "AIzaSyCuLhQcDdZTTb4JzpUFms1OCch2dk5lHF0"; +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // GA & GTM // NOTE: Using the old ISS site GTM Cotnainer ID for now, will create a new one soon. @@ -26,7 +27,8 @@ module.exports = { }, }, }, - configureWebpack: { - devtool: 'source-map' + configureWebpack: { + devtool: 'source-map', + plugins: [new MiniCssExtractPlugin()] }, };