Merge pull request #864 from Safelite/feature/CSR-944-dev
Feature/csr 944 dev
This commit is contained in:
commit
a635bc48ea
5 changed files with 42 additions and 13 deletions
|
|
@ -248,7 +248,9 @@ describe("vehicle-parts.vue", () => {
|
|||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
wrapper.vm.navigateBack();
|
||||
store.dispatch = jest.fn(() => {});
|
||||
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
@ -294,7 +296,8 @@ describe("vehicle-parts.vue", () => {
|
|||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
wrapper.vm.navigateBack();
|
||||
store.dispatch = jest.fn(() => {});
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ export default {
|
|||
}
|
||||
},
|
||||
// Can't use `this` because navigateForward is also called from quote
|
||||
navigateBack(vm) {
|
||||
async navigateBack(vm) {
|
||||
const self = vm ?? this;
|
||||
const partsOrQuestions = (
|
||||
self.$store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS) ??
|
||||
|
|
@ -471,6 +471,8 @@ export default {
|
|||
this.hasGlassLocationWithMultipleParts(partsOrQuestions);
|
||||
const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions);
|
||||
const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions);
|
||||
const skipVinLookup = await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE);
|
||||
|
||||
let backNavigationScenario = self.$store.getters.vehicle.vin
|
||||
? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS
|
||||
: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS;
|
||||
|
|
@ -497,6 +499,8 @@ export default {
|
|||
this.currentPageComesAfterPage(currentPage, fmgPageValues.PART_QUESTIONS)
|
||||
) {
|
||||
backNavigationScenario = navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS;
|
||||
} else if (skipVinLookup) {
|
||||
backNavigationScenario = navigationScenarios.CLICKED_BACK_TO_GO_TO_ESTIMATE;
|
||||
}
|
||||
|
||||
self.$router.navigateWithoutSaving(backNavigationScenario, self.$route);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { shallowMount } from "@vue/test-utils";
|
|||
import { setupMocksForJsFiles, getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import store from "@/store";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { navigationScenarios } from "../router/router-constants/navigation-scenarios";
|
||||
import { getters } from "@/store";
|
||||
|
|
@ -2259,12 +2260,13 @@ describe("vehicle-questions-mixin", () => {
|
|||
"current page is quote, there are no questions, and we don't have their vin => go to estimate"
|
||||
);
|
||||
|
||||
test("current page is quote, there are no questions, and we have their vin => go to vin-lookup", () => {
|
||||
test("current page is quote, there are no questions, and we have their vin => go to vin-lookup", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ fmgPage: fmgPageValues.QUOTE, hasVin: true });
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateBack();
|
||||
store.dispatch = jest.fn(() => {});
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
@ -2273,13 +2275,14 @@ describe("vehicle-questions-mixin", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("current page is quote and there are capability questions => go to capability questions", () => {
|
||||
test("current page is quote and there are capability questions => go to capability questions", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ fmgPage: fmgPageValues.QUOTE });
|
||||
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateBack();
|
||||
store.dispatch = jest.fn(() => {});
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
@ -2288,14 +2291,14 @@ describe("vehicle-questions-mixin", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("current page is quote and there are part questions and molding questions => go to molding questions", () => {
|
||||
test("current page is quote and there are part questions and molding questions => go to molding questions", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ fmgPage: fmgPageValues.QUOTE });
|
||||
wrapper.vm.hasPartQuestions = jest.fn().mockReturnValue(true);
|
||||
wrapper.vm.hasChildPartQuestions = jest.fn().mockReturnValue(true);
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateBack();
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
@ -2304,7 +2307,7 @@ describe("vehicle-questions-mixin", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts", () => {
|
||||
test("current page is molding questions and there are part questions, multiple parts to choose, and capability questions => go to vehicle-parts", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ fmgPage: fmgPageValues.MOLDING_QUESTIONS });
|
||||
wrapper.vm.hasPartQuestions = jest.fn().mockReturnValue(true);
|
||||
|
|
@ -2313,7 +2316,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateBack();
|
||||
store.dispatch = jest.fn(() => {});
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
@ -2322,7 +2326,7 @@ describe("vehicle-questions-mixin", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("current page is molding questions and there are part questions and capability questions => go to part-questions", () => {
|
||||
test("current page is molding questions and there are part questions and capability questions => go to part-questions", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ fmgPage: fmgPageValues.MOLDING_QUESTIONS });
|
||||
wrapper.vm.hasPartQuestions = jest.fn().mockReturnValue(true);
|
||||
|
|
@ -2331,7 +2335,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
wrapper.vm.hasCapabilityQuestions = jest.fn().mockReturnValue(true);
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateBack();
|
||||
store.dispatch = jest.fn(() => {});
|
||||
await wrapper.vm.navigateBack();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalledWith(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ const navigationScenarios = {
|
|||
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_NO_VIN_NOR_QUESTIONS: "CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS",
|
||||
CLICKED_BACK_TO_GO_TO_ESTIMATE: "CLICKED_BACK_TO_GO_TO_ESTIMATE",
|
||||
};
|
||||
|
||||
export { navigationScenarios };
|
||||
|
|
|
|||
|
|
@ -286,6 +286,10 @@ const routingTable = function (store) {
|
|||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||
destinationFmgPageValue: fmgPageValues.QUOTE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK_TO_GO_TO_ESTIMATE,
|
||||
destinationFmgPageValue: fmgPageValues.ESTIMATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
@ -319,6 +323,10 @@ const routingTable = function (store) {
|
|||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||
destinationFmgPageValue: fmgPageValues.QUOTE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK_TO_GO_TO_ESTIMATE,
|
||||
destinationFmgPageValue: fmgPageValues.ESTIMATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
@ -348,6 +356,10 @@ const routingTable = function (store) {
|
|||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||
destinationFmgPageValue: fmgPageValues.QUOTE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK_TO_GO_TO_ESTIMATE,
|
||||
destinationFmgPageValue: fmgPageValues.ESTIMATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
@ -377,6 +389,10 @@ const routingTable = function (store) {
|
|||
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||
destinationFmgPageValue: fmgPageValues.QUOTE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK_TO_GO_TO_ESTIMATE,
|
||||
destinationFmgPageValue: fmgPageValues.ESTIMATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue