Merge remote-tracking branch 'origin/develop' into feature/digital/SSR-1081
This commit is contained in:
commit
89f2bbaa15
16 changed files with 1506 additions and 1013 deletions
|
|
@ -117,7 +117,7 @@ const endpoints = Object.freeze({
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
TaxOrderItems: {
|
TaxOrderItems: {
|
||||||
url: '/price/api/v1/price/taxed-order-items',
|
url: `${PRICE_BASE_URL}/taxed-order-items`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
LogExperimentExposureIfAssigned: {
|
LogExperimentExposureIfAssigned: {
|
||||||
|
|
|
||||||
12
src/helpers/price-calculator.js
Normal file
12
src/helpers/price-calculator.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
function getPriceOfLineItem(lineItem) {
|
||||||
|
return (lineItem?.kitPrice ?? 0)
|
||||||
|
+ (lineItem?.laborAmount ?? 0)
|
||||||
|
+ (lineItem?.sellingPrice ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function getPriceOfLineItems(lineItems) {
|
||||||
|
return lineItems.reduce(
|
||||||
|
(accumulator, lineItem) => accumulator + getPriceOfLineItem(lineItem),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
56
src/helpers/price-calculator.spec.js
Normal file
56
src/helpers/price-calculator.spec.js
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
import getPriceOfLineItems from "@/helpers/price-calculator.js";
|
||||||
|
|
||||||
|
describe('getPriceOfLineItems', () => {
|
||||||
|
test('Returns zero when no line items', () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = [];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(0);
|
||||||
|
});
|
||||||
|
test('Returns expected when one line item', () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = [
|
||||||
|
{
|
||||||
|
kitPrice: 1,
|
||||||
|
laborAmount: 2,
|
||||||
|
sellingPrice: 3
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const expected = 6;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expected);
|
||||||
|
});
|
||||||
|
test('Returns expected when multiple line items', () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = [
|
||||||
|
{
|
||||||
|
kitPrice: 1,
|
||||||
|
laborAmount: 2,
|
||||||
|
sellingPrice: 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kitPrice: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
kitPrice: 10,
|
||||||
|
laborAmount: 100,
|
||||||
|
sellingPrice: 1000
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const expected = 1117;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = getPriceOfLineItems(lineItems);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -23,12 +23,9 @@ export default {
|
||||||
return this.genericVehicleImage;
|
return this.genericVehicleImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
let imageUrl = '';
|
const imageUrl = (this.mainStore.hasSubmittedOrder())
|
||||||
if (this.mainStore.hasSubmittedOrder()) {
|
? this.mainStore.submittedOrder.vehicle.imageUrl
|
||||||
imageUrl = this.mainStore.submittedOrder.vehicle.imageUrl;
|
: this.mainStore.order.vehicle.imageUrl;
|
||||||
} else {
|
|
||||||
imageUrl = this.mainStore.order.vehicle.imageUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!imageUrl || imageUrl === 'NULL') {
|
if (!imageUrl || imageUrl === 'NULL') {
|
||||||
return this.getUnmatchedVehicleIcon();
|
return this.getUnmatchedVehicleIcon();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`coverageStatement.vue-working returns the initial data 1`] = `
|
||||||
|
Object {
|
||||||
|
"baseServiceLineItems": Array [],
|
||||||
|
"currencyFormatter": NumberFormat {},
|
||||||
|
"deductibleText": "Your deductible is",
|
||||||
|
"isNoComp": false,
|
||||||
|
"isRepair": true,
|
||||||
|
"loadingText": Array [
|
||||||
|
"Connecting to your insurance company",
|
||||||
|
"Nearly there",
|
||||||
|
"Finishing up",
|
||||||
|
],
|
||||||
|
"policyLookupSuccessful": true,
|
||||||
|
"rules": Object {
|
||||||
|
"selectionRequired": "option-required",
|
||||||
|
},
|
||||||
|
"selectedProvider": "",
|
||||||
|
"supportingItems": null,
|
||||||
|
"widget": Object {
|
||||||
|
"explanatoryText": "ExplanatoryTextWidget",
|
||||||
|
"nextStep": "NextStepsWidget",
|
||||||
|
"serviceProviderQuestion": "ServiceProviderQuestion",
|
||||||
|
"subheader": "SiteSubHeaderWidget",
|
||||||
|
"verifiedItacAlert": "VerifiedITACAlert",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -35,26 +35,26 @@
|
||||||
<div
|
<div
|
||||||
v-if="verifiedDeductible"
|
v-if="verifiedDeductible"
|
||||||
class="d-flex justify-content-center cost">
|
class="d-flex justify-content-center cost">
|
||||||
{{ formattedDeductible }}
|
{{ deductibleForDisplay }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="displayQuote"
|
v-if="isQuoteDisplayed"
|
||||||
class="d-flex justify-content-center cost mb-0">
|
class="d-flex justify-content-center cost mb-0">
|
||||||
{{ formattedServicePrice }}
|
{{ servicePriceForDisplay }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="verifiedITAC"
|
v-if="verifiedITAC"
|
||||||
class="d-flex justify-content-center mb-4 deductible-text">
|
class="d-flex justify-content-center mb-4 deductible-text">
|
||||||
{{ deductibleText }}
|
{{ deductibleText }}
|
||||||
<span class="text-success fw-bold">{{ formattedDeductible }}</span>
|
<span class="text-success fw-bold">{{ deductibleForDisplay }}</span>
|
||||||
</div>
|
</div>
|
||||||
<alert
|
<alert
|
||||||
v-if="verifiedITAC"
|
v-if="verifiedITAC"
|
||||||
ref="verifiedITACAlert"
|
ref="verifiedITACAlert"
|
||||||
class="mb-5"
|
class="mb-5"
|
||||||
cmsWidgetName="VerifiedITACAlert"
|
cmsWidgetName="VerifiedITACAlert"
|
||||||
:manualHeadline="verifiedITACAlertHeader"
|
:manualHeadline="verifiedItacAlertHeader"
|
||||||
:manualCopy="verifiedITACAlertBody"
|
:manualCopy="verifiedItacAlertBody"
|
||||||
alertClass="alert-success"
|
alertClass="alert-success"
|
||||||
:isDismissible="false">
|
:isDismissible="false">
|
||||||
</alert>
|
</alert>
|
||||||
|
|
@ -67,18 +67,18 @@
|
||||||
v-html="nextStepsBody">
|
v-html="nextStepsBody">
|
||||||
</div>
|
</div>
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
v-if="displayQuote"
|
v-if="isQuoteDisplayed"
|
||||||
v-model="selectedProvider"
|
v-model="selectedProvider"
|
||||||
cmsWidgetName="ServiceProviderQuestion"
|
cmsWidgetName="ServiceProviderQuestion"
|
||||||
:questionText="questionText"
|
:questionText="serviceProviderQuestionText"
|
||||||
:answers="answersFromCms"
|
:answers="serviceProviderQuestionAnswers"
|
||||||
groupName="ServiceProviderQuestionOption"
|
groupName="ServiceProviderQuestionOption"
|
||||||
buttonTypeString="listButton"
|
buttonTypeString="listButton"
|
||||||
isRequired
|
isRequired
|
||||||
:validationRules="rules.selectionRequired">
|
:validationRules="rules.selectionRequired">
|
||||||
</buttonQuestion>
|
</buttonQuestion>
|
||||||
<text-block
|
<text-block
|
||||||
v-if="displayQuote"
|
v-if="isQuoteDisplayed"
|
||||||
cmsWidgetName="DisclaimerWidget"
|
cmsWidgetName="DisclaimerWidget"
|
||||||
typeStyle="caption" />
|
typeStyle="caption" />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -88,7 +88,7 @@
|
||||||
cmsWidgetName="SiteFooterWidget"
|
cmsWidgetName="SiteFooterWidget"
|
||||||
:isForwardActionDisabled="!meta.valid"
|
:isForwardActionDisabled="!meta.valid"
|
||||||
@backClicked="navigateBackByVehicleQuestions"
|
@backClicked="navigateBackByVehicleQuestions"
|
||||||
@forwardClicked="forwardButtonAction" />
|
@forwardClicked="navigateForward" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -126,10 +126,16 @@ import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin.js';
|
||||||
import globalRules from '@/constants/global-rules.js';
|
import globalRules from '@/constants/global-rules.js';
|
||||||
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import bailoutCode from '@/constants/bailoutCode';
|
|
||||||
import bailoutMessage from '@/constants/bailoutMessage';
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
|
import widgetFields from '@/constants/cms-widget-fields.js';
|
||||||
|
import getPriceOfLineItems from '@/helpers/price-calculator.js';
|
||||||
|
|
||||||
|
const SAFELITE_PROVIDER = 'Safelite';
|
||||||
|
|
||||||
|
function setBailout(currentRoute, message) {
|
||||||
|
useMainStore().setBailout(currentRoute, message);
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'coverage-statement',
|
name: 'coverage-statement',
|
||||||
|
|
@ -164,8 +170,8 @@ export default {
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
const clonedGlassParts = useMainStore().order.lineItems.glassParts
|
const clonedGlassParts = useMainStore().lineItems.glassParts
|
||||||
? JSON.parse(JSON.stringify(useMainStore().order.lineItems.glassParts))
|
? JSON.parse(JSON.stringify(useMainStore().lineItems.glassParts))
|
||||||
: [];
|
: [];
|
||||||
const availableLineItems = [
|
const availableLineItems = [
|
||||||
...(resultMap.supportingItems ?? []),
|
...(resultMap.supportingItems ?? []),
|
||||||
|
|
@ -174,11 +180,14 @@ export default {
|
||||||
|
|
||||||
let hasBailedOut = false;
|
let hasBailedOut = false;
|
||||||
let pricingResults = [];
|
let pricingResults = [];
|
||||||
if (useMainStore().order.policy.policyLookupSuccessful && useMainStore().order.vehicle.policyVehicleId >= 0) {
|
if (useMainStore().policy.policyLookupSuccessful && useMainStore().vehicle.policyVehicleId >= 0) {
|
||||||
await useMainStore().getFinalDeductible();
|
await useMainStore().getFinalDeductible();
|
||||||
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
|
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
useMainStore().setBailout(to, bailoutMessage.pricingResponseError(availableLineItems.map((li) => li.partNumber), { code: err.code, message: err.message, data: err.data }));
|
setBailout(to, bailoutMessage.pricingResponseError(
|
||||||
|
availableLineItems.map((li) => li.partNumber),
|
||||||
|
{ code: err.code, message: err.message, data: err.data }
|
||||||
|
));
|
||||||
hasBailedOut = true;
|
hasBailedOut = true;
|
||||||
next(`/?issPage=${issPageValues.BAILOUT_PAGE}`);
|
next(`/?issPage=${issPageValues.BAILOUT_PAGE}`);
|
||||||
});
|
});
|
||||||
|
|
@ -190,22 +199,27 @@ export default {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.setSupportingItems(resultMap.supportingItems);
|
vm.setSupportingItems(resultMap.supportingItems);
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
vm.availableLineItems = pricingResults;
|
vm.setBaseServiceLineItems(pricingResults);
|
||||||
vm.$refs.loadingModal.showModal();
|
vm.$refs.loadingModal.showModal();
|
||||||
vm.initializeComponent(availableLineItems);
|
vm.initializeComponent();
|
||||||
if (!vm.unverified) {
|
if (!vm.unverified) {
|
||||||
useMainStore().disableKeyFields();
|
useMainStore().disableKeyFields();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup() {
|
|
||||||
const mainStore = useMainStore();
|
|
||||||
return { mainStore };
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
|
const { isRepair } = useMainStore().damage;
|
||||||
|
const { policyLookupSuccessful, noCoverage } = useMainStore().policy;
|
||||||
return {
|
return {
|
||||||
availableLineItems: [],
|
currencyFormatter: new Intl.NumberFormat('en-US', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'USD'
|
||||||
|
}),
|
||||||
|
isRepair,
|
||||||
|
policyLookupSuccessful,
|
||||||
|
isNoComp: noCoverage ?? false,
|
||||||
|
baseServiceLineItems: [],
|
||||||
selectedProvider: '',
|
selectedProvider: '',
|
||||||
deductibleText: 'Your deductible is',
|
deductibleText: 'Your deductible is',
|
||||||
// TODO update when design team gives appropriate text
|
// TODO update when design team gives appropriate text
|
||||||
|
|
@ -217,84 +231,90 @@ export default {
|
||||||
rules: {
|
rules: {
|
||||||
selectionRequired: globalRules.OPTION_REQUIRED
|
selectionRequired: globalRules.OPTION_REQUIRED
|
||||||
},
|
},
|
||||||
supportingItems: null
|
supportingItems: null,
|
||||||
|
widget: {
|
||||||
|
subheader: 'SiteSubHeaderWidget',
|
||||||
|
verifiedItacAlert: 'VerifiedITACAlert',
|
||||||
|
explanatoryText: 'ExplanatoryTextWidget',
|
||||||
|
nextStep: 'NextStepsWidget',
|
||||||
|
serviceProviderQuestion: 'ServiceProviderQuestion'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
verifiedITACAlertHeader() {
|
coverageStatementSubHeader() {
|
||||||
return this.getCmsContent(
|
return this.getTextFromCmsWithCustomIfStatements(
|
||||||
'VerifiedITACAlert',
|
this.widget.subheader,
|
||||||
'HeadlineText'
|
widgetFields.SUB_HEADER_WIDGET.SUB_HEADER_TEXT
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
verifiedITACAlertBody() {
|
verifiedItacAlertHeader() {
|
||||||
return this.getCmsContent(
|
return this.getCmsContent(
|
||||||
'VerifiedITACAlert',
|
this.widget.verifiedItacAlert,
|
||||||
'BodyText'
|
widgetFields.ALERT_WIDGET.HEADLINE_TEXT
|
||||||
)?.replaceAll('{custom:costSavings}', this.costSavings);
|
);
|
||||||
},
|
},
|
||||||
coverageStatementSubHeader() {
|
verifiedItacAlertBody() {
|
||||||
return this.getSubheaderTextFromCms('SiteSubHeaderWidget');
|
return this.getCmsContent(
|
||||||
|
this.widget.verifiedItacAlert,
|
||||||
|
widgetFields.ALERT_WIDGET.BODY_TEXT
|
||||||
|
)?.replaceAll('{custom:costSavings}', this.itacCostSavingsForDisplay);
|
||||||
},
|
},
|
||||||
secondaryText() {
|
secondaryText() {
|
||||||
return this.getSecondaryTextFromCms('SiteSubHeaderWidget');
|
return this.getTextFromCmsWithCustomIfStatements(
|
||||||
|
this.widget.subheader,
|
||||||
|
widgetFields.SUB_HEADER_WIDGET.SECONDARY_TEXT
|
||||||
|
);
|
||||||
},
|
},
|
||||||
explanatoryText() {
|
explanatoryText() {
|
||||||
return this.getExplantoryTextFromCms('ExplanatoryTextWidget');
|
return this.getTextFromCmsWithCustomIfStatements(
|
||||||
|
this.widget.explanatoryText,
|
||||||
|
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT
|
||||||
|
);
|
||||||
},
|
},
|
||||||
nextStepsHeader() {
|
nextStepsHeader() {
|
||||||
return this.getHeaderTextFromCms('NextStepsWidget');
|
return this.getTextFromCmsWithCustomIfStatements(
|
||||||
|
this.widget.nextStep,
|
||||||
|
widgetFields.CONTENT_GROUP_WIDGET.HEADER_TEXT
|
||||||
|
);
|
||||||
},
|
},
|
||||||
nextStepsBody() {
|
nextStepsBody() {
|
||||||
return this.getBodyTextFromCms('NextStepsWidget')?.replaceAll('{custom:damage}', this.damageText);
|
return this.getTextFromCmsWithCustomIfStatements(
|
||||||
},
|
this.widget.nextStep,
|
||||||
continueWithSchedulingBodyText() {
|
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT
|
||||||
return this.getCmsContent('continueWithSchedulingCopy', 'BodyText');
|
)?.replaceAll('{custom:damage}', this.damageText);
|
||||||
},
|
|
||||||
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() {
|
damageText() {
|
||||||
const damageString = getDamageString();
|
const damageString = getDamageString();
|
||||||
return damageString === 'match' ? '' : damageString;
|
return damageString === 'match' ? '' : damageString;
|
||||||
},
|
},
|
||||||
vehicleDeductible() {
|
deductibleValue() {
|
||||||
const deductible = useMainStore().order.currentDeductible;
|
return useMainStore().order.currentDeductible;
|
||||||
return deductible;
|
|
||||||
},
|
},
|
||||||
formattedDeductible() {
|
deductibleForDisplay() {
|
||||||
return this.getDeductibleString(this.vehicleDeductible);
|
return this.getFormattedAmount(this.deductibleValue);
|
||||||
},
|
|
||||||
isDeductibleZero() {
|
|
||||||
return this.vehicleDeductible === 0;
|
|
||||||
},
|
|
||||||
policyLookupSuccessful() {
|
|
||||||
return useMainStore().order.policy.policyLookupSuccessful;
|
|
||||||
},
|
},
|
||||||
registerClaimSuccessful() {
|
registerClaimSuccessful() {
|
||||||
return useMainStore().payment.insuranceCoverage.isVerified;
|
return useMainStore().payment.insuranceCoverage.isVerified;
|
||||||
},
|
},
|
||||||
verifiedNoComp() {
|
verifiedNoComp() {
|
||||||
return this.policyLookupSuccessful ? useMainStore().order.policy.noCoverage : false;
|
return this.policyLookupSuccessful && this.isNoComp;
|
||||||
},
|
},
|
||||||
verifiedITAC() {
|
verifiedITAC() {
|
||||||
return this.policyLookupSuccessful
|
return this.policyLookupSuccessful
|
||||||
&& !this.verifiedNoComp
|
&& !this.isNoComp
|
||||||
&& this.vehicleDeductible > this.totalServicePrice;
|
&& this.deductibleValue > this.totalServicePrice;
|
||||||
},
|
},
|
||||||
coveredAndServicePriceAboveOrEqualDeductible() {
|
coveredAndServicePriceAboveOrEqualDeductible() {
|
||||||
return !this.verifiedNoComp && this.totalServicePrice >= this.vehicleDeductible;
|
return !this.verifiedNoComp && this.totalServicePrice >= this.deductibleValue;
|
||||||
},
|
},
|
||||||
verifiedDeductible() {
|
verifiedDeductible() {
|
||||||
return useMainStore().isClaimRegistrationRequired
|
return useMainStore().isClaimRegistrationRequired
|
||||||
? this.registerClaimSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible && this.vehicleDeductible !== null
|
? this.registerClaimSuccessful
|
||||||
: this.policyLookupSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible;
|
&& this.coveredAndServicePriceAboveOrEqualDeductible
|
||||||
|
&& this.deductibleValue !== null
|
||||||
|
: this.policyLookupSuccessful
|
||||||
|
&& this.coveredAndServicePriceAboveOrEqualDeductible;
|
||||||
},
|
},
|
||||||
unverified() {
|
unverified() {
|
||||||
return !this.verifiedDeductible && !this.verifiedITAC && !this.verifiedNoComp;
|
return !this.verifiedDeductible && !this.verifiedITAC && !this.verifiedNoComp;
|
||||||
|
|
@ -303,41 +323,46 @@ export default {
|
||||||
const parts = useMainStore().order.lineItems.glassParts;
|
const parts = useMainStore().order.lineItems.glassParts;
|
||||||
return parts !== null && !!parts.find((part) => part.requiresRecalibration);
|
return parts !== null && !!parts.find((part) => part.requiresRecalibration);
|
||||||
},
|
},
|
||||||
isRepair() {
|
|
||||||
return useMainStore().order.damage.isRepair;
|
|
||||||
},
|
|
||||||
totalServicePrice() {
|
totalServicePrice() {
|
||||||
let total = 0;
|
return getPriceOfLineItems(this.baseServiceLineItems);
|
||||||
this.availableLineItems.forEach((lineItem) => {
|
|
||||||
total += this.getTotalLineItemPrice(lineItem);
|
|
||||||
});
|
|
||||||
return total;
|
|
||||||
},
|
},
|
||||||
formattedServicePrice() {
|
servicePriceForDisplay() {
|
||||||
return this.getServicePriceString(this.totalServicePrice);
|
return this.getFormattedAmount(this.totalServicePrice);
|
||||||
},
|
},
|
||||||
costSavings() {
|
itacCostSavings() {
|
||||||
const savings = this.getITACCostSavings(this.vehicleDeductible, this.totalServicePrice);
|
return this.deductibleValue - this.totalServicePrice;
|
||||||
const formattedSavings = parseFloat(savings).toFixed(2);
|
|
||||||
return `$${formattedSavings}`;
|
|
||||||
},
|
},
|
||||||
questionText() {
|
itacCostSavingsForDisplay() {
|
||||||
return this.getCmsContent('ServiceProviderQuestion', 'QuestionText');
|
return this.getFormattedAmount(this.itacCostSavings);
|
||||||
},
|
},
|
||||||
answersFromCms() {
|
serviceProviderQuestionText() {
|
||||||
return this.getCmsContent('ServiceProviderQuestion', 'Answers');
|
return this.getCmsContent(
|
||||||
|
this.widget.serviceProviderQuestion,
|
||||||
|
widgetFields.INPUT_QUESTION_WIDGET.QUESTION_TEXT
|
||||||
|
);
|
||||||
},
|
},
|
||||||
displayQuote() {
|
serviceProviderQuestionAnswers() {
|
||||||
|
return this.getCmsContent(
|
||||||
|
this.widget.serviceProviderQuestion,
|
||||||
|
widgetFields.INPUT_QUESTION_WIDGET.ANSWERS
|
||||||
|
);
|
||||||
|
},
|
||||||
|
isQuoteDisplayed() {
|
||||||
return this.verifiedITAC || this.verifiedNoComp;
|
return this.verifiedITAC || this.verifiedNoComp;
|
||||||
|
},
|
||||||
|
shouldRegisterClaim() {
|
||||||
|
return this.policyLookupSuccessful
|
||||||
|
&& useMainStore().vehicle.policyVehicleId != null
|
||||||
|
&& useMainStore().vehicle.policyVehicleId >= 0
|
||||||
|
&& useMainStore().isClaimRegistrationRequired
|
||||||
|
&& !useMainStore().isClaimAlreadyRegistered
|
||||||
|
&& (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectedProvider() {
|
selectedProvider() {
|
||||||
if (this.selectedProvider === 'Safelite') {
|
const buttonText = this.selectedProvider === SAFELITE_PROVIDER ? 'Continue with Safelite' : 'Safelite';
|
||||||
this.$refs.siteFooter.updateButtonText('Continue with Safelite');
|
this.$refs.siteFooter.updateButtonText(buttonText);
|
||||||
} else {
|
|
||||||
this.$refs.siteFooter.updateButtonText('Continue');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
nextStepsBody(newValue, oldValue) {
|
nextStepsBody(newValue, oldValue) {
|
||||||
if (newValue !== oldValue) {
|
if (newValue !== oldValue) {
|
||||||
|
|
@ -353,78 +378,43 @@ export default {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return !!useMainStore().vehicle.carId;
|
return !!useMainStore().vehicle.carId;
|
||||||
},
|
},
|
||||||
|
getFormattedAmount(amount) {
|
||||||
|
return this.currencyFormatter.format(amount);
|
||||||
|
},
|
||||||
async initializeComponent() {
|
async initializeComponent() {
|
||||||
useMainStore().updatePolicyITACFlag(this.verifiedITAC);
|
useMainStore().updatePolicyITACFlag(this.verifiedITAC);
|
||||||
if (this.policyLookupSuccessful
|
if (this.shouldRegisterClaim) {
|
||||||
&& useMainStore().order.vehicle.policyVehicleId >= 0
|
|
||||||
&& useMainStore().isClaimRegistrationRequired
|
|
||||||
&& !useMainStore().isClaimAlreadyRegistered
|
|
||||||
&& (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC)) {
|
|
||||||
await useMainStore().registerClaim()?.catch(() => {});
|
await useMainStore().registerClaim()?.catch(() => {});
|
||||||
}
|
}
|
||||||
this.$refs.loadingModal.hideModal();
|
this.$refs.loadingModal.hideModal();
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
|
||||||
return this.navigateForward();
|
|
||||||
},
|
|
||||||
async navigateForward() {
|
async navigateForward() {
|
||||||
if (this.unverified || this.verifiedDeductible) {
|
if (this.unverified || this.verifiedDeductible) {
|
||||||
useMainStore().updateSupportingItems(this.supportingItems);
|
useMainStore().updateSupportingItems(this.supportingItems);
|
||||||
this.$router.navigate(
|
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD);
|
||||||
navigationScenarios.CLICKED_FORWARD,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
} else if (this.verifiedITAC || this.verifiedNoComp) {
|
} else if (this.verifiedITAC || this.verifiedNoComp) {
|
||||||
useMainStore().updateIsSafeliteProvider(this.selectedProvider === 'Safelite');
|
useMainStore().updateIsSafeliteProvider(this.selectedProvider === SAFELITE_PROVIDER);
|
||||||
if (this.selectedProvider === 'Safelite') {
|
if (this.selectedProvider === SAFELITE_PROVIDER) {
|
||||||
useMainStore().updateSupportingItems(this.supportingItems);
|
useMainStore().updateSupportingItems(this.supportingItems);
|
||||||
this.$router.navigate(
|
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE);
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.RequestCallback());
|
this.setBailoutWithMessage(bailoutMessage.RequestCallback());
|
||||||
this.$router.navigate(
|
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP);
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_NON_SAFELITE_SHOP,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.coverageStatementInvalidState());
|
this.setBailoutWithMessage(bailoutMessage.coverageStatementInvalidState());
|
||||||
this.$router.navigate(
|
this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE);
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
processIfStatements,
|
setBailoutWithMessage(message) {
|
||||||
getHeaderTextFromCms(cmsWidgetName) {
|
setBailout(this.$router.currentRoute, message);
|
||||||
const header = this.getCmsContent(cmsWidgetName, 'HeaderText');
|
|
||||||
return this.processIfStatements(header, 'custom', this.getCustomValueFromString);
|
|
||||||
},
|
},
|
||||||
getSubheaderTextFromCms(cmsWidgetName) {
|
navigateWithScenario(scenario) {
|
||||||
const subHeader = this.getCmsContent(cmsWidgetName, 'SubHeaderText');
|
this.$router.navigate(scenario, this.$route);
|
||||||
return this.processIfStatements(subHeader, 'custom', this.getCustomValueFromString);
|
|
||||||
},
|
},
|
||||||
getBodyTextFromCms(cmsWidgetName) {
|
getTextFromCmsWithCustomIfStatements(widgetName, widgetField) {
|
||||||
const bodyText = this.getCmsContent(cmsWidgetName, 'BodyText');
|
const rawText = this.getCmsContent(widgetName, widgetField);
|
||||||
return this.processIfStatements(bodyText, 'custom', this.getCustomValueFromString);
|
return processIfStatements(rawText, 'custom', this.getCustomValueFromString);
|
||||||
},
|
|
||||||
getSecondaryTextFromCms(cmsWidgetName) {
|
|
||||||
const secondaryText = this.getCmsContent(cmsWidgetName, 'SecondaryText');
|
|
||||||
return this.processIfStatements(secondaryText, 'custom', this.getCustomValueFromString);
|
|
||||||
},
|
|
||||||
getExplantoryTextFromCms(cmsWidgetName) {
|
|
||||||
const explanatoryText = this.getCmsContent(cmsWidgetName, 'BodyText');
|
|
||||||
return this.processIfStatements(explanatoryText, 'custom', this.getCustomValueFromString);
|
|
||||||
},
|
},
|
||||||
getCustomValueFromString(str) {
|
getCustomValueFromString(str) {
|
||||||
switch (str) {
|
switch (str) {
|
||||||
|
|
@ -443,29 +433,18 @@ export default {
|
||||||
case 'nonADASRepair':
|
case 'nonADASRepair':
|
||||||
return this.isRepair;
|
return this.isRepair;
|
||||||
case 'deductibleOverZero':
|
case 'deductibleOverZero':
|
||||||
return this.verifiedDeductible && !this.isDeductibleZero; // TODO what if deductible is negative?
|
return this.verifiedDeductible && this.deductibleValue !== 0; // TODO what if deductible is negative?
|
||||||
case 'isDeductibleZero':
|
case 'isDeductibleZero':
|
||||||
return this.verifiedDeductible && this.isDeductibleZero;
|
return this.verifiedDeductible && this.deductibleValue === 0;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getTotalLineItemPrice(lineItem) {
|
|
||||||
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
|
|
||||||
},
|
|
||||||
getDeductibleString(deductible) {
|
|
||||||
const formattedDeductibleFloat = parseFloat(deductible).toFixed(2);
|
|
||||||
return `$${formattedDeductibleFloat}`;
|
|
||||||
},
|
|
||||||
getServicePriceString(price) {
|
|
||||||
const formattedPriceFloat = parseFloat(price).toFixed(2);
|
|
||||||
return `$${formattedPriceFloat}`;
|
|
||||||
},
|
|
||||||
getITACCostSavings(vehicleDeductible, totalServicePrice) {
|
|
||||||
return vehicleDeductible - totalServicePrice;
|
|
||||||
},
|
|
||||||
setSupportingItems(newSupportingItems) {
|
setSupportingItems(newSupportingItems) {
|
||||||
this.supportingItems = newSupportingItems;
|
this.supportingItems = newSupportingItems;
|
||||||
|
},
|
||||||
|
setBaseServiceLineItems(lineItems) {
|
||||||
|
this.baseServiceLineItems = lineItems;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -475,7 +454,7 @@ export default {
|
||||||
.cost {
|
.cost {
|
||||||
color: $green;
|
color: $green;
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
font-weight: 300;
|
font-weight: $font-weight-light;
|
||||||
line-height: 2.75rem;
|
line-height: 2.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,8 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext
|
SubText: expectedSubtext,
|
||||||
|
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle make => returns order with only date subtext', () => {
|
||||||
|
|
@ -173,7 +174,8 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext
|
SubText: expectedSubtext,
|
||||||
|
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
test('duplicateOrder in store with null vehicle model => returns order with only date subtext', () => {
|
||||||
|
|
@ -210,7 +212,8 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: expectedSubtext
|
SubText: expectedSubtext,
|
||||||
|
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
test('duplicateOrder in store with all vehicle info => returns order with year, make, model and date in subtext', () => {
|
||||||
|
|
@ -248,7 +251,8 @@ describe('duplicateCheck.vue', () => {
|
||||||
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
expect(wrapper.vm.duplicateOrders[0]).toStrictEqual({
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: referralNumber,
|
Name: referralNumber,
|
||||||
SubText: `${expectedVehicle}, ${expectedDate}`
|
SubText: `${expectedVehicle}, ${expectedDate}`,
|
||||||
|
value: useMainStore().applicationUser.duplicateOrders[0]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -352,7 +356,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
test('Selected duplicate => load session called', async () => {
|
test('Selected duplicate => load session called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const newOrderSelectionName = getRandomString(6, 6);
|
||||||
const selectedAnswer = getRandomString(6, 6);
|
const selectedAnswer = {};
|
||||||
|
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: { navigate: jest.fn() }
|
router: { navigate: jest.fn() }
|
||||||
|
|
@ -405,7 +409,7 @@ describe('duplicateCheck.vue', () => {
|
||||||
test('Load session throws error => still navigate forward', async () => {
|
test('Load session throws error => still navigate forward', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const newOrderSelectionName = getRandomString(6, 6);
|
const newOrderSelectionName = getRandomString(6, 6);
|
||||||
const selectedAnswer = getRandomString(6, 6);
|
const selectedAnswer = {};
|
||||||
|
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: { navigate: jest.fn() }
|
router: { navigate: jest.fn() }
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedAnswer: '',
|
selectedAnswer: null,
|
||||||
widget: {
|
widget: {
|
||||||
siteHeader: 'SiteHeaderWidget',
|
siteHeader: 'SiteHeaderWidget',
|
||||||
siteSubHeader: 'SiteSubHeaderWidget',
|
siteSubHeader: 'SiteSubHeaderWidget',
|
||||||
|
|
@ -113,7 +113,8 @@ export default {
|
||||||
return {
|
return {
|
||||||
Text: duplicateOrderText,
|
Text: duplicateOrderText,
|
||||||
Name: o.referralNumber,
|
Name: o.referralNumber,
|
||||||
SubText: toTitleCase(subtext)
|
SubText: toTitleCase(subtext),
|
||||||
|
value: o
|
||||||
};
|
};
|
||||||
}) ?? [];
|
}) ?? [];
|
||||||
},
|
},
|
||||||
|
|
@ -126,13 +127,16 @@ export default {
|
||||||
* @summary Steps to perform when forward button clicked.
|
* @summary Steps to perform when forward button clicked.
|
||||||
*/
|
*/
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (this.selectedAnswer !== this.getNewOrderSelectionName) {
|
if (this.selectedAnswer !== null && typeof this.selectedAnswer === 'object') {
|
||||||
await useMainStore().loadSession()
|
await useMainStore().loadSession(this.selectedAnswer)
|
||||||
.then(() => {}, () => {})
|
.catch(() => {})
|
||||||
.finally(() => { this.navigateForward(); });
|
.finally(() => {
|
||||||
} else {
|
this.navigateForward();
|
||||||
this.navigateForward();
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.navigateForward();
|
||||||
},
|
},
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
if (!this.mainStore.order.policy.policyLookupSuccessful) {
|
if (!this.mainStore.order.policy.policyLookupSuccessful) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
fetchCmsContentForPage: jest.fn(),
|
fetchCmsContentForPage: jest.fn(),
|
||||||
processIfStatements: jest.fn()
|
processIfStatements: jest.fn()
|
||||||
}));
|
}));
|
||||||
const wordingText = 'wording Text {custom:address}';
|
const wordingText = 'wording text {custom:address}';
|
||||||
|
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -67,6 +67,55 @@ const initialStore = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sessionStorage = {
|
||||||
|
schedule: {
|
||||||
|
date: '2024-03-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00',
|
||||||
|
jobMinMinutes: 60,
|
||||||
|
jobMaxMinutes: 90
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
address: '123 Test Way',
|
||||||
|
address2: '#1',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345',
|
||||||
|
appointmentType: 'Inshop',
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sessionStorageMock = (() => {
|
||||||
|
let sessionStore = {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
getItem(key) {
|
||||||
|
return sessionStore[key] || null;
|
||||||
|
},
|
||||||
|
setItem(key, value) {
|
||||||
|
sessionStore[key] = value.toString();
|
||||||
|
},
|
||||||
|
removeItem(key) {
|
||||||
|
delete sessionStore[key];
|
||||||
|
},
|
||||||
|
clear() {
|
||||||
|
sessionStore = {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
Object.defineProperty(window, 'sessionStorage', {
|
||||||
|
value: sessionStorageMock
|
||||||
|
});
|
||||||
|
|
||||||
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
|
|
@ -107,9 +156,16 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('OrderConfirmation.vue', () => {
|
describe('OrderConfirmation.vue', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
window.sessionStorage.clear();
|
||||||
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
window.sessionStorage.removeItem('submittedOrder');
|
||||||
|
});
|
||||||
describe('Rendering', () => {
|
describe('Rendering', () => {
|
||||||
test('Should render Site Header', () => {
|
test('Should render Site Header', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -120,6 +176,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('Should render Vehicle Banner', () => {
|
test('Should render Vehicle Banner', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -130,6 +187,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('If Advanced flow, should display Site Footer', () => {
|
test('If Advanced flow, should display Site Footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const testStore = {
|
const testStore = {
|
||||||
order: {
|
order: {
|
||||||
schedule: {
|
schedule: {
|
||||||
|
|
@ -154,6 +212,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('If Essential flow, should not display Site Footer', () => {
|
test('If Essential flow, should not display Site Footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -166,6 +225,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
describe('Navigation', () => {
|
describe('Navigation', () => {
|
||||||
test('If Advanced flow, forward button action navigates to carrier URL', () => {
|
test('If Advanced flow, forward button action navigates to carrier URL', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const carrierReturnUrl = 'testURL';
|
const carrierReturnUrl = 'testURL';
|
||||||
const testStore = {
|
const testStore = {
|
||||||
order: {
|
order: {
|
||||||
|
|
@ -193,6 +253,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
describe('Computed properties', () => {
|
describe('Computed properties', () => {
|
||||||
test('appointmentDateFormatted should return date in expected format', () => {
|
test('appointmentDateFormatted should return date in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -203,19 +264,18 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('appointmentTimeFormatted should return Mobile time in expected format', () => {
|
test('appointmentTimeFormatted should return Mobile time in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testSessionStorage = {
|
||||||
order: {
|
schedule: {
|
||||||
schedule: {
|
date: '2019-01-01',
|
||||||
date: '2019-01-01',
|
startTime: '09:00',
|
||||||
startTime: '09:00',
|
endTime: '10:00'
|
||||||
endTime: '10:00'
|
},
|
||||||
},
|
serviceLocation: {
|
||||||
serviceLocation: {
|
appointmentType: 'Mobile'
|
||||||
appointmentType: 'Mobile'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(testStore);
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentTimeFormatted;
|
const testValue = wrapper.vm.appointmentTimeFormatted;
|
||||||
|
|
@ -225,19 +285,26 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('appointmentTimeFormatted should return Drop Off time in expected format', () => {
|
test('appointmentTimeFormatted should return Drop Off time in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testSessionStorage = {
|
||||||
order: {
|
schedule: {
|
||||||
schedule: {
|
date: '2019-01-01',
|
||||||
date: '2019-01-01',
|
startTime: '09:00',
|
||||||
startTime: '09:00',
|
endTime: '10:00'
|
||||||
endTime: '10:00'
|
},
|
||||||
},
|
serviceLocation: {
|
||||||
serviceLocation: {
|
appointmentType: 'Dropoff',
|
||||||
appointmentType: 'Dropoff'
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(testStore);
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentTimeFormatted;
|
const testValue = wrapper.vm.appointmentTimeFormatted;
|
||||||
|
|
@ -247,6 +314,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('appointmentTimeFormatted should return In Shop time in expected format', () => {
|
test('appointmentTimeFormatted should return In Shop time in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(sessionStorage));
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -257,111 +325,162 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('appointmentWordingText should return Mobile text in expected format', () => {
|
test('appointmentWordingText should return Mobile text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testSessionStorage = {
|
||||||
order: {
|
schedule: {
|
||||||
schedule: {
|
date: '2019-01-01',
|
||||||
date: '2019-01-01',
|
startTime: '09:00',
|
||||||
startTime: '09:00',
|
endTime: '10:00'
|
||||||
endTime: '10:00'
|
},
|
||||||
},
|
serviceLocation: {
|
||||||
serviceLocation: {
|
address: '123 Test Way',
|
||||||
address: '123 Test Way',
|
address2: '#1',
|
||||||
address2: '#1',
|
city: 'Mesa',
|
||||||
city: 'Mesa',
|
state: 'AZ',
|
||||||
state: 'AZ',
|
zipCode: '12345',
|
||||||
zipCode: '12345',
|
appointmentType: 'Mobile'
|
||||||
appointmentType: 'Mobile'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(testStore);
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentWordingText;
|
const testValue = wrapper.vm.appointmentWordingText;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('wording Text <br/>123 Test Way, #1,<br/> Mesa, AZ 12345<br/>');
|
expect(testValue).toEqual('wording text 123 Test Way, #1,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('appointmentWordingText should return Drop Off text in expected format', () => {
|
test('appointmentWordingText should return Drop Off text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testSessionStorage = {
|
||||||
order: {
|
schedule: {
|
||||||
schedule: {
|
date: '2019-01-01',
|
||||||
date: '2019-01-01',
|
startTime: '09:00',
|
||||||
startTime: '09:00',
|
endTime: '10:00'
|
||||||
endTime: '10:00'
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
appointmentType: 'Dropoff'
|
||||||
provider: {
|
|
||||||
address: {
|
|
||||||
streetAddress: '123 Safelite Street',
|
|
||||||
city: 'Mesa',
|
|
||||||
state: 'AZ',
|
|
||||||
zipCode: '12345'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
appointmentType: 'Dropoff'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(testStore);
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentWordingText;
|
const testValue = wrapper.vm.appointmentWordingText;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('wording Text <br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
|
expect(testValue).toEqual('wording text 123 Safelite Street,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('appointmentWordingText should return In Shop text in expected format', () => {
|
test('appointmentWordingText should return In Shop text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const testSessionStorage = {
|
||||||
|
schedule: {
|
||||||
|
date: '2019-01-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00'
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appointmentType: 'Inshop'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentWordingText;
|
const testValue = wrapper.vm.appointmentWordingText;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('wording Text <br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
|
expect(testValue).toEqual('wording text 123 Safelite Street,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('serviceLocationFullAddress should return text in expected format', () => {
|
test('serviceLocationFullAddress should return text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const testSessionStorage = {
|
||||||
|
schedule: {
|
||||||
|
date: '2019-01-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00'
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
address: '123 Test Way',
|
||||||
|
address2: '#1',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345',
|
||||||
|
appointmentType: 'Mobile'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.serviceLocationFullAddress;
|
const testValue = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('<br/>123 Test Way, #1,<br/> Mesa, AZ 12345<br/>');
|
expect(testValue).toEqual('123 Test Way, #1,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('providerFullAddress should return text in expected format', () => {
|
test('providerFullAddress should return text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const testSessionStorage = {
|
||||||
|
schedule: {
|
||||||
|
date: '2019-01-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00'
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appointmentType: 'Inshop'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.providerFullAddress;
|
const testValue = wrapper.vm.providerFullAddress;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('<br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
|
expect(testValue).toEqual('123 Safelite Street,<br/> Mesa, AZ 12345');
|
||||||
});
|
});
|
||||||
test('appointmentWordingText2 should return Mobile text in expected format', () => {
|
test('appointmentWordingText2 should return Mobile text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testSessionStorage = {
|
||||||
order: {
|
schedule: {
|
||||||
schedule: {
|
date: '2019-01-01',
|
||||||
date: '2019-01-01',
|
startTime: '09:00',
|
||||||
startTime: '09:00',
|
endTime: '10:00'
|
||||||
endTime: '10:00'
|
},
|
||||||
},
|
serviceLocation: {
|
||||||
serviceLocation: {
|
address: '123 Test Way',
|
||||||
address: '123 Test Way',
|
address2: '#1',
|
||||||
address2: '#1',
|
city: 'Mesa',
|
||||||
city: 'Mesa',
|
state: 'AZ',
|
||||||
state: 'AZ',
|
zipCode: '12345',
|
||||||
zipCode: '12345',
|
appointmentType: 'Mobile'
|
||||||
appointmentType: 'Mobile'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(testStore);
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentWordingText2;
|
const testValue = wrapper.vm.appointmentWordingText2;
|
||||||
|
|
@ -371,27 +490,26 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('appointmentWordingText2 should return Drop Off and text in expected format', () => {
|
test('appointmentWordingText2 should return Drop Off and text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testSessionStorage = {
|
||||||
order: {
|
schedule: {
|
||||||
schedule: {
|
date: '2019-01-01',
|
||||||
date: '2019-01-01',
|
startTime: '09:00',
|
||||||
startTime: '09:00',
|
endTime: '10:00'
|
||||||
endTime: '10:00'
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
appointmentType: 'Dropoff'
|
||||||
provider: {
|
|
||||||
address: {
|
|
||||||
streetAddress: '123 Safelite Street',
|
|
||||||
city: 'Mesa',
|
|
||||||
state: 'AZ',
|
|
||||||
zipCode: '12345'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
appointmentType: 'Dropoff'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(testStore);
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentWordingText2;
|
const testValue = wrapper.vm.appointmentWordingText2;
|
||||||
|
|
@ -402,7 +520,26 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
test('appointmentWordingText2 should return In Shop text in expected format', () => {
|
test('appointmentWordingText2 should return In Shop text in expected format', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getMountedComponent(initialStore);
|
const testSessionStorage = {
|
||||||
|
schedule: {
|
||||||
|
date: '2019-01-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00'
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appointmentType: 'Inshop'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.sessionStorage.setItem('submittedOrder', JSON.stringify(testSessionStorage));
|
||||||
|
const { wrapper } = getMountedComponent();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.appointmentWordingText2;
|
const testValue = wrapper.vm.appointmentWordingText2;
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ export default {
|
||||||
},
|
},
|
||||||
providerFullAddress() {
|
providerFullAddress() {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
return `<br/>${this.providerAddress},<br/> ${this.providerCity}, ${this.providerState} ${this.providerZipCode}<br/>`;
|
return `${this.providerAddress},<br/> ${this.providerCity}, ${this.providerState} ${this.providerZipCode}`;
|
||||||
},
|
},
|
||||||
appointmentWordingText() {
|
appointmentWordingText() {
|
||||||
switch (this.appointmentType) {
|
switch (this.appointmentType) {
|
||||||
|
|
|
||||||
|
|
@ -264,44 +264,6 @@ describe('payment-page.vue', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('beforeRouteEnter', () => {
|
|
||||||
test('Properly initializes fields and kicks off hop', async () => {
|
|
||||||
// Arrange
|
|
||||||
const vmMock = {
|
|
||||||
setCmsContent: jest.fn(),
|
|
||||||
$refs: {
|
|
||||||
cart: {
|
|
||||||
cartItems: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getPiaLineItems: jest.fn(),
|
|
||||||
fetchSignatureInfo: jest.fn(),
|
|
||||||
setIFrameListener: jest.fn(),
|
|
||||||
|
|
||||||
$nextTick: (f) => {
|
|
||||||
f();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const nextF = (f) => {
|
|
||||||
f(vmMock);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await payment.beforeRouteEnter.call(
|
|
||||||
vmMock,
|
|
||||||
{ query: { issPage: 'payment-page' } },
|
|
||||||
undefined,
|
|
||||||
nextF
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(vmMock.setCmsContent).toBeCalled();
|
|
||||||
expect(vmMock.fetchSignatureInfo).toBeCalled();
|
|
||||||
expect(vmMock.setIFrameListener).toBeCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('payment type mapping', () => {
|
describe('payment type mapping', () => {
|
||||||
describe('getPaymentType', () => {
|
describe('getPaymentType', () => {
|
||||||
test('Maps AFTERPAY -> hopPaymentMethods.AFTERPAY', () => {
|
test('Maps AFTERPAY -> hopPaymentMethods.AFTERPAY', () => {
|
||||||
|
|
|
||||||
|
|
@ -637,13 +637,7 @@ export default {
|
||||||
},
|
},
|
||||||
getPayInAdvanceLineItems(cartItems) {
|
getPayInAdvanceLineItems(cartItems) {
|
||||||
const { glassParts } = useMainStore().order.lineItems;
|
const { glassParts } = useMainStore().order.lineItems;
|
||||||
let lineItems = [];
|
const lineItems = (glassParts === null) ? ['Labor|0|1', 'Repair supplies|0|1'] : ['Parts and labor|0|1'];
|
||||||
|
|
||||||
if (glassParts === null) {
|
|
||||||
lineItems = ['Labor|0|1', 'Repair supplies|0|1'];
|
|
||||||
} else {
|
|
||||||
lineItems = ['Parts and labor|0|1'];
|
|
||||||
}
|
|
||||||
|
|
||||||
cartItems.forEach((item) => {
|
cartItems.forEach((item) => {
|
||||||
if (item.name !== null && item.category !== 'promos') {
|
if (item.name !== null && item.category !== 'promos') {
|
||||||
|
|
@ -695,8 +689,7 @@ export default {
|
||||||
handleIFrameContentWindowMessage(event) {
|
handleIFrameContentWindowMessage(event) {
|
||||||
if (typeof event.data === 'string') {
|
if (typeof event.data === 'string') {
|
||||||
if (event.data.indexOf('afterpayClosed') > -1) {
|
if (event.data.indexOf('afterpayClosed') > -1) {
|
||||||
console.log('trigger back button...');
|
this.backButtonAction();
|
||||||
// this.backButtonAction();
|
|
||||||
}
|
}
|
||||||
if (event.data.indexOf('creditCardSubmit') > -1) {
|
if (event.data.indexOf('creditCardSubmit') > -1) {
|
||||||
this.setUIBlock(true);
|
this.setUIBlock(true);
|
||||||
|
|
|
||||||
|
|
@ -138,12 +138,12 @@ router.beforeEach(async (to, from) => {
|
||||||
const notToPayInAdvanceReturn = toQueryPage !== issPageValues.PAYMENT_RETURN;
|
const notToPayInAdvanceReturn = toQueryPage !== issPageValues.PAYMENT_RETURN;
|
||||||
const isInIframe = fromQueryPage === issPageValues.PAYMENT_PAGE;
|
const isInIframe = fromQueryPage === issPageValues.PAYMENT_PAGE;
|
||||||
|
|
||||||
// fromPaymentToConfirmation workaround for navigating from an iframe but
|
// isFromPaymentPageToOrderConfirmation workaround for navigating from an iframe but
|
||||||
// isInIframe evaluates to false for some reason when navigating from payment to confirmation
|
// isInIframe evaluates to false for some reason when navigating from payment to confirmation
|
||||||
const fromPaymentToConfirmation =
|
const isFromPaymentPageToOrderConfirmation =
|
||||||
fromQueryPage === issPageValues.PAYMENT_PAGE && toQueryPage === issPageValues.ORDER_CONFIRMATION;
|
fromQueryPage === issPageValues.PAYMENT_PAGE && toQueryPage === issPageValues.ORDER_CONFIRMATION;
|
||||||
|
|
||||||
if ((isInIframe && notToPayInAdvanceReturn) || fromPaymentToConfirmation) {
|
if ((isInIframe && notToPayInAdvanceReturn) || isFromPaymentPageToOrderConfirmation) {
|
||||||
// need to set window.top.location.href directly when navigating out of an iframe
|
// need to set window.top.location.href directly when navigating out of an iframe
|
||||||
// especially when navigating with browser buttons
|
// especially when navigating with browser buttons
|
||||||
const newUrl = `${window.top.location.origin}${to.href}`;
|
const newUrl = `${window.top.location.origin}${to.href}`;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import applicationConfig from '@/constants/application-config';
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import damageLocationsSelected from '@/constants/damage-locations-selected';
|
import damageLocationsSelected from '@/constants/damage-locations-selected';
|
||||||
import coverageStatuses from '@/constants/coverage-statuses';
|
import coverageStatuses from '@/constants/coverage-statuses';
|
||||||
import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants';
|
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
||||||
import { deepClone } from '@/helpers/object-helper';
|
import { deepClone } from '@/helpers/object-helper';
|
||||||
import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper';
|
import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper';
|
||||||
import { paymentMethods } from '@/constants/payment-method-constants';
|
import { paymentMethods } from '@/constants/payment-method-constants';
|
||||||
|
|
@ -902,10 +902,8 @@ export const useMainStore = defineStore({
|
||||||
},
|
},
|
||||||
async getWipers() {
|
async getWipers() {
|
||||||
const { carId } = this.order.vehicle;
|
const { carId } = this.order.vehicle;
|
||||||
// WARNING
|
|
||||||
// TODO: this is temp test code until serviceLocation is complete.
|
|
||||||
const serviceZipCode = this.order.serviceLocation.zipCode;
|
const serviceZipCode = this.order.serviceLocation.zipCode;
|
||||||
// const serviceZipCode = '44902';
|
|
||||||
return globalMethods
|
return globalMethods
|
||||||
.callHttpClient({
|
.callHttpClient({
|
||||||
method: endpoints.GetWipers.method,
|
method: endpoints.GetWipers.method,
|
||||||
|
|
@ -1287,20 +1285,17 @@ export const useMainStore = defineStore({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadSession() {
|
async loadSession(duplicate) {
|
||||||
const { applicationUser, order, issConfig } = this;
|
const { applicationUser, order, issConfig } = this;
|
||||||
// TODO how to get savedSessionId for a duplicate referral?
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await globalMethods.callHttpClient({
|
const response = await globalMethods.callHttpClient({
|
||||||
method: endpoints.LoadSession.method,
|
method: endpoints.LoadSession.method,
|
||||||
endpoint: endpoints.LoadSession.url,
|
endpoint: endpoints.LoadSession.url,
|
||||||
payload: {
|
payload: {
|
||||||
savedSessionId: applicationUser.savedSessionId?.toString(),
|
referralNumber: duplicate.referralNumber,
|
||||||
referralNumber: order.referralNumber?.toString(),
|
referralDate: duplicate.responseDate,
|
||||||
referralDate: order.referralDate?.toString(),
|
|
||||||
parentAccountNumber: issConfig.parentAccountNumber,
|
parentAccountNumber: issConfig.parentAccountNumber,
|
||||||
referralCorrelationId: order.referralCorrelationId
|
referralCorrelationId: duplicate.referralCorrelationId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { data } = response;
|
const { data } = response;
|
||||||
|
|
@ -1309,10 +1304,6 @@ export const useMainStore = defineStore({
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId;
|
|
||||||
applicationUser.experiments = data.applicationUser?.experiments ?? [];
|
|
||||||
applicationUser.savedSessionId = data.applicationUser?.savedSessionId;
|
|
||||||
|
|
||||||
if (order.policy.policyLookupSuccessful) {
|
if (order.policy.policyLookupSuccessful) {
|
||||||
order.customer.emailAddress = data.customer?.emailAddress;
|
order.customer.emailAddress = data.customer?.emailAddress;
|
||||||
order.customer.firstName = data.customer?.firstName;
|
order.customer.firstName = data.customer?.firstName;
|
||||||
|
|
|
||||||
|
|
@ -961,10 +961,7 @@ describe('Store', () => {
|
||||||
describe('loadSession method', () => {
|
describe('loadSession method', () => {
|
||||||
describe('successful method call', () => {
|
describe('successful method call', () => {
|
||||||
const applicationUser = {
|
const applicationUser = {
|
||||||
crmCustomerId: getRandomString(6, 6),
|
experiments: getRandomString(6, 6)
|
||||||
experiments: getRandomString(6, 6),
|
|
||||||
pageData: getRandomString(6, 6),
|
|
||||||
savedSessionId: getRandomString(6, 6)
|
|
||||||
};
|
};
|
||||||
const vehicle = {
|
const vehicle = {
|
||||||
year: getRandomString(6, 6),
|
year: getRandomString(6, 6),
|
||||||
|
|
@ -1006,9 +1003,13 @@ describe('Store', () => {
|
||||||
it('calls load session api endpoint', async () => {
|
it('calls load session api endpoint', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({ data: {} }));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({ data: {} }));
|
||||||
|
const duplicate = {
|
||||||
|
referralNumber: getRandomString(6, 6),
|
||||||
|
referralCorrelationId: getRandomGuid()
|
||||||
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
store.loadSession();
|
store.loadSession(duplicate);
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
|
|
@ -1020,34 +1021,31 @@ describe('Store', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const response = { data: { ReferralNumber: getRandomString(6, 6) } };
|
const response = { data: { ReferralNumber: getRandomString(6, 6) } };
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||||
|
const duplicate = {
|
||||||
|
referralNumber: getRandomString(6, 6),
|
||||||
|
referralCorrelationId: getRandomGuid()
|
||||||
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = store.loadSession();
|
const result = store.loadSession(duplicate);
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
await expect(result).resolves.toBe(response.data);
|
await expect(result).resolves.toBe(response.data);
|
||||||
});
|
});
|
||||||
it('sets expected application user data', async () => {
|
|
||||||
// Arrange
|
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await store.loadSession();
|
|
||||||
|
|
||||||
// Asserts
|
|
||||||
expect(store.applicationUser.experiments).toEqual(applicationUser.experiments);
|
|
||||||
expect(store.applicationUser.savedSessionId).toBe(applicationUser.savedSessionId);
|
|
||||||
expect(store.applicationUser.crmCustomerId).toBe(applicationUser.crmCustomerId);
|
|
||||||
});
|
|
||||||
it('sets expected vehicle data', async () => {
|
it('sets expected vehicle data', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
||||||
|
|
||||||
|
const duplicate = {
|
||||||
|
referralNumber: getRandomString(6, 6),
|
||||||
|
referralCorrelationId: getRandomGuid()
|
||||||
|
};
|
||||||
|
|
||||||
store.order.policy.policyLookupSuccessful = true;
|
store.order.policy.policyLookupSuccessful = true;
|
||||||
store.policy.vehicles = [{ vin: vehicle.vin }];
|
store.policy.vehicles = [{ vin: vehicle.vin }];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await store.loadSession();
|
await store.loadSession(duplicate);
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(store.vehicle.year).toBe(vehicle.year);
|
expect(store.vehicle.year).toBe(vehicle.year);
|
||||||
|
|
@ -1061,11 +1059,16 @@ describe('Store', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
||||||
|
|
||||||
|
const duplicate = {
|
||||||
|
referralNumber: getRandomString(6, 6),
|
||||||
|
referralCorrelationId: getRandomGuid()
|
||||||
|
};
|
||||||
|
|
||||||
store.order.policy.policyLookupSuccessful = true;
|
store.order.policy.policyLookupSuccessful = true;
|
||||||
store.policy.vehicles = [{ vin: vehicle.vin }];
|
store.policy.vehicles = [{ vin: vehicle.vin }];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await store.loadSession();
|
await store.loadSession(duplicate);
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(store.order.customer.address.streetAddress).toBe(customer.address.streetAddress);
|
expect(store.order.customer.address.streetAddress).toBe(customer.address.streetAddress);
|
||||||
|
|
@ -1081,10 +1084,14 @@ describe('Store', () => {
|
||||||
it('sets expected remaining order data', async () => {
|
it('sets expected remaining order data', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(fullApiResponse));
|
||||||
const originalWorkOrderNumber = store.order.workOrderNumber;
|
|
||||||
|
const duplicate = {
|
||||||
|
referralNumber: getRandomString(6, 6),
|
||||||
|
referralCorrelationId: getRandomGuid()
|
||||||
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await store.loadSession();
|
await store.loadSession(duplicate);
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(store.order.referralNumber).toBe(fullApiResponse.data.referralNumber);
|
expect(store.order.referralNumber).toBe(fullApiResponse.data.referralNumber);
|
||||||
|
|
@ -1092,7 +1099,6 @@ describe('Store', () => {
|
||||||
expect(store.order.referralCorrelationId).toBe(fullApiResponse.data.referralCorrelationId);
|
expect(store.order.referralCorrelationId).toBe(fullApiResponse.data.referralCorrelationId);
|
||||||
expect(store.order.referralSequenceNumber).toBe(fullApiResponse.data.referralSequenceNumber);
|
expect(store.order.referralSequenceNumber).toBe(fullApiResponse.data.referralSequenceNumber);
|
||||||
expect(store.order.eon).toBe(fullApiResponse.data.eon);
|
expect(store.order.eon).toBe(fullApiResponse.data.eon);
|
||||||
expect(store.order.workOrderNumber).toBe(originalWorkOrderNumber);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('api call throws exception', async () => {
|
it('api call throws exception', async () => {
|
||||||
|
|
@ -1100,8 +1106,13 @@ describe('Store', () => {
|
||||||
const error = 'load session error';
|
const error = 'load session error';
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
|
||||||
|
|
||||||
|
const duplicate = {
|
||||||
|
referralNumber: getRandomString(6, 6),
|
||||||
|
referralCorrelationId: getRandomGuid()
|
||||||
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await store.loadSession().catch((e) => {
|
await store.loadSession(duplicate).catch((e) => {
|
||||||
expect(e).toEqual(error);
|
expect(e).toEqual(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue