diff --git a/src/mixins/vin-pages-mixin.js b/src/mixins/vin-pages-mixin.js index c15529d4f..78cb134cf 100644 --- a/src/mixins/vin-pages-mixin.js +++ b/src/mixins/vin-pages-mixin.js @@ -37,7 +37,7 @@ export default { pageNameToLog: pageName, }); - if (result.PartNotFound || store.getters.vehicle.vinRequired) { + if (result.PartNotFound) { return bailoutMixin.methods.navigateToBailoutPage( this, bailoutCodes.PART_NOT_FOUND diff --git a/src/mixins/vin-pages-mixin.spec.js b/src/mixins/vin-pages-mixin.spec.js index 46d755c3c..55f0d02fc 100644 --- a/src/mixins/vin-pages-mixin.spec.js +++ b/src/mixins/vin-pages-mixin.spec.js @@ -35,10 +35,9 @@ describe("vin-pages-mixin", () => { expect(vehicleQuestionsMixin.methods.navigateForward).toHaveBeenCalled(); }); - test("vinRequired vehicles navigate to bailout after VIN is saved", async () => { + test("navigate to bailout when parts are not found", async () => { // Arrange - store.commit(storeMutations.UPDATE_VIN_REQUIRED, true); - const { wrapper } = setupMocks({}); + const { wrapper } = setupMocks({ partNotFound: true }); bailoutMixin.methods.navigateToBailoutPage = jest.fn(); vehicleQuestionsMixin.methods.navigateForward = jest.fn(); @@ -52,10 +51,29 @@ describe("vin-pages-mixin", () => { ); expect(vehicleQuestionsMixin.methods.navigateForward).not.toHaveBeenCalled(); }); + + test("vinRequired vehicles navigate forward when parts are found", async () => { + // Arrange + store.commit(storeMutations.UPDATE_VIN_REQUIRED, true); + const partsOrQuestions = [{ partNumber: "123" }]; + const { wrapper } = setupMocks({ partsOrQuestions }); + bailoutMixin.methods.navigateToBailoutPage = jest.fn(); + vehicleQuestionsMixin.methods.navigateForward = jest.fn(); + + // Act + await wrapper.vm.navigateForwardWithSingleCarMatch(); + + // Assert + expect(bailoutMixin.methods.navigateToBailoutPage).not.toHaveBeenCalled(); + expect(vehicleQuestionsMixin.methods.navigateForward).toHaveBeenCalledWith( + partsOrQuestions, + wrapper.vm + ); + }); }); }); -function setupMocks({ partsOrQuestions = [] }) { +function setupMocks({ partsOrQuestions = [], partNotFound = false } = {}) { const baseMixin = setupMocksForJsFiles({ actionList: [ { @@ -67,6 +85,14 @@ function setupMocks({ partsOrQuestions = [] }) { ], }); + if (partNotFound) { + baseMixin.baseMixin.methods.dispatchStoreAction.mockImplementation((actionName) => { + if (actionName === storeActions.GET_PARTS_OR_QUESTIONS) { + return Promise.resolve({ PartNotFound: true }); + } + }); + } + const mocks = getMountOptions({ router: { navigate: jest.fn(),