diff --git a/src/layouts/order-confirmation/order-confirmation.spec.js b/src/layouts/order-confirmation/order-confirmation.spec.js index 47e0f137..c38a062e 100644 --- a/src/layouts/order-confirmation/order-confirmation.spec.js +++ b/src/layouts/order-confirmation/order-confirmation.spec.js @@ -8,6 +8,7 @@ import settleAllPromises from '@/helpers/layout-helper.js'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { mount } from '@vue/test-utils'; import { createTestingPinia } from '@pinia/testing'; +import { nextTick } from 'vue'; jest.mock('@/helpers/layout-helper.js', () => jest.fn()); @@ -67,6 +68,16 @@ const initialStore = { zipCode: '12345' } } + }, + payment: { + isInsurance: true, + isPayInAdvance: false + }, + contactInfo: { + firstName: 'Test', + lastName: 'Test', + phoneNumber: '111-111-1111', + emailAddress: 'test@email.com' } } }; @@ -167,6 +178,20 @@ describe('OrderConfirmation.vue', () => { afterEach(() => { window.sessionStorage.removeItem('submittedOrder'); }); + describe('Page pre-requisites', () => { + test('If submitted order saved to store, page pre-reqs return true', async () => { + // Arrange + window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage)); + const { wrapper } = getMountedComponent(initialStore); + + // Act + const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + await nextTick(); + + // Assert + expect(arePagePrerequisitesValid).toBe(true); + }); + }); describe('Rendering', () => { test('Should render Site Header', () => { // Arrange diff --git a/src/layouts/order-confirmation/order-confirmation.vue b/src/layouts/order-confirmation/order-confirmation.vue index 8fcf3c54..c045f651 100644 --- a/src/layouts/order-confirmation/order-confirmation.vue +++ b/src/layouts/order-confirmation/order-confirmation.vue @@ -95,6 +95,7 @@ export default { }, mixins: [BaseFormMixin], async beforeRouteEnter(to, from, next) { + console.log('beforeRouteEnter just called'); useMainStore().createSubmittedOrder(); // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); @@ -270,6 +271,68 @@ export default { } }, methods: { + arePagePrerequisitesValid() { + const hasSubmittedOrder = useMainStore().hasSubmittedOrder(); + if (hasSubmittedOrder) { + return true; + } + + // Service Location + const { serviceLocation } = useMainStore().order; + const mobileReqs = !!( + serviceLocation.address + && serviceLocation.city + && serviceLocation.state + && serviceLocation.zipCode + ); + + const providerLocation = serviceLocation.provider.address; + const dropOffInShopReqs = !!( + providerLocation.streetAddress + && providerLocation.city + && providerLocation.state + && providerLocation.zipCode + ); + + const isMobile = serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE + || serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP; + + const serviceLocationReqs = + (isMobile && mobileReqs) || (!isMobile && dropOffInShopReqs); + + // Insurance + const isInsuranceSet = useMainStore().order.payment.isInsurance !== null; + + // Schedule + const { schedule } = useMainStore().order; + const scheduleReqs = !!( + schedule.date + && schedule.startTime + && schedule.endTime + && schedule.jobMaxMinutes + && schedule.jobMinMinutes + ); + + // Contact Info + const { contactInfo } = useMainStore().order; + const contactInfoReqs = !!( + contactInfo.firstName + && contactInfo.lastName + && contactInfo.phoneNumber + && contactInfo.emailAddress + ); + + // Payment + const paymentMethodReqs = useMainStore().order.payment.isPayInAdvance === false; + + return ( + serviceLocationReqs + && isInsuranceSet + && scheduleReqs + && contactInfoReqs + && paymentMethodReqs + ); + }, forwardButtonAction() { this.$router.navigateToExternalUrl(this.carrierUrl); }, @@ -355,5 +418,9 @@ $page-side-padding: 1.5rem; font-weight: $font-weight-bold; text-decoration: none; } + :deep(strong) { + font-weight: $font-weight-bold; + color: $black; + } } diff --git a/src/layouts/payment-page/payment-page.vue b/src/layouts/payment-page/payment-page.vue index d8d2f907..d8b6d3b5 100644 --- a/src/layouts/payment-page/payment-page.vue +++ b/src/layouts/payment-page/payment-page.vue @@ -664,21 +664,26 @@ export default { }, getPayInAdvanceLineItems(cartItems) { const { glassParts } = useMainStore().order.lineItems; - const lineItems = (glassParts === null) ? ['Labor|0|1', 'Repair supplies|0|1'] : ['Parts and labor|0|1']; + const lineItems = (glassParts === null) + ? [this.getPayInAdvanceFormattedLineItem('Labor', 0, 1), this.getPayInAdvanceFormattedLineItem('Repair supplies', 0, 1)] + : [this.getPayInAdvanceFormattedLineItem('Parts and labor', 0, 1)]; cartItems.forEach((item) => { if (item.name !== null && item.category !== 'promos') { - lineItems.push(`${item.name}|${(item.salesTax + item.subTotal).toFixed(2)}|1`); + lineItems.push(this.getPayInAdvanceFormattedLineItem(item.name, (item.salesTax + item.subTotal).toFixed(2), 1)); } }); this.payInAdvanceLineItems = lineItems.join('||'); }, + getPayInAdvanceFormattedLineItem(itemName, price, quantity) { + return `${itemName}|${price}|${quantity}`; + }, getMockPiaLineItems() { let lineItems = []; - lineItems = ['Parts and labor|0|1']; - lineItems.push('New wiper blades|75.22|1'); - lineItems.push('Recycling|37.60|1'); + lineItems = [this.getPayInAdvanceFormattedLineItem('Parts and labor', 0, 1)]; + lineItems.push(this.getPayInAdvanceFormattedLineItem('New wiper blades', 75.22, 1)); + lineItems.push(this.getPayInAdvanceFormattedLineItem('Recycling', 37.60, 1)); this.payInAdvanceLineItems = lineItems.join('||'); }, diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 0a7d4ab7..d003357b 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -162,7 +162,7 @@ const routingTable = () => [ maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, @@ -199,7 +199,7 @@ const routingTable = () => [ }, { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, @@ -224,7 +224,7 @@ const routingTable = () => [ maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, @@ -253,7 +253,7 @@ const routingTable = () => [ maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, @@ -486,7 +486,7 @@ const routingTable = () => [ maps: [ { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, - destinationIssPageValue: issPageValues.VIN_LOOKUP + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,