Adding test cases

This commit is contained in:
Michaela Brydon 2024-03-06 10:15:08 -05:00
parent 76c35865e4
commit 7757bc6cfd
2 changed files with 81 additions and 46 deletions

View file

@ -830,19 +830,62 @@ describe('coverageStatement.vue-working', () => {
}); });
}); });
describe('Computed', () => { describe('Computed', () => {
describe('formattedDeductible', () => {}); describe.only('verifiedNoComp', () => {
describe('verifiedNoComp', () => {}); test.each([true, false])('returns false when policyLookupSuccessful false', (isNoComp) => {
describe('verifiedITAC', () => {});
describe('verifiedDeductible', () => {}); });
test.each([true, false])('returns false when isNoComp false', (policyLookupSuccessful) => {});
test('returns true when policyLookupSuccessful true and policyLookupSuccessful true', () => {
});
});
describe('verifiedITAC', () => {
test('returns false when policyLookupSuccessful false', () => {});
test('returns false when isNoComp true', () => {});
test('returns false when deductibleValue equals totalServicePrice', () => {});
test('returns false when deductibleValue less than totalServicePrice', () => {});
});
describe('verifiedDeductible', () => {
test('', () => { });
test('', () => { });
test('', () => { });
test('', () => { });
test('', () => { });
test('', () => { });
test('', () => { });
});
describe('unverified', () => {}); describe('unverified', () => {});
describe('isADAS', () => {}); describe('isADAS', () => {});
describe('servicePriceForDisplay', () => {});
describe('itacCostSavings', () => {}); describe('itacCostSavings', () => {});
describe('itacCostSavingsForDisplay', () => {});
describe('isQuoteDisplayed', () => {}); describe('isQuoteDisplayed', () => {});
describe('shouldRegisterClaim', () => {});
}); });
describe('watchers', () => { describe('methods', () => {
describe('arePagePrerequisitesValid', () => {
});
test.each([
[0, '$0.00'],
[1, '$1.00'],
[12, '$12.00'],
[1.2, '$1.20'],
[1.25, '$1.25'],
[1.254, '$1.25'],
[1.255, '$1.26'],
[-1, '-$1.00']
])('getFormattedAmount', (value, expected) => {
// Arrange
const { wrapper } = getMountedComponent();
// Act
const result = wrapper.vm.getFormattedAmount(value);
// Assert
expect(result).toBe(expected);
});
describe('navigateForward', () => {
});
}); });
describe('ITAC flag', () => { describe('ITAC flag', () => {
test('ITAC flag updated once component is initialized', async () => { test('ITAC flag updated once component is initialized', async () => {

View file

@ -35,7 +35,7 @@
<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="isQuoteDisplayed" v-if="isQuoteDisplayed"
@ -46,7 +46,7 @@
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 }}&nbsp; {{ deductibleText }}&nbsp;
<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"
@ -134,6 +134,10 @@ import getPriceOfLineItems from '@/helpers/price-calculator.js';
const SAFELITE_PROVIDER = 'Safelite'; const SAFELITE_PROVIDER = 'Safelite';
function setBailout(currentRoute, message) {
useMainStore().setBailout(currentRoute, message);
}
export default { export default {
name: 'coverage-statement', name: 'coverage-statement',
components: { components: {
@ -181,14 +185,10 @@ export default {
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(
.setBailout( availableLineItems.map((li) => li.partNumber),
to, { code: err.code, message: err.message, data: err.data }
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}`);
}); });
@ -292,7 +292,7 @@ export default {
deductibleValue() { deductibleValue() {
return useMainStore().order.currentDeductible; return useMainStore().order.currentDeductible;
}, },
formattedDeductible() { deductibleForDisplay() {
return this.getFormattedAmount(this.deductibleValue); return this.getFormattedAmount(this.deductibleValue);
}, },
registerClaimSuccessful() { registerClaimSuccessful() {
@ -347,6 +347,13 @@ export default {
}, },
isQuoteDisplayed() { isQuoteDisplayed() {
return this.verifiedITAC || this.verifiedNoComp; return this.verifiedITAC || this.verifiedNoComp;
},
shouldRegisterClaim() {
return this.policyLookupSuccessful
&& useMainStore().vehicle.policyVehicleId >= 0
&& useMainStore().isClaimRegistrationRequired
&& !useMainStore().isClaimAlreadyRegistered
&& (this.coveredAndServicePriceAboveOrEqualDeductible || this.verifiedITAC);
} }
}, },
watch: { watch: {
@ -373,11 +380,7 @@ export default {
}, },
async initializeComponent() { async initializeComponent() {
useMainStore().updatePolicyITACFlag(this.verifiedITAC); useMainStore().updatePolicyITACFlag(this.verifiedITAC);
if (this.policyLookupSuccessful if (this.shouldRegisterClaim) {
&& useMainStore().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();
@ -385,38 +388,27 @@ export default {
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_PROVIDER); useMainStore().updateIsSafeliteProvider(this.selectedProvider === SAFELITE_PROVIDER);
if (this.selectedProvider === SAFELITE_PROVIDER) { 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
);
} else { } else {
useMainStore().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
);
} }
} else { } else {
useMainStore().setBailout( this.setBailoutWithMessage(bailoutMessage.coverageStatementInvalidState());
this.$router.currentRoute, this.navigateWithScenario(navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE);
bailoutMessage.coverageStatementInvalidState()
);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE,
this.$route
);
} }
}, },
setBailoutWithMessage(message) {
setBailout(this.$router.currentRoute, message);
},
navigateWithScenario(scenario) {
this.$router.navigate(scenario, this.$route);
},
getTextFromCmsWithCustomIfStatements(widgetName, widgetField) { getTextFromCmsWithCustomIfStatements(widgetName, widgetField) {
const rawText = this.getCmsContent(widgetName, widgetField); const rawText = this.getCmsContent(widgetName, widgetField);
return processIfStatements(rawText, 'custom', this.getCustomValueFromString); return processIfStatements(rawText, 'custom', this.getCustomValueFromString);