Merge pull request #452 from Safelite/feature/digital/SSR-661
SSR-661 Skip VIN Questions if we already have VIN from policy
This commit is contained in:
commit
ab3d3ec38f
6 changed files with 52 additions and 31 deletions
|
|
@ -84,6 +84,7 @@ import alert from '@/ux-components/alert/alert.vue';
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
||||||
|
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import settleAllPromises from '@/helpers/layout-helper';
|
import settleAllPromises from '@/helpers/layout-helper';
|
||||||
import { Form, defineRule } from 'vee-validate';
|
import { Form, defineRule } from 'vee-validate';
|
||||||
|
|
@ -112,7 +113,7 @@ export default {
|
||||||
Form,
|
Form,
|
||||||
alert
|
alert
|
||||||
},
|
},
|
||||||
mixins: [BaseFormMixin],
|
mixins: [BaseFormMixin, vehicleQuestionsMixin],
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
|
|
||||||
|
|
@ -375,10 +376,6 @@ export default {
|
||||||
this.mainStore.saveSupportingItems(supportingItems.data);
|
this.mainStore.saveSupportingItems(supportingItems.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.navigateForward();
|
|
||||||
},
|
|
||||||
|
|
||||||
navigateForward() {
|
|
||||||
if (this.mainStore.damage.isRepair) {
|
if (this.mainStore.damage.isRepair) {
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
|
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
|
||||||
|
|
@ -386,16 +383,25 @@ export default {
|
||||||
);
|
);
|
||||||
} else if (this.mainStore.order.vehicle.vin) {
|
} else if (this.mainStore.order.vehicle.vin) {
|
||||||
// If vin already exists, navigate directly to vin-lookup
|
// If vin already exists, navigate directly to vin-lookup
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
|
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
||||||
this.$route
|
if (partsOrQuestionsResponse.error) {
|
||||||
);
|
// To Do: Need requirement on what to do here
|
||||||
|
window.console.error('Error on retrieving PartsOrQuestions');
|
||||||
|
this.$refs.siteFooter.removeLoader();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comes from vehicleQuestionsMixin.navigateForward()
|
||||||
|
await this.navigateForward(partsOrQuestionsResponse.data.partsOrQuestions, this);
|
||||||
} else {
|
} else {
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
||||||
this.$route
|
this.$route
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedGlassToReplace() {
|
selectedGlassToReplace() {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import navigationScenarios from '@/router/router-constants/navigation-scenarios'
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
import routerParams from '@/router/router-constants/router-params';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import VinLookupComponent from '@/layouts/vin-lookup/vin-lookup.vue';
|
import VinLookupComponent from '@/layouts/vin-lookup/vin-lookup.vue';
|
||||||
|
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
||||||
|
|
||||||
const continueButtonQuerySelector = '[data-test-id="site-footer-main-button"]';
|
const continueButtonQuerySelector = '[data-test-id="site-footer-main-button"]';
|
||||||
const errorMessageWrapperElSelector = '#vin-question-wrapper .form-test-error';
|
const errorMessageWrapperElSelector = '#vin-question-wrapper .form-test-error';
|
||||||
|
|
@ -287,7 +288,7 @@ describe('vin-lookup.vue', () => {
|
||||||
|
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||||
jest.spyOn(VinLookupComponent.methods, getPartsOrQuestions.methodName)
|
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||||
|
|
||||||
mountOptions.data = () => ({
|
mountOptions.data = () => ({
|
||||||
|
|
@ -323,7 +324,7 @@ describe('vin-lookup.vue', () => {
|
||||||
getPartsOrQuestions.mockResponse = vehicleWithPartQuestionsMockResponse;
|
getPartsOrQuestions.mockResponse = vehicleWithPartQuestionsMockResponse;
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||||
jest.spyOn(VinLookupComponent.methods, getPartsOrQuestions.methodName)
|
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||||
|
|
||||||
const { container } = render(VinLookupComponent, mountOptions);
|
const { container } = render(VinLookupComponent, mountOptions);
|
||||||
|
|
@ -355,7 +356,7 @@ describe('vin-lookup.vue', () => {
|
||||||
getPartsOrQuestions.mockResponse = vehicleWithMultiplePartsMockResponse;
|
getPartsOrQuestions.mockResponse = vehicleWithMultiplePartsMockResponse;
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||||
jest.spyOn(VinLookupComponent.methods, getPartsOrQuestions.methodName)
|
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||||
|
|
||||||
const { container } = render(VinLookupComponent, mountOptions);
|
const { container } = render(VinLookupComponent, mountOptions);
|
||||||
|
|
@ -387,7 +388,7 @@ describe('vin-lookup.vue', () => {
|
||||||
getPartsOrQuestions.mockResponse = vehicleWithMoldingQuestionsMockResponse;
|
getPartsOrQuestions.mockResponse = vehicleWithMoldingQuestionsMockResponse;
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||||
jest.spyOn(VinLookupComponent.methods, getPartsOrQuestions.methodName)
|
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||||
|
|
||||||
const { container } = render(VinLookupComponent, mountOptions);
|
const { container } = render(VinLookupComponent, mountOptions);
|
||||||
|
|
@ -421,7 +422,7 @@ describe('vin-lookup.vue', () => {
|
||||||
|
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||||
jest.spyOn(VinLookupComponent.methods, getPartsOrQuestions.methodName)
|
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||||
store.getCapabilityQuestions.mockResolvedValueOnce({ data: [] });
|
store.getCapabilityQuestions.mockResolvedValueOnce({ data: [] });
|
||||||
|
|
||||||
|
|
@ -455,7 +456,7 @@ describe('vin-lookup.vue', () => {
|
||||||
|
|
||||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||||
jest.spyOn(VinLookupComponent.methods, getPartsOrQuestions.methodName)
|
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||||
|
|
||||||
const { container } = render(VinLookupComponent, mountOptions);
|
const { container } = render(VinLookupComponent, mountOptions);
|
||||||
|
|
|
||||||
|
|
@ -241,19 +241,6 @@ export default {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
async getPartsOrQuestions() {
|
|
||||||
try {
|
|
||||||
const response = await this.mainStore.getPartsOrQuestions();
|
|
||||||
|
|
||||||
return response;
|
|
||||||
} catch (responseError) {
|
|
||||||
return {
|
|
||||||
error: {
|
|
||||||
status: responseError.status
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async lookupVehicleByVin(vin) {
|
async lookupVehicleByVin(vin) {
|
||||||
try {
|
try {
|
||||||
return await this.mainStore.lookupVehicleByVin(vin);
|
return await this.mainStore.lookupVehicleByVin(vin);
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,18 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getPartsOrQuestions() {
|
||||||
|
try {
|
||||||
|
return await useMainStore().getPartsOrQuestions();
|
||||||
|
} catch (responseError) {
|
||||||
|
return {
|
||||||
|
error: {
|
||||||
|
status: responseError.status
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Can't use `this` because navigateForward is also called from vin-pages-mixin
|
// Can't use `this` because navigateForward is also called from vin-pages-mixin
|
||||||
async navigateForward(partsOrQuestions, vm) {
|
async navigateForward(partsOrQuestions, vm) {
|
||||||
const self = vm ?? this;
|
const self = vm ?? this;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ const navigationScenarios = Object.freeze({
|
||||||
|
|
||||||
// Vin selection
|
// Vin selection
|
||||||
CLICKED_BACK_WITH_VIN: 'CLICKED_BACK_WITH_VIN',
|
CLICKED_BACK_WITH_VIN: 'CLICKED_BACK_WITH_VIN',
|
||||||
CLICKED_FORWARD_WITH_VIN: 'CLICKED_FORWARD_WITH_VIN',
|
|
||||||
CLICKED_FORWARD_WITHOUT_VIN: 'CLICKED_FORWARD_WITHOUT_VIN',
|
CLICKED_FORWARD_WITHOUT_VIN: 'CLICKED_FORWARD_WITHOUT_VIN',
|
||||||
CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES: 'CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES',
|
CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES: 'CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES',
|
||||||
SELECTED_VIN_WITH_MISMATCHED_GLASS: 'SELECTED_VIN_WITH_MISMATCHED_GLASS',
|
SELECTED_VIN_WITH_MISMATCHED_GLASS: 'SELECTED_VIN_WITH_MISMATCHED_GLASS',
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,24 @@ const routingTable = () => [
|
||||||
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
|
||||||
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
destinationIssPageValue: issPageValues.PART_QUESTIONS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
|
||||||
|
destinationIssPageValue: issPageValues.VEHICLE_PARTS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
|
||||||
|
destinationIssPageValue: issPageValues.MOLDING_QUESTIONS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
|
||||||
|
destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||||
|
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue