Merge branch 'develop' into feature/SSR-705
This commit is contained in:
commit
630590c3ce
2 changed files with 56 additions and 32 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
import coverageStatement from '@/layouts/coverage-statement/coverage-statement.vue';
|
import coverageStatement from '@/layouts/coverage-statement/coverage-statement.vue';
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
|
import { nextTick } from 'vue';
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
|
|
@ -10,6 +11,7 @@ import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
|
||||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
import routerParams from '@/router/router-constants/router-params';
|
||||||
|
import { useMainStore } from '@/store/index.js';
|
||||||
|
|
||||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
||||||
|
|
@ -41,7 +43,7 @@ const loadingModalStub = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getMountedComponent(mainInitialState = {}, initialData = {}) {
|
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn()
|
||||||
|
|
@ -56,11 +58,15 @@ function getMountedComponent(mainInitialState = {}, initialData = {}) {
|
||||||
alert: true,
|
alert: true,
|
||||||
loadingModal: loadingModalStub
|
loadingModal: loadingModalStub
|
||||||
};
|
};
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
const testingPinia = createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
main: mainInitialState
|
main: mainInitialState
|
||||||
}
|
}
|
||||||
})];
|
});
|
||||||
|
useMainStore(testingPinia);
|
||||||
|
methodToRun();
|
||||||
|
|
||||||
|
mountOptions.global.plugins = [testingPinia];
|
||||||
mountOptions.mixins = [mockMixin];
|
mountOptions.mixins = [mockMixin];
|
||||||
mountOptions.data = () => (
|
mountOptions.data = () => (
|
||||||
initialData
|
initialData
|
||||||
|
|
@ -462,7 +468,8 @@ describe('coverageStatement.vue', () => {
|
||||||
navigationScenarios.CLICKED_FORWARD,
|
navigationScenarios.CLICKED_FORWARD,
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -502,7 +509,8 @@ describe('coverageStatement.vue', () => {
|
||||||
navigationScenarios.CLICKED_FORWARD,
|
navigationScenarios.CLICKED_FORWARD,
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -543,7 +551,8 @@ describe('coverageStatement.vue', () => {
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_ENABLED', () => {
|
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_ENABLED', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -587,7 +596,8 @@ describe('coverageStatement.vue', () => {
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
|
navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
test('If Verified ITAC, selected other shop, and TPA disabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_DISABLED', () => {
|
test('If Verified ITAC, selected other shop, and TPA disabled, navigate forward w/ CLICKED_FORWARD_WITH_TPA_DISABLED', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -631,7 +641,8 @@ describe('coverageStatement.vue', () => {
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
|
navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD scenario', () => {
|
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -661,7 +672,8 @@ describe('coverageStatement.vue', () => {
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('ADAS', () => {
|
describe('ADAS', () => {
|
||||||
|
|
@ -735,7 +747,7 @@ describe('coverageStatement.vue', () => {
|
||||||
expect(wrapper.vm.mainStore.registerClaim).not.toHaveBeenCalled();
|
expect(wrapper.vm.mainStore.registerClaim).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('claim registration required => register claim method called', async () => {
|
it.only('claim registration required => register claim method called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const sellingPrice = getRandomInt(50, 100);
|
const sellingPrice = getRandomInt(50, 100);
|
||||||
const deductible = sellingPrice - 1;
|
const deductible = sellingPrice - 1;
|
||||||
|
|
@ -756,17 +768,27 @@ describe('coverageStatement.vue', () => {
|
||||||
isClaimRegistrationRequired: true
|
isClaimRegistrationRequired: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const initialData = {
|
const mockStoreActions = () => {
|
||||||
availableLineItems: [
|
useMainStore().getWipers = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getRainDefense = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getSupportingItems = jest.fn().mockImplementation(() => Promise.resolve());
|
||||||
|
useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve([
|
||||||
{
|
{
|
||||||
sellingPrice,
|
sellingPrice,
|
||||||
kitPrice: 0,
|
kitPrice: 0,
|
||||||
laborAmount: 0
|
laborAmount: 0
|
||||||
}
|
}
|
||||||
]
|
]));
|
||||||
};
|
};
|
||||||
|
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
||||||
|
const next = (method) => { method(wrapper.vm); };
|
||||||
|
|
||||||
const { wrapper } = getMountedComponent(initialStore, initialData);
|
// Act
|
||||||
|
coverageStatement.beforeRouteEnter.call(wrapper.vm, undefined, undefined, next);
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await nextTick();
|
||||||
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalled();
|
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalled();
|
||||||
|
|
|
||||||
|
|
@ -137,10 +137,10 @@ export default {
|
||||||
},
|
},
|
||||||
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
||||||
const wipersPromise = useMainStore().getWipers();
|
const wipersPromise = await useMainStore().getWipers();
|
||||||
const rainDefensePromise = useMainStore().getRainDefense();
|
const rainDefensePromise = await useMainStore().getRainDefense();
|
||||||
const supportingItemsPromise = await useMainStore().getSupportingItems();
|
const supportingItemsPromise = await useMainStore().getSupportingItems();
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
|
|
@ -169,9 +169,9 @@ export default {
|
||||||
: [];
|
: [];
|
||||||
const availableLineItems = [
|
const availableLineItems = [
|
||||||
resultMap.rainDefense,
|
resultMap.rainDefense,
|
||||||
...resultMap.supportingItems,
|
...(resultMap.supportingItems ?? []),
|
||||||
...resultMap.wipers,
|
...(resultMap.wipers ?? []),
|
||||||
...clonedGlassParts
|
...(clonedGlassParts ?? [])
|
||||||
];
|
];
|
||||||
|
|
||||||
const pricingResults = await useMainStore().getPriceOrderItems(availableLineItems);
|
const pricingResults = await useMainStore().getPriceOrderItems(availableLineItems);
|
||||||
|
|
@ -182,6 +182,8 @@ export default {
|
||||||
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.availableLineItems = pricingResults;
|
||||||
|
vm.$refs.loadingModal.showModal();
|
||||||
|
vm.initializeComponent(availableLineItems);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
@ -330,26 +332,26 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
nextStepsBody(newValue, oldValue) {
|
nextStepsBody(newValue, oldValue) {
|
||||||
if (newValue !== oldValue){
|
if (newValue !== oldValue) {
|
||||||
setupModalLink(this, "RecalModal");
|
setupModalLink(this, 'RecalModal');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
mounted() {
|
||||||
this.$refs.loadingModal.showModal();
|
|
||||||
setupModalLinks(this);
|
setupModalLinks(this);
|
||||||
const vm = this;
|
|
||||||
if (this.policyLookupSuccessful
|
|
||||||
&& useMainStore().isClaimRegistrationRequired
|
|
||||||
&& this.coveredAndServicePriceAboveOrEqualDeductible) {
|
|
||||||
await useMainStore().registerClaim()?.catch(() => {});
|
|
||||||
}
|
|
||||||
vm.$refs.loadingModal.hideModal();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return !!useMainStore().vehicle.vin;
|
return !!useMainStore().vehicle.vin;
|
||||||
},
|
},
|
||||||
|
async initializeComponent() {
|
||||||
|
if (this.policyLookupSuccessful
|
||||||
|
&& useMainStore().isClaimRegistrationRequired
|
||||||
|
&& this.coveredAndServicePriceAboveOrEqualDeductible) {
|
||||||
|
await useMainStore().registerClaim()?.catch(() => {});
|
||||||
|
}
|
||||||
|
this.$refs.loadingModal.hideModal();
|
||||||
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
return this.navigateForward();
|
return this.navigateForward();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue