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:
AHumphriesSL 2026-02-16 11:40:13 -05:00 committed by GitHub
commit d6775e3c83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 154 additions and 15 deletions

View file

@ -90,6 +90,15 @@ export function getGlassList(glassPieces) {
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
* and have not been adjusted for ISS.

View file

@ -5,6 +5,7 @@ import routerParams from '@/router/router-constants/router-params';
import { useMainStore } from '@/store';
import vehicleCategories from '@/constants/vehicle-categories';
import VehicleDamageComponent from '@/layouts/vehicle-damage/vehicle-damage.vue';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
const mockRoute = {
params: {}
@ -12,6 +13,16 @@ const mockRoute = {
const mockRouter = {
navigate: jest.fn()
};
jest.mock('@/mixins/vehicle-questions-mixin', () => ({
methods: {
navigateForward: jest.fn(),
getPartsOrQuestions: jest.fn(() => Promise.resolve({
data: {
partsOrQuestions: []
}
}))
}
}));
const mountOptions = {
global: {
mixins: [
@ -91,6 +102,43 @@ describe('vehicle-damage.vue', () => {
expect(mockRouter.navigate)
.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 () => {
mountOptions.global.plugins = [createTestingPinia({
initialState: {
@ -115,7 +163,7 @@ describe('vehicle-damage.vue', () => {
const partsQuestionsErrorResponse = {
error: 'Error getting parts'
};
useMainStore().getPartsOrQuestions = jest.fn().mockImplementation(() => (
vehicleQuestionsMixin.methods.getPartsOrQuestions.mockImplementation(() => (
partsQuestionsErrorResponse
));
siteFooterWrapper.vm.$emit('forwardClicked');

View file

@ -216,6 +216,13 @@ export default {
=== damageLocationsSelected.REPAIR
);
},
isWindshieldReplace() {
return (
this.isWindshieldDamageLocation
&& this.selectedWindshieldOptions.selectedWindshieldDamageType
=== damageLocationsSelected.REPLACE
);
},
isDriverSideReplace() {
if (!this.isSideDoorDamageLocation) return false;
@ -418,8 +425,8 @@ export default {
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
this.$route
);
} else if (this.mainStore.order.vehicle.vin) {
// If vin already exists, navigate directly to vin-lookup
} else if (this.mainStore.order.vehicle.vin || !this.isWindshieldReplace) {
// If vin already exists or not replacing windshield, get parts/questions and navigate forward
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
if (partsOrQuestionsResponse.error) {

View file

@ -212,6 +212,7 @@ describe('vehicle-parts.vue', () => {
test('User had part questions > navigateBack triggers a router.navigateWithoutSaving change with correct scenario', async () => {
// Arrange
useMainStore().damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
const { wrapper } = setupMocks({
mountOptionsMockData: {
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 () => {
// Arrange
useMainStore().damage.glassToReplace = [{ glassLocation: 'Rear', glassName: 'Stationary' }, { glassLocation: 'Windshield', glassName: 'Single' }];
const { wrapper } = setupMocks({
mountOptionsMockData: {
router: {

View file

@ -1,3 +1,4 @@
import { includesWindshieldReplacement } from '@/helpers/damage-helper';
import issPageValues from '@/router/router-constants/issPage-values';
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
import { useMainStore } from '@/store';
@ -457,6 +458,8 @@ export default {
let backNavigationScenario = '';
if (self.mainStore.order.damage.isRepair) {
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_REPAIR;
} else if (!includesWindshieldReplacement()) {
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_SKIP_VIN_AND_NO_MORE_QUESTIONS;
} else {
backNavigationScenario = self.mainStore.vehicle.vin
? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS

View file

@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils';
import { setupMocksForJsFiles, getMountOptions } from '@/helpers/unit-test-helper.js';
import issPageValues from '@/router/router-constants/issPage-values';
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
import { useMainStore } from '@/store';
import { useMainStore, getDefaultState } from '@/store';
/** @ignore */
function setupMocks({ issPage = issPageValues.VIN_LOOKUP }) {
@ -53,6 +53,7 @@ function setupMocks({ issPage = issPageValues.VIN_LOOKUP }) {
describe('vehicle-questions-mixin', () => {
afterEach(() => {
jest.clearAllMocks();
useMainStore().order = getDefaultState().order;
});
describe('hasPartQuestions', () => {
@ -2181,19 +2182,83 @@ describe('vehicle-questions-mixin', () => {
});
describe('navigateBackByVehicleQuestions', () => {
test('current page is coverage-statement and damage is repair => go to vehicle-damage', () => {
// Arrange
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
useMainStore().order.damage.isRepair = true;
describe('current page is coverage-statement', () => {
test('damage is repair => go to vehicle-damage', () => {
// Arrange
const { wrapper } = setupMocks({ issPage: issPageValues.COVERAGE_STATEMENT });
useMainStore().order.damage.isRepair = true;
// Act
wrapper.vm.navigateBackByVehicleQuestions();
// Act
wrapper.vm.navigateBackByVehicleQuestions();
// Assert
expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_REPAIR,
{ query: { issPage: issPageValues.COVERAGE_STATEMENT } }
);
// Assert
expect(wrapper.vm.$router.navigateWithSpinner).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_REPAIR,
{ 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(

View file

@ -61,6 +61,7 @@ const navigationScenarios = Object.freeze({
CLICKED_BACK_WITH_MOLDING_QUESTIONS: 'CLICKED_BACK_WITH_MOLDING_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_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',
// Schedule

View file

@ -536,6 +536,10 @@ const routingTable = () => [
scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
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,
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP