Merge branch 'develop' of https://github.com/Safelite/DigitalConsumer.ISS into feature/digital/SSR-1043

git push
git push
git add .

git add .
git stauts
git add .
ls
Lines starting with '#' will be ignored, and an empty message aborts
This commit is contained in:
Michaela Brydon 2024-03-29 10:05:00 -04:00
commit f353ca414b
4 changed files with 107 additions and 10 deletions

View file

@ -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

View file

@ -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;
}
}
</style>

View file

@ -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('||');
},

View file

@ -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,