Merge branch 'develop' into feature/Digital/CSR-1629

This commit is contained in:
hiteshkumar87 2024-09-04 14:59:36 +05:30 committed by GitHub
commit 663c1d90e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 42 additions and 21 deletions

View file

@ -525,14 +525,18 @@ export default {
await submitWorkOrder({ pageNameToLog: "payment-method", submitAfterSave: true }); await submitWorkOrder({ pageNameToLog: "payment-method", submitAfterSave: true });
this.$router.navigateWithoutSaving( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_FORWARD, this.navigationScenarios.CLICKED_FORWARD,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_PIA_ALERT]: false }
); );
} else { } else {
if (this.paymentMethod == paymentMethods.INSURANCE) { if (this.paymentMethod == paymentMethods.INSURANCE) {
this.dispatchStoreAction(this.storeActions.SAVE_PAYMENT_TYPE, true, false); this.dispatchStoreAction(this.storeActions.SAVE_PAYMENT_TYPE, true, false);
this.$router.navigateWithoutSaving( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_INSURANCE, this.navigationScenarios.CLICKED_INSURANCE,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_PIA_ALERT]: false }
); );
} else { } else {
this.setupPia(); this.setupPia();
@ -554,14 +558,16 @@ export default {
} catch (error) { } catch (error) {
console.log("error: response from pia submit work order:" + error.message); console.log("error: response from pia submit work order:" + error.message);
this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE);
this.$route.params[routerParams.DISPLAY_PIA_ALERT] = true; this.$route.query[queryStrings.DISPLAY_PIA_ALERT] = true;
return; return;
} }
} }
this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE);
this.$router.navigateWithoutSaving( this.$router.navigateWithoutSaving(
this.navigationScenarios.CLICKED_PAY_NOW, this.navigationScenarios.CLICKED_PAY_NOW,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_PIA_ALERT]: false }
); );
}, },
hasSubmittedOrder() { hasSubmittedOrder() {
@ -682,7 +688,7 @@ export default {
shouldDisplayPiaAlert() { shouldDisplayPiaAlert() {
return ( return (
this.$route.query[queryStrings.DISPLAY_PIA_ALERT] || this.$route.query[queryStrings.DISPLAY_PIA_ALERT] ||
this.$route.params[routerParams.DISPLAY_PIA_ALERT] eval(window.history.state.displayPiaAlert)
); );
}, },
// Necessary to make the watcher of lineItems work // Necessary to make the watcher of lineItems work

View file

@ -747,7 +747,7 @@ export default {
shouldDisplayPiaAlert(payMethod) { shouldDisplayPiaAlert(payMethod) {
return ( return (
this.$route.query[queryStrings.DISPLAY_PIA_ALERT] === payMethod || this.$route.query[queryStrings.DISPLAY_PIA_ALERT] === payMethod ||
this.$route.params[routerParams.DISPLAY_PIA_ALERT] === payMethod eval(window.history.state.displayPiaAlert)
); );
}, },
}, },

View file

@ -310,12 +310,11 @@ describe("vehicle-damage.vue", () => {
describe("alert", () => { describe("alert", () => {
test("when displayVehicleChangeAlert router params is true, the alert: 'vehicleChangeAlert' should be rendered", () => { test("when displayVehicleChangeAlert router params is true, the alert: 'vehicleChangeAlert' should be rendered", () => {
// Arrange & Act // Arrange & Act
window.history.pushState({ displayVehicleChangeAlert: "true" }, "", "");
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
route: { route: {
params: { state: { displayVehicleChangeAlert: true },
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true,
},
}, },
}, },
}); });
@ -325,21 +324,24 @@ describe("vehicle-damage.vue", () => {
test("when displayVehicleChangeAlert router params is false, the alert: 'vehicleChangeAlert' should not be rendered", () => { test("when displayVehicleChangeAlert router params is false, the alert: 'vehicleChangeAlert' should not be rendered", () => {
// Arrange & Act // Arrange & Act
window.history.pushState({ displayVehicleChangeAlert: "false" }, "", "");
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
route: { route: {
params: { state: {
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false, [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false,
}, },
}, },
}, },
}); });
// Assert // Assert
expect(wrapper.findComponent({ ref: "vehicleChangeAlert" }).exists()).toBe(false); expect(wrapper.findComponent({ ref: "vehicleChangeAlert" }).exists()).toBe(false);
}); });
test("when displayVehicleChangeAlert router params is undefined, the alert: 'vehicleChangeAlert' should not be rendered", () => { test("when displayVehicleChangeAlert router params is undefined, the alert: 'vehicleChangeAlert' should not be rendered", () => {
// Arrange & Act // Arrange & Act
window.history.pushState({ displayVehicleChangeAlert: "false" }, "", "");
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
route: { route: {
@ -850,7 +852,7 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCo
navigateWithSaving: jest.fn(), navigateWithSaving: jest.fn(),
}, },
route: { route: {
params: { state: {
[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false, [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false,
}, },
}, },

View file

@ -103,6 +103,7 @@ import { errorMessages } from "@/constants/error-messages";
import { damageLocationsCms } from "@/constants/damage-locations-cms.js"; import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js"; import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
import { routerParams } from "@/router/router-constants/router-params";
import store from "@/store"; import store from "@/store";
import baseMixin from "@/mixins/base-mixin"; import baseMixin from "@/mixins/base-mixin";
@ -405,20 +406,26 @@ export default {
if (skipVin) { if (skipVin) {
this.$router.navigateWithSaving( this.$router.navigateWithSaving(
this.navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN, this.navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false }
); );
} else { } else {
if (store.getters.damage.isRepair) { if (store.getters.damage.isRepair) {
this.$router.navigateWithSaving( this.$router.navigateWithSaving(
this.navigationScenarios this.navigationScenarios
.CLICKED_FORWARD_WITH_REPAIR_AND_VERIFIED_INSURANCE, .CLICKED_FORWARD_WITH_REPAIR_AND_VERIFIED_INSURANCE,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false }
); );
} else { } else {
this.$router.navigateWithSaving( this.$router.navigateWithSaving(
this.navigationScenarios this.navigationScenarios
.CLICKED_FORWARD_WITH_REPLACE_AND_VERIFIED_INSURANCE, .CLICKED_FORWARD_WITH_REPLACE_AND_VERIFIED_INSURANCE,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false }
); );
} }
} }
@ -427,17 +434,23 @@ export default {
else if (store.getters.vehicle.vin) { else if (store.getters.vehicle.vin) {
this.$router.navigateWithSaving( this.$router.navigateWithSaving(
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false }
); );
} else if (skipVin) { } else if (skipVin) {
this.$router.navigateWithSaving( this.$router.navigateWithSaving(
this.navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN, this.navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false }
); );
} else { } else {
this.$router.navigateWithSaving( this.$router.navigateWithSaving(
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
this.$route this.$route,
{},
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: false }
); );
} }
}, },
@ -566,7 +579,7 @@ export default {
); );
}, },
shouldDisplayVehicleChangeAlert() { shouldDisplayVehicleChangeAlert() {
return this.$route.params[this.routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]; return eval(window.history.state.displayVehicleChangeAlert);
}, },
shouldHideBackButton() { shouldHideBackButton() {
return this.$store.getters.requiresVerifiedRedirecting; return this.$store.getters.requiresVerifiedRedirecting;

View file

@ -398,6 +398,8 @@ async function navigate(
: (existingPageDataForPage ?? {}) : (existingPageDataForPage ?? {})
); );
optionalParams.isSavingNavigation = isSavingNavigation;
// add querystring params to the route. if they are already in the store then no need to add them // add querystring params to the route. if they are already in the store then no need to add them
var queryStringsObject = { var queryStringsObject = {
fmgPage: destinationFmgPageValue, fmgPage: destinationFmgPageValue,
@ -429,9 +431,7 @@ async function navigate(
router.push({ router.push({
name: "root", name: "root",
query: Object.assign(optionalQuery, queryStringsObject), query: Object.assign(optionalQuery, queryStringsObject),
state: { state: optionalParams,
isSavingNavigation: isSavingNavigation,
},
}); });
} else if (matchingScenarioMap.destinationUrl !== undefined) { } else if (matchingScenarioMap.destinationUrl !== undefined) {
navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery); navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery);