Merge pull request #1081 from Safelite/feature/humphries/INSR-7774.2
INSR-8455: Skip vehicle lookup if not replacing windshield
This commit is contained in:
commit
d6775e3c83
8 changed files with 154 additions and 15 deletions
|
|
@ -90,6 +90,15 @@ export function getGlassList(glassPieces) {
|
||||||
return names.toLowerCase();
|
return names.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function includesWindshieldReplacement() {
|
||||||
|
const mainStore = useMainStore();
|
||||||
|
const windshieldMatches =
|
||||||
|
mainStore.damage.glassToReplace?.filter(
|
||||||
|
(glassToReplace) => glassToReplace.glassLocation === damageLocationsSelected.WINDSHIELD
|
||||||
|
) ?? [];
|
||||||
|
return windshieldMatches.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commented code are copied directly from DigitalConsumer.FixMyGlass
|
* Commented code are copied directly from DigitalConsumer.FixMyGlass
|
||||||
* and have not been adjusted for ISS.
|
* and have not been adjusted for ISS.
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import routerParams from '@/router/router-constants/router-params';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import vehicleCategories from '@/constants/vehicle-categories';
|
import vehicleCategories from '@/constants/vehicle-categories';
|
||||||
import VehicleDamageComponent from '@/layouts/vehicle-damage/vehicle-damage.vue';
|
import VehicleDamageComponent from '@/layouts/vehicle-damage/vehicle-damage.vue';
|
||||||
|
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
||||||
|
|
||||||
const mockRoute = {
|
const mockRoute = {
|
||||||
params: {}
|
params: {}
|
||||||
|
|
@ -12,6 +13,16 @@ const mockRoute = {
|
||||||
const mockRouter = {
|
const mockRouter = {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn()
|
||||||
};
|
};
|
||||||
|
jest.mock('@/mixins/vehicle-questions-mixin', () => ({
|
||||||
|
methods: {
|
||||||
|
navigateForward: jest.fn(),
|
||||||
|
getPartsOrQuestions: jest.fn(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
|
partsOrQuestions: []
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}));
|
||||||
const mountOptions = {
|
const mountOptions = {
|
||||||
global: {
|
global: {
|
||||||
mixins: [
|
mixins: [
|
||||||
|
|
@ -91,6 +102,43 @@ describe('vehicle-damage.vue', () => {
|
||||||
expect(mockRouter.navigate)
|
expect(mockRouter.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, mockRoute);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, mockRoute);
|
||||||
});
|
});
|
||||||
|
test('When damage selected is a replace but not windshield, navigate forward from vehicle-questions-mixin', async () => {
|
||||||
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: false,
|
||||||
|
glassToReplace: [{ glassLocation: 'Rear', glassName: 'Stationary' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})];
|
||||||
|
const wrapper = mount(VehicleDamageComponent, mountOptions);
|
||||||
|
const siteFooterWrapper = wrapper.getComponent({ ref: 'siteFooter' });
|
||||||
|
|
||||||
|
useMainStore().getSupportingItems = jest.fn().mockImplementation(() => Promise.resolve({
|
||||||
|
data: { data: [
|
||||||
|
{
|
||||||
|
description: null,
|
||||||
|
partNumber: 'SUPPLIES-REPAIR',
|
||||||
|
partType: 'REPAIR FEE'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: null,
|
||||||
|
partNumber: 'WSREPAIR',
|
||||||
|
partType: 'REPAIR FEE'
|
||||||
|
}
|
||||||
|
] }
|
||||||
|
}));
|
||||||
|
|
||||||
|
siteFooterWrapper.vm.$emit('forwardClicked');
|
||||||
|
|
||||||
|
await flushPromises();
|
||||||
|
expect(vehicleQuestionsMixin.methods.getPartsOrQuestions).toHaveBeenCalledTimes(1);
|
||||||
|
expect(vehicleQuestionsMixin.methods.navigateForward).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
test('Error in getPartsOrQuestions call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario', async () => {
|
test('Error in getPartsOrQuestions call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario', async () => {
|
||||||
mountOptions.global.plugins = [createTestingPinia({
|
mountOptions.global.plugins = [createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
|
|
@ -115,7 +163,7 @@ describe('vehicle-damage.vue', () => {
|
||||||
const partsQuestionsErrorResponse = {
|
const partsQuestionsErrorResponse = {
|
||||||
error: 'Error getting parts'
|
error: 'Error getting parts'
|
||||||
};
|
};
|
||||||
useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => (
|
vehicleQuestionsMixin.methods.getPartsOrQuestions.mockImplementation(() => (
|
||||||
partsQuestionsErrorResponse
|
partsQuestionsErrorResponse
|
||||||
));
|
));
|
||||||
siteFooterWrapper.vm.$emit('forwardClicked');
|
siteFooterWrapper.vm.$emit('forwardClicked');
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,13 @@ export default {
|
||||||
=== damageLocationsSelected.REPAIR
|
=== damageLocationsSelected.REPAIR
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
isWindshieldReplace() {
|
||||||
|
return (
|
||||||
|
this.isWindshieldDamageLocation
|
||||||
|
&& this.selectedWindshieldOptions.selectedWindshieldDamageType
|
||||||
|
=== damageLocationsSelected.REPLACE
|
||||||
|
);
|
||||||
|
},
|
||||||
isDriverSideReplace() {
|
isDriverSideReplace() {
|
||||||
if (!this.isSideDoorDamageLocation) return false;
|
if (!this.isSideDoorDamageLocation) return false;
|
||||||
|
|
||||||
|
|
@ -418,8 +425,8 @@ export default {
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
|
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
|
||||||
this.$route
|
this.$route
|
||||||
);
|
);
|
||||||
} else if (this.mainStore.order.vehicle.vin) {
|
} else if (this.mainStore.order.vehicle.vin || !this.isWindshieldReplace) {
|
||||||
// If vin already exists, navigate directly to vin-lookup
|
// If vin already exists or not replacing windshield, get parts/questions and navigate forward
|
||||||
|
|
||||||
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
|
||||||
if (partsOrQuestionsResponse.error) {
|
if (partsOrQuestionsResponse.error) {
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,7 @@ describe('vehicle-parts.vue', () => {
|
||||||
|
|
||||||
test('User had part questions > navigateBack triggers a router.navigateWithoutSaving change with correct scenario', async () => {
|
test('User had part questions > navigateBack triggers a router.navigateWithoutSaving change with correct scenario', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
useMainStore().damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
mountOptionsMockData: {
|
mountOptionsMockData: {
|
||||||
router: {
|
router: {
|
||||||
|
|
@ -244,6 +245,7 @@ describe('vehicle-parts.vue', () => {
|
||||||
|
|
||||||
test('User did not have part questions > navigateBack triggers a router.navigate change with correct scenario', async () => {
|
test('User did not have part questions > navigateBack triggers a router.navigate change with correct scenario', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
useMainStore().damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
mountOptionsMockData: {
|
mountOptionsMockData: {
|
||||||
router: {
|
router: {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { includesWindshieldReplacement } from '@/helpers/damage-helper';
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
|
@ -457,6 +458,8 @@ export default {
|
||||||
let backNavigationScenario = '';
|
let backNavigationScenario = '';
|
||||||
if (self.mainStore.order.damage.isRepair) {
|
if (self.mainStore.order.damage.isRepair) {
|
||||||
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_REPAIR;
|
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_REPAIR;
|
||||||
|
} else if (!includesWindshieldReplacement()) {
|
||||||
|
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_SKIP_VIN_AND_NO_MORE_QUESTIONS;
|
||||||
} else {
|
} else {
|
||||||
backNavigationScenario = self.mainStore.vehicle.vin
|
backNavigationScenario = self.mainStore.vehicle.vin
|
||||||
? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS
|
? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils';
|
||||||
import { setupMocksForJsFiles, getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { setupMocksForJsFiles, getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import issPageValues from '@/router/router-constants/issPage-values';
|
import issPageValues from '@/router/router-constants/issPage-values';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore, getDefaultState } from '@/store';
|
||||||
|
|
||||||
/** @ignore */
|
/** @ignore */
|
||||||
function setupMocks({ issPage = issPageValues.VIN_LOOKUP }) {
|
function setupMocks({ issPage = issPageValues.VIN_LOOKUP }) {
|
||||||
|
|
@ -53,6 +53,7 @@ function setupMocks({ issPage = issPageValues.VIN_LOOKUP }) {
|
||||||
describe('vehicle-questions-mixin', () => {
|
describe('vehicle-questions-mixin', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
useMainStore().order = getDefaultState().order;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hasPartQuestions', () => {
|
describe('hasPartQuestions', () => {
|
||||||
|
|
@ -2181,7 +2182,8 @@ describe('vehicle-questions-mixin', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('navigateBackByVehicleQuestions', () => {
|
describe('navigateBackByVehicleQuestions', () => {
|
||||||
test('current page is coverage-statement and damage is repair => go to vehicle-damage', () => {
|
describe('current page is coverage-statement', () => {
|
||||||
|
test('damage is repair => go to vehicle-damage', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
|
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
|
||||||
useMainStore().order.damage.isRepair = true;
|
useMainStore().order.damage.isRepair = true;
|
||||||
|
|
@ -2195,6 +2197,69 @@ describe('vehicle-questions-mixin', () => {
|
||||||
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
|
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
test('damage is replace but not windshield => go to vehicle-damage', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
|
||||||
|
useMainStore().order.damage.isRepair = false;
|
||||||
|
useMainStore().order.damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateBackByVehicleQuestions();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_BACK_WITH_SKIP_VIN_AND_NO_MORE_QUESTIONS,
|
||||||
|
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('damage is replace and includes windshield, we have vin => go to vehicle-damage', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
|
||||||
|
useMainStore().order.damage.isRepair = false;
|
||||||
|
useMainStore().order.damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
|
||||||
|
useMainStore().order.vehicle.vin = '5NMS3CADXLH233004';
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateBackByVehicleQuestions();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
|
||||||
|
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('damage is replace and includes windshield => go to vehicle-lookup', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
|
||||||
|
useMainStore().order.damage.isRepair = false;
|
||||||
|
useMainStore().order.damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateBackByVehicleQuestions();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
|
||||||
|
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test('damage is replace and includes windshield but there are parts to choose => go to vehicle-parts', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
|
||||||
|
useMainStore().order.damage.isRepair = false;
|
||||||
|
useMainStore().order.damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
|
||||||
|
wrapper.vm.hasGlassLocationWithMultipleParts = jest.fn().mockReturnValue(true);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.navigateBackByVehicleQuestions();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE,
|
||||||
|
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts',
|
'current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts',
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ const navigationScenarios = Object.freeze({
|
||||||
CLICKED_BACK_WITH_MOLDING_QUESTIONS: 'CLICKED_BACK_WITH_MOLDING_QUESTIONS',
|
CLICKED_BACK_WITH_MOLDING_QUESTIONS: 'CLICKED_BACK_WITH_MOLDING_QUESTIONS',
|
||||||
CLICKED_BACK_WITH_CAPABILITY_QUESTIONS: 'CLICKED_BACK_WITH_CAPABILITY_QUESTIONS',
|
CLICKED_BACK_WITH_CAPABILITY_QUESTIONS: 'CLICKED_BACK_WITH_CAPABILITY_QUESTIONS',
|
||||||
CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS: 'CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS',
|
CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS: 'CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS',
|
||||||
|
CLICKED_BACK_WITH_SKIP_VIN_AND_NO_MORE_QUESTIONS: 'CLICKED_BACK_WITH_SKIP_VIN_AND_NO_MORE_QUESTIONS',
|
||||||
CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS: 'CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS',
|
CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS: 'CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS',
|
||||||
|
|
||||||
// Schedule
|
// Schedule
|
||||||
|
|
|
||||||
|
|
@ -536,6 +536,10 @@ const routingTable = () => [
|
||||||
scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
|
scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
|
||||||
destinationIssPageValue: issPageValues.VEHICLE_DAMAGE
|
destinationIssPageValue: issPageValues.VEHICLE_DAMAGE
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_BACK_WITH_SKIP_VIN_AND_NO_MORE_QUESTIONS,
|
||||||
|
destinationIssPageValue: issPageValues.VEHICLE_DAMAGE
|
||||||
|
},
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
|
scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
|
||||||
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue