Merge pull request #449 from Safelite/feature/richardson/SSR-518-bb
Feature/richardson/ssr 518 bb
This commit is contained in:
commit
860620240a
2 changed files with 56 additions and 32 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import coverageStatement from '@/layouts/coverage-statement/coverage-statement.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { nextTick } from 'vue';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
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 { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import routerParams from '@/router/router-constants/router-params';
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
|
||||
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({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
|
|
@ -56,11 +58,15 @@ function getMountedComponent(mainInitialState = {}, initialData = {}) {
|
|||
alert: true,
|
||||
loadingModal: loadingModalStub
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
const testingPinia = createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
});
|
||||
useMainStore(testingPinia);
|
||||
methodToRun();
|
||||
|
||||
mountOptions.global.plugins = [testingPinia];
|
||||
mountOptions.mixins = [mockMixin];
|
||||
mountOptions.data = () => (
|
||||
initialData
|
||||
|
|
@ -462,7 +468,8 @@ describe('coverageStatement.vue', () => {
|
|||
navigationScenarios.CLICKED_FORWARD,
|
||||
undefined,
|
||||
{},
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
});
|
||||
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||
// Arrange
|
||||
|
|
@ -502,7 +509,8 @@ describe('coverageStatement.vue', () => {
|
|||
navigationScenarios.CLICKED_FORWARD,
|
||||
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', () => {
|
||||
// Arrange
|
||||
|
|
@ -543,7 +551,8 @@ describe('coverageStatement.vue', () => {
|
|||
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||
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', () => {
|
||||
// Arrange
|
||||
|
|
@ -587,7 +596,8 @@ describe('coverageStatement.vue', () => {
|
|||
navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED,
|
||||
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', () => {
|
||||
// Arrange
|
||||
|
|
@ -631,7 +641,8 @@ describe('coverageStatement.vue', () => {
|
|||
navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
|
||||
undefined,
|
||||
{},
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
});
|
||||
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||
// Arrange
|
||||
|
|
@ -661,7 +672,8 @@ describe('coverageStatement.vue', () => {
|
|||
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
|
||||
undefined,
|
||||
{},
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true });
|
||||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('ADAS', () => {
|
||||
|
|
@ -735,7 +747,7 @@ describe('coverageStatement.vue', () => {
|
|||
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
|
||||
const sellingPrice = getRandomInt(50, 100);
|
||||
const deductible = sellingPrice - 1;
|
||||
|
|
@ -756,17 +768,27 @@ describe('coverageStatement.vue', () => {
|
|||
isClaimRegistrationRequired: true
|
||||
}
|
||||
};
|
||||
const initialData = {
|
||||
availableLineItems: [
|
||||
const mockStoreActions = () => {
|
||||
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,
|
||||
kitPrice: 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
|
||||
expect(wrapper.vm.mainStore.registerClaim).toHaveBeenCalled();
|
||||
|
|
|
|||
|
|
@ -137,10 +137,10 @@ export default {
|
|||
},
|
||||
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||
const wipersPromise = useMainStore().getWipers();
|
||||
const rainDefensePromise = useMainStore().getRainDefense();
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
||||
const wipersPromise = await useMainStore().getWipers();
|
||||
const rainDefensePromise = await useMainStore().getRainDefense();
|
||||
const supportingItemsPromise = await useMainStore().getSupportingItems();
|
||||
|
||||
// Settle promises and get results
|
||||
|
|
@ -169,9 +169,9 @@ export default {
|
|||
: [];
|
||||
const availableLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...resultMap.supportingItems,
|
||||
...resultMap.wipers,
|
||||
...clonedGlassParts
|
||||
...(resultMap.supportingItems ?? []),
|
||||
...(resultMap.wipers ?? []),
|
||||
...(clonedGlassParts ?? [])
|
||||
];
|
||||
|
||||
const pricingResults = await useMainStore().getPriceOrderItems(availableLineItems);
|
||||
|
|
@ -182,6 +182,8 @@ export default {
|
|||
vm.setSupportingItems(resultMap.supportingItems);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.$refs.loadingModal.showModal();
|
||||
vm.initializeComponent(availableLineItems);
|
||||
});
|
||||
},
|
||||
setup() {
|
||||
|
|
@ -330,26 +332,26 @@ export default {
|
|||
}
|
||||
},
|
||||
nextStepsBody(newValue, oldValue) {
|
||||
if (newValue !== oldValue){
|
||||
setupModalLink(this, "RecalModal");
|
||||
if (newValue !== oldValue) {
|
||||
setupModalLink(this, 'RecalModal');
|
||||
}
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.$refs.loadingModal.showModal();
|
||||
mounted() {
|
||||
setupModalLinks(this);
|
||||
const vm = this;
|
||||
if (this.policyLookupSuccessful
|
||||
&& useMainStore().isClaimRegistrationRequired
|
||||
&& this.coveredAndServicePriceAboveOrEqualDeductible) {
|
||||
await useMainStore().registerClaim()?.catch(() => {});
|
||||
}
|
||||
vm.$refs.loadingModal.hideModal();
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
return !!useMainStore().vehicle.vin;
|
||||
},
|
||||
async initializeComponent() {
|
||||
if (this.policyLookupSuccessful
|
||||
&& useMainStore().isClaimRegistrationRequired
|
||||
&& this.coveredAndServicePriceAboveOrEqualDeductible) {
|
||||
await useMainStore().registerClaim()?.catch(() => {});
|
||||
}
|
||||
this.$refs.loadingModal.hideModal();
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
return this.navigateForward();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue