add page pre-reqs + one minor styling change + unit tests

This commit is contained in:
Katie Kroell 2024-03-26 14:30:17 -04:00
parent 98602d8f2b
commit bf41d0837b
2 changed files with 56 additions and 0 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());
@ -167,6 +168,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

@ -270,6 +270,44 @@ export default {
}
},
methods: {
arePagePrerequisitesValid() {
if (useMainStore().hasSubmittedOrder) {
return true;
}
// Service Location
const { serviceLocation } = this.submittedOrder;
const mobileReqs = !!(
serviceLocation.address
&& serviceLocation.city
&& serviceLocation.state
&& serviceLocation.zipCode
);
const { providerLocation } = this.submittedOrder.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);
// Schedule
const { schedule } = this.submittedOrder;
const scheduleReqs = !!(schedule.date && schedule.startTime && schedule.endTime);
// Customer
const { customer } = this.submittedOrder;
const customerReqs = !!customer.emailAddress;
return serviceLocationReqs && scheduleReqs && customerReqs;
},
forwardButtonAction() {
this.$router.navigateToExternalUrl(this.carrierUrl);
},
@ -355,5 +393,8 @@ $page-side-padding: 1.5rem;
font-weight: $font-weight-bold;
text-decoration: none;
}
:deep(strong) {
color: $black;
}
}
</style>