Merge pull request #367 from Safelite/defect/digital/SSR-505
Fixing bug with compensation
This commit is contained in:
commit
32ce777e0f
5 changed files with 280 additions and 267 deletions
|
|
@ -1,5 +1,9 @@
|
|||
<template>
|
||||
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }" >
|
||||
<Form
|
||||
ref="theForm"
|
||||
v-slot="{ meta }"
|
||||
@submit="onSubmit"
|
||||
@invalid-submit="onInvalidSubmit">
|
||||
<div class="page-container-grouped-styles">
|
||||
<div class="fade-on-route-transition position-relative">
|
||||
<siteHeader cmsWidgetName="SiteHeaderWidget" />
|
||||
|
|
@ -9,152 +13,155 @@
|
|||
<div class="col">
|
||||
<div class="select-car-form rounded pb-1">
|
||||
<textBlock
|
||||
id="coverage-statement-text-block"
|
||||
cmsWidgetName="verifyingCoverageStatement"
|
||||
typeStyle="h5"
|
||||
justifyText="center"
|
||||
class="mt-4 mb-4"
|
||||
id="coverage-statement-text-block" />
|
||||
class="mt-4 mb-4" />
|
||||
<div>
|
||||
<p v-html="continueWithSchedulingBodyText" class="mt-0 small" ></p>
|
||||
<p
|
||||
class="mt-0 small"
|
||||
v-html="continueWithSchedulingBodyText"></p>
|
||||
</div>
|
||||
<textBlock
|
||||
id="coverage-statement-text-block"
|
||||
cmsWidgetName="whatHappensNextCopy"
|
||||
class="mt-4 mb-2 fw-bold"
|
||||
id="coverage-statement-text-block" />
|
||||
class="mt-4 mb-2 fw-bold" />
|
||||
<div>
|
||||
<p class="small" v-html="bodyText" ref="coverageStatementBodyText"></p>
|
||||
<p
|
||||
ref="coverageStatementBodyText"
|
||||
class="small"
|
||||
v-html="bodyText"></p>
|
||||
</div>
|
||||
<steeringText cmsWidgetName="MASteeringText" ></steeringText>
|
||||
<steeringText cmsWidgetName="MASteeringText"></steeringText>
|
||||
</div>
|
||||
<siteFooter
|
||||
ref="siteFooter"
|
||||
class="mt-5"
|
||||
cmsWidgetName="SiteFooterWidget"
|
||||
:isForwardActionDisabled="!meta.valid"
|
||||
@backClicked="navigateBack"
|
||||
@forwardClicked="forwardButtonAction"
|
||||
ref="siteFooter" />
|
||||
@forwardClicked="forwardButtonAction" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<recalModal ref="RecalModal" cmsWidgetName="RecalModal" />
|
||||
<recalModal
|
||||
ref="RecalModal"
|
||||
cmsWidgetName="RecalModal" />
|
||||
</Form>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
// Import Component
|
||||
import baseFormMixin from '@/mixins/base-form-mixin';
|
||||
import { Form } from 'vee-validate';
|
||||
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
||||
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
|
||||
import textBlock from "@/digital-components/text-block/text-block";
|
||||
import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal.vue';
|
||||
import steeringText from "@/iss-components/steering-text/steering-text.vue";
|
||||
import siteFooter from '@/iss-components/site-footer/site-footer';
|
||||
import siteHeader from '@/iss-components/site-header/site-header';
|
||||
import textBlock from '@/digital-components/text-block/text-block';
|
||||
import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal';
|
||||
import steeringText from '@/iss-components/steering-text/steering-text';
|
||||
// Import Supporting Files
|
||||
import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper';
|
||||
import { settleAllPromises } from '@/helpers/layout-helper';
|
||||
import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper.js';
|
||||
import { settleAllPromises } from '@/helpers/layout-helper.js';
|
||||
import { getDamageString } from '@/helpers/damage-helper.js';
|
||||
import { useMainStore } from "@/store";
|
||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin.js';
|
||||
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
||||
|
||||
export default {
|
||||
name: 'coverage-statement',
|
||||
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||
components: {
|
||||
siteFooter,
|
||||
siteHeader,
|
||||
siteSubHeader,
|
||||
Form,
|
||||
textBlock,
|
||||
recalModal,
|
||||
steeringText
|
||||
},
|
||||
mounted() {
|
||||
setupModalLinks(this);
|
||||
},
|
||||
computed: {
|
||||
bodyText() {
|
||||
if (useMainStore().damage.isRepair) {
|
||||
return this.unverifiedNonADASRepairBodyText;
|
||||
}
|
||||
else {
|
||||
let parts = useMainStore().lineItems.glassParts;
|
||||
name: 'coverage-statement',
|
||||
components: {
|
||||
siteFooter,
|
||||
siteHeader,
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
Form,
|
||||
textBlock,
|
||||
recalModal,
|
||||
steeringText
|
||||
},
|
||||
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||
|
||||
// if ADAS, display ADASNextSteps
|
||||
if (parts != null && parts.filter(part => part.requiresRecalibration).length > 0) {
|
||||
return this.unverifiedADASNextStepsBodyText;
|
||||
}
|
||||
// if non-ADAS, display NonADASNextSteps
|
||||
else {
|
||||
return this.unverifiedNonADASNextStepsBodyText;
|
||||
}
|
||||
}
|
||||
},
|
||||
continueWithSchedulingBodyText() {
|
||||
return this.getCmsContent("continueWithSchedulingCopy", "BodyText");
|
||||
},
|
||||
unverifiedADASNextStepsBodyText() {
|
||||
return this.getCmsContent("UnverifiedADASNextStepsWidget", "BodyText").replaceAll("{custom:damage}", this.damageText);
|
||||
},
|
||||
unverifiedNonADASNextStepsBodyText() {
|
||||
return this.getCmsContent("UnverifiedNonADASNextStepsWidget", "BodyText").replaceAll("{custom:damage}", this.damageText);
|
||||
},
|
||||
unverifiedNonADASRepairBodyText() {
|
||||
return this.getCmsContent("UnverifiedNonADASRepairWidget", "BodyText");
|
||||
},
|
||||
damageText() {
|
||||
var damageString = getDamageString();
|
||||
return damageString == "match" ? "" : damageString;
|
||||
},
|
||||
},
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise
|
||||
}
|
||||
];
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise,
|
||||
},
|
||||
];
|
||||
if (useMainStore().isClaimRegistrationRequired && !useMainStore().policy.noCoverage) {
|
||||
const registerClaimResponse = await useMainStore().registerClaim();
|
||||
promiseResultMap.push({
|
||||
resultKey: 'registerClaim',
|
||||
promise: registerClaimResponse
|
||||
});
|
||||
}
|
||||
|
||||
if (useMainStore().isClaimRegistrationRequired){
|
||||
const registerClaimResponse = await useMainStore().registerClaim();
|
||||
promiseResultMap.push({
|
||||
resultKey: 'registerClaim',
|
||||
promise: registerClaimResponse,
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
bodyText() {
|
||||
if (useMainStore().damage.isRepair) {
|
||||
return this.unverifiedNonADASRepairBodyText;
|
||||
}
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
const parts = useMainStore().lineItems.glassParts;
|
||||
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
if (useMainStore().vehicle.vin) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// if ADAS, display ADASNextSteps
|
||||
if (parts != null && parts.filter((part) =>
|
||||
part.requiresRecalibration).length > 0) {
|
||||
return this.unverifiedADASNextStepsBodyText;
|
||||
}
|
||||
// if non-ADAS, display NonADASNextSteps
|
||||
|
||||
async forwardButtonAction() {
|
||||
return this.navigateForward();
|
||||
},
|
||||
return this.unverifiedNonADASNextStepsBodyText;
|
||||
},
|
||||
continueWithSchedulingBodyText() {
|
||||
return this.getCmsContent('continueWithSchedulingCopy', 'BodyText');
|
||||
},
|
||||
unverifiedADASNextStepsBodyText() {
|
||||
return this.getCmsContent('UnverifiedADASNextStepsWidget', 'BodyText').replaceAll('{custom:damage}', this.damageText);
|
||||
},
|
||||
unverifiedNonADASNextStepsBodyText() {
|
||||
return this.getCmsContent('UnverifiedNonADASNextStepsWidget', 'BodyText').replaceAll('{custom:damage}', this.damageText);
|
||||
},
|
||||
unverifiedNonADASRepairBodyText() {
|
||||
return this.getCmsContent('UnverifiedNonADASRepairWidget', 'BodyText');
|
||||
},
|
||||
damageText() {
|
||||
const damageString = getDamageString();
|
||||
return damageString === 'match' ? '' : damageString;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
setupModalLinks(this);
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
if (useMainStore().vehicle.vin) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
navigateForward() {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD,
|
||||
this.$route
|
||||
);
|
||||
},
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
return this.navigateForward();
|
||||
},
|
||||
|
||||
navigateForward() {
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
|
||||
this.$route);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ describe('policy-vehicles.vue', () => {
|
|||
const expectedInput = {
|
||||
year: year,
|
||||
vin: vin,
|
||||
noCompensation: true,
|
||||
noCoverage: true,
|
||||
deductible: 0,
|
||||
repairWaived: false
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ describe('policy-vehicles.vue', () => {
|
|||
//Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
const vin = getRandomString(17,17);
|
||||
const vin = getRandomString(17, 17);
|
||||
await wrapper.setData({
|
||||
selectedVehicleVin: vin,
|
||||
bailout: false
|
||||
|
|
@ -130,24 +130,24 @@ describe('policy-vehicles.vue', () => {
|
|||
{}
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('noCompensationForSelectedVehicle computed property', () => {
|
||||
describe('noCoverageForSelectedVehicle computed property', () => {
|
||||
it('No vehicle match => returns true', async () => {
|
||||
// Arrange
|
||||
const selectedVin = getRandomString(17,17);
|
||||
const otherVin = getRandomString(17,17);
|
||||
const selectedVin = getRandomString(17, 17);
|
||||
const otherVin = getRandomString(17, 17);
|
||||
const testValues = {
|
||||
selectedVehicleVin: selectedVin,
|
||||
policyVehicles: [
|
||||
{
|
||||
vin: otherVin,
|
||||
},
|
||||
],
|
||||
}
|
||||
vin: otherVin
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues);
|
||||
const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues);
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
|
|
@ -155,19 +155,19 @@ describe('policy-vehicles.vue', () => {
|
|||
|
||||
it('Coverages list empty => true', () => {
|
||||
// Arrange
|
||||
const vin = getRandomString(17,17);
|
||||
const vin = getRandomString(17, 17);
|
||||
const testValues = {
|
||||
selectedVehicleVin: vin,
|
||||
policyVehicles: [
|
||||
{
|
||||
vin: vin,
|
||||
vin,
|
||||
coverages: []
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues);
|
||||
const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues);
|
||||
|
||||
// Assert
|
||||
expect(result).toBeTruthy();
|
||||
|
|
@ -175,28 +175,28 @@ describe('policy-vehicles.vue', () => {
|
|||
|
||||
it('Coverages list non-empty => false', () => {
|
||||
// Arrange
|
||||
const vin = getRandomString(17,17);
|
||||
const vin = getRandomString(17, 17);
|
||||
const testValues = {
|
||||
selectedVehicleVin: vin,
|
||||
policyVehicles: [
|
||||
{
|
||||
vin: vin,
|
||||
vin,
|
||||
coverages: [
|
||||
{
|
||||
deductible: 0
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Act
|
||||
const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues);
|
||||
const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues);
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('deductibleForSelectedVehicle computed property', () => {
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export default {
|
|||
}) ?? [];
|
||||
return mappedData;
|
||||
},
|
||||
noCompensationForSelectedVehicle() {
|
||||
noCoverageForSelectedVehicle() {
|
||||
const vehicle = this.policyVehicles.find((policyVehicle) =>
|
||||
policyVehicle.vin === this.selectedVehicleVin);
|
||||
return (vehicle?.coverages?.length ?? 0) === 0;
|
||||
|
|
@ -174,7 +174,7 @@ export default {
|
|||
|
||||
this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, {
|
||||
vin: this.selectedVehicleVin,
|
||||
noCompensation: this.noCompensationForSelectedVehicle,
|
||||
noCoverage: this.noCoverageForSelectedVehicle,
|
||||
deductible: this.deductibleForSelectedVehicle,
|
||||
repairWaived: this.repairWaivedForSelectedVehicle
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const getDefaultState = () =>
|
|||
damageState: null,
|
||||
damageCity: null,
|
||||
isDamageGlassOnly: null,
|
||||
noCompensation: null,
|
||||
noCoverage: null,
|
||||
deductible: {
|
||||
repair: null, // numerical value; how much customer owes on deductible in repair case
|
||||
replace: null // numerical value; how much customer owes on deductible in replace case,
|
||||
|
|
@ -396,6 +396,10 @@ export const useMainStore = defineStore({
|
|||
number: this.order.customer.phoneNumber?.replaceAll(nonNumberCharRegex, '') ?? ''
|
||||
}
|
||||
},
|
||||
driver: {
|
||||
firstName: this.order.customer.firstName,
|
||||
lastName: this.order.customer.lastName
|
||||
},
|
||||
caller: {
|
||||
homePhone: {}
|
||||
},
|
||||
|
|
@ -424,11 +428,13 @@ export const useMainStore = defineStore({
|
|||
}).then((response) => {
|
||||
const registerClaimFailed = response.data.isError;
|
||||
this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed;
|
||||
this.order.payment.insuranceCoverage.coverageStatus = registerClaimFailed
|
||||
? coverageStatuses.PENDING
|
||||
: this.policy.noCompensation
|
||||
? coverageStatuses.NO_COMP
|
||||
: coverageStatuses.VERIFIED;
|
||||
if (registerClaimFailed) {
|
||||
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
} else if (this.policy.noCoverage) {
|
||||
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.NO_COMP;
|
||||
} else {
|
||||
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
|
||||
}
|
||||
}, (error) => {
|
||||
this.order.payment.insuranceCoverage.isVerified = false;
|
||||
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
|
||||
|
|
@ -764,7 +770,7 @@ export const useMainStore = defineStore({
|
|||
this.order.vehicle.imageColor = vehicle.imageVifColor;
|
||||
|
||||
// These could be undefined
|
||||
this.order.policy.noCompensation = vehicle.noCoverage;
|
||||
this.order.policy.noCoverage = vehicle.noCoverage;
|
||||
this.order.policy.deductible.replace = vehicle.deductible;
|
||||
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useMainStore } from '@/store';
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import globalMethods from '@/global-methods';
|
||||
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation';
|
||||
import globalMethods from '@/global-methods.js';
|
||||
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
|
||||
import { coverageStatuses } from '@/constants/coverage-statuses.js';
|
||||
|
||||
describe('Store', () => {
|
||||
|
|
@ -29,15 +29,15 @@ describe('Store', () => {
|
|||
const copy = getRandomString(5, 25);
|
||||
const headline = getRandomString(5, 25);
|
||||
const type = getRandomString(5, 15);
|
||||
let event = {
|
||||
category: category,
|
||||
subCategory: subCategory,
|
||||
const event = {
|
||||
category,
|
||||
subCategory,
|
||||
eventValue: {
|
||||
isDismissible: isDismissible,
|
||||
isDismissible,
|
||||
messageCopy: copy,
|
||||
messageHeadline: headline,
|
||||
type: type,
|
||||
},
|
||||
type
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -55,15 +55,15 @@ describe('Store', () => {
|
|||
const copy = getRandomString(5, 25);
|
||||
const headline = getRandomString(5, 25);
|
||||
const type = getRandomString(5, 15);
|
||||
let event = {
|
||||
category: category,
|
||||
subCategory: subCategory,
|
||||
const event = {
|
||||
category,
|
||||
subCategory,
|
||||
eventValue: {
|
||||
isDismissible: isDismissible,
|
||||
isDismissible,
|
||||
messageCopy: copy,
|
||||
messageHeadline: headline,
|
||||
type: type,
|
||||
},
|
||||
type
|
||||
}
|
||||
};
|
||||
|
||||
store.addEventToBus(event);
|
||||
|
|
@ -85,21 +85,21 @@ describe('Store', () => {
|
|||
const copy = getRandomString(5, 25);
|
||||
const headline = getRandomString(5, 25);
|
||||
const type = getRandomString(5, 15);
|
||||
let event = {
|
||||
category: category,
|
||||
subCategory: subCategory,
|
||||
const event = {
|
||||
category,
|
||||
subCategory,
|
||||
eventValue: {
|
||||
isDismissible: isDismissible,
|
||||
isDismissible,
|
||||
messageCopy: copy,
|
||||
messageHeadline: headline,
|
||||
type: type,
|
||||
},
|
||||
type
|
||||
}
|
||||
};
|
||||
|
||||
store.addEventToBus(event);
|
||||
|
||||
// Act
|
||||
const actual = store.eventBusItem(event.category, event.subCategory)
|
||||
const actual = store.eventBusItem(event.category, event.subCategory);
|
||||
|
||||
// Assert
|
||||
expect(actual).toEqual(event.eventValue);
|
||||
|
|
@ -107,38 +107,38 @@ describe('Store', () => {
|
|||
|
||||
it('UpdateVehicle should merge vehicle with response object', () => {
|
||||
// Arrange
|
||||
const carId = getRandomString(10,14);
|
||||
const category = getRandomString(3,7);
|
||||
const carId = getRandomString(10, 14);
|
||||
const category = getRandomString(3, 7);
|
||||
const year = getRandomInt(1960, 2023);
|
||||
const make = getRandomString(4,10);
|
||||
const model = getRandomString(4,10);
|
||||
const style = getRandomString(4,15);
|
||||
const imageUrl = getRandomString(50,100);
|
||||
const imageVifNumber = getRandomInt(10000,99999).toString();
|
||||
const imageColor = getRandomString(4,10);
|
||||
const make = getRandomString(4, 10);
|
||||
const model = getRandomString(4, 10);
|
||||
const style = getRandomString(4, 15);
|
||||
const imageUrl = getRandomString(50, 100);
|
||||
const imageVifNumber = getRandomInt(10000, 99999).toString();
|
||||
const imageColor = getRandomString(4, 10);
|
||||
const providedVehicle = {
|
||||
carId: carId,
|
||||
category: category,
|
||||
year: year,
|
||||
make: make,
|
||||
model: model,
|
||||
style: style,
|
||||
imageUrl: imageUrl,
|
||||
imageVifNumber: imageVifNumber,
|
||||
carId,
|
||||
category,
|
||||
year,
|
||||
make,
|
||||
model,
|
||||
style,
|
||||
imageUrl,
|
||||
imageVifNumber,
|
||||
imageVifColor: imageColor
|
||||
};
|
||||
|
||||
const expectedVehicle = {
|
||||
carId: carId,
|
||||
category: category,
|
||||
year: year,
|
||||
make: make,
|
||||
model: model,
|
||||
style: style,
|
||||
imageUrl: imageUrl,
|
||||
imageVifNumber: imageVifNumber,
|
||||
imageColor: imageColor
|
||||
}
|
||||
carId,
|
||||
category,
|
||||
year,
|
||||
make,
|
||||
model,
|
||||
style,
|
||||
imageUrl,
|
||||
imageVifNumber,
|
||||
imageColor
|
||||
};
|
||||
|
||||
// Act
|
||||
store.updateVehicle(providedVehicle);
|
||||
|
|
@ -149,16 +149,16 @@ describe('Store', () => {
|
|||
|
||||
it('UpdateVehicle should set policy values appropriately with repair waived', () => {
|
||||
// Arrange
|
||||
const noCompensation = getRandomBoolean();
|
||||
const deductible = getRandomInt(1,500);
|
||||
const noCoverage = getRandomBoolean();
|
||||
const deductible = getRandomInt(1, 500);
|
||||
const vehicle = {
|
||||
noCoverage: noCompensation,
|
||||
deductible: deductible,
|
||||
noCoverage,
|
||||
deductible,
|
||||
repairWaived: true
|
||||
};
|
||||
|
||||
const expectedPolicy = {
|
||||
noCompensation: noCompensation,
|
||||
noCoverage,
|
||||
deductible: {
|
||||
replace: deductible,
|
||||
repair: 0
|
||||
|
|
@ -174,16 +174,16 @@ describe('Store', () => {
|
|||
|
||||
it('UpdateVehicle should set policy values appropriately with repair not waived', () => {
|
||||
// Arrange
|
||||
const noCompensation = getRandomBoolean();
|
||||
const deductible = getRandomInt(1,500);
|
||||
const noCoverage = getRandomBoolean();
|
||||
const deductible = getRandomInt(1, 500);
|
||||
const vehicle = {
|
||||
noCoverage: noCompensation,
|
||||
deductible: deductible,
|
||||
noCoverage,
|
||||
deductible,
|
||||
repairWaived: false
|
||||
};
|
||||
|
||||
const expectedPolicy = {
|
||||
noCompensation: noCompensation,
|
||||
noCoverage,
|
||||
deductible: {
|
||||
replace: deductible,
|
||||
repair: deductible
|
||||
|
|
@ -200,25 +200,25 @@ describe('Store', () => {
|
|||
// TODO update test to work also checking store values
|
||||
it('setVehicle should call globalMethods.callHttpClient', () => {
|
||||
// Arrange
|
||||
const carId = getRandomString(10,14);
|
||||
const category = getRandomString(3,7);
|
||||
const carId = getRandomString(10, 14);
|
||||
const category = getRandomString(3, 7);
|
||||
const year = getRandomInt(1960, 2023);
|
||||
const make = getRandomString(4,10);
|
||||
const model = getRandomString(4,10);
|
||||
const style = getRandomString(4,15);
|
||||
const imageUrl = getRandomString(50,100);
|
||||
const imageVifNumber = getRandomInt(10000,99999).toString();
|
||||
const imageColor = getRandomString(4,10);
|
||||
const make = getRandomString(4, 10);
|
||||
const model = getRandomString(4, 10);
|
||||
const style = getRandomString(4, 15);
|
||||
const imageUrl = getRandomString(50, 100);
|
||||
const imageVifNumber = getRandomInt(10000, 99999).toString();
|
||||
const imageColor = getRandomString(4, 10);
|
||||
const response = {
|
||||
data: {
|
||||
carId: carId,
|
||||
category: category,
|
||||
year: year,
|
||||
make: make,
|
||||
model: model,
|
||||
style: style,
|
||||
imageUrl: imageUrl,
|
||||
imageVifNumber: imageVifNumber,
|
||||
carId,
|
||||
category,
|
||||
year,
|
||||
make,
|
||||
model,
|
||||
style,
|
||||
imageUrl,
|
||||
imageVifNumber,
|
||||
imageVifColor: imageColor
|
||||
}
|
||||
};
|
||||
|
|
@ -235,14 +235,14 @@ describe('Store', () => {
|
|||
|
||||
it('saveVehicleDamage with windshield repair should update damage with number of chips not null', () => {
|
||||
// Arrange
|
||||
const glassName = getRandomString(4,10);
|
||||
const glassLocation = getRandomString(5,15);
|
||||
const glassName = getRandomString(4, 10);
|
||||
const glassLocation = getRandomString(5, 15);
|
||||
const isWindshieldRepair = true;
|
||||
const selectedGlassToReplace = [{
|
||||
glassName: glassName,
|
||||
glassLocation: glassLocation
|
||||
glassName,
|
||||
glassLocation
|
||||
}];
|
||||
const chipCount = getRandomInt(0,3);
|
||||
const chipCount = getRandomInt(0, 3);
|
||||
|
||||
// Act
|
||||
store.saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, chipCount);
|
||||
|
|
@ -255,14 +255,14 @@ describe('Store', () => {
|
|||
|
||||
it('saveVehicleDamage without windshield repair should update damage with number of chips null', () => {
|
||||
// Arrange
|
||||
const glassName = getRandomString(4,10);
|
||||
const glassLocation = getRandomString(5,15);
|
||||
const glassName = getRandomString(4, 10);
|
||||
const glassLocation = getRandomString(5, 15);
|
||||
const isWindshieldRepair = false;
|
||||
const selectedGlassToReplace = [{
|
||||
glassName: glassName,
|
||||
glassLocation: glassLocation
|
||||
glassName,
|
||||
glassLocation
|
||||
}];
|
||||
const chipCount = getRandomInt(0,3);
|
||||
const chipCount = getRandomInt(0, 3);
|
||||
|
||||
const expectedChipCount = null;
|
||||
|
||||
|
|
@ -276,77 +276,77 @@ describe('Store', () => {
|
|||
});
|
||||
|
||||
it('should return registration data if available', () => {
|
||||
//Arrange
|
||||
const streetAddress = getRandomString(5,15);
|
||||
const city = getRandomString(5,15);
|
||||
const state = getRandomString(5,10);
|
||||
const zipCode = getRandomInt(10000,99999).toString();
|
||||
const firstName = getRandomString(5,20);
|
||||
const lastName = getRandomString(5,20);
|
||||
// Arrange
|
||||
const streetAddress = getRandomString(5, 15);
|
||||
const city = getRandomString(5, 15);
|
||||
const state = getRandomString(5, 10);
|
||||
const zipCode = getRandomInt(10000, 99999).toString();
|
||||
const firstName = getRandomString(5, 20);
|
||||
const lastName = getRandomString(5, 20);
|
||||
const expected = {
|
||||
addressQuestions: {
|
||||
streetAddress: streetAddress,
|
||||
city: city,
|
||||
state: state,
|
||||
zipCode: zipCode,
|
||||
streetAddress,
|
||||
city,
|
||||
state,
|
||||
zipCode
|
||||
},
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
}
|
||||
firstName,
|
||||
lastName
|
||||
};
|
||||
|
||||
store.order.vehicle.registration = {
|
||||
licensePlate: null,
|
||||
address: streetAddress,
|
||||
city: city,
|
||||
state: state,
|
||||
zipCode: zipCode,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
city,
|
||||
state,
|
||||
zipCode,
|
||||
firstName,
|
||||
lastName
|
||||
};
|
||||
|
||||
//Act
|
||||
// Act
|
||||
const actual = store.customerData;
|
||||
|
||||
//Assert
|
||||
// Assert
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should return customer data if registration data unavailable', () => {
|
||||
//Arrange
|
||||
const address = getRandomString(1,25);
|
||||
const city = getRandomString(5,20);
|
||||
const state = getRandomString(4,20);
|
||||
// Arrange
|
||||
const address = getRandomString(1, 25);
|
||||
const city = getRandomString(5, 20);
|
||||
const state = getRandomString(4, 20);
|
||||
const zipCode = getRandomInt(10000, 99999).toString();
|
||||
const firstName = getRandomString(5,25);
|
||||
const lastName = getRandomString(5,25);
|
||||
const firstName = getRandomString(5, 25);
|
||||
const lastName = getRandomString(5, 25);
|
||||
const expected = {
|
||||
addressQuestions: {
|
||||
streetAddress: address,
|
||||
city: city,
|
||||
state: state,
|
||||
zipCode: zipCode,
|
||||
city,
|
||||
state,
|
||||
zipCode
|
||||
},
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
}
|
||||
firstName,
|
||||
lastName
|
||||
};
|
||||
|
||||
store.order.vehicle.registration.address = null;
|
||||
|
||||
store.order.customer = {
|
||||
address: {
|
||||
streetAddress: address,
|
||||
city: city,
|
||||
state: state,
|
||||
zipCode: zipCode
|
||||
city,
|
||||
state,
|
||||
zipCode
|
||||
},
|
||||
firstName: firstName,
|
||||
lastName: lastName
|
||||
firstName,
|
||||
lastName
|
||||
};
|
||||
|
||||
//Act
|
||||
// Act
|
||||
const actual = store.customerData;
|
||||
|
||||
//Assert
|
||||
// Assert
|
||||
expect(actual).toMatchObject(expected);
|
||||
});
|
||||
|
||||
|
|
@ -364,7 +364,7 @@ describe('Store', () => {
|
|||
deductible: 0
|
||||
}
|
||||
};
|
||||
store.policy.noCompensation = true;
|
||||
store.policy.noCoverage = true;
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ describe('Store', () => {
|
|||
deductible: 0
|
||||
}
|
||||
};
|
||||
store.policy.noCompensation = false;
|
||||
store.policy.noCoverage = false;
|
||||
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue