Merge remote-tracking branch 'origin/feature/CSR-98' into feature/CSR-99
This commit is contained in:
commit
322597c55b
6 changed files with 106 additions and 55 deletions
57
src/helpers/heritage-integration-helper.js
Normal file
57
src/helpers/heritage-integration-helper.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { storeActions } from "@/constants/store-actions.js";
|
||||
import { storeMutations } from "@/constants/store-mutations.js";
|
||||
import { cookieNames } from "@/constants/cookie-names";
|
||||
import store from "@/store";
|
||||
import router from "@/router";
|
||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||
import baseMixin from "../mixins/base-mixin";
|
||||
|
||||
// Read info from heritage funnel and reset state or load referral
|
||||
export function handleInfoFromHeritageFunnel() {
|
||||
var orderInfoJson = getHeritageCookieValue();
|
||||
var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson);
|
||||
|
||||
if (orderInfo?.ShouldResetState) {
|
||||
store.dispatch(storeActions.RESET_STATE);
|
||||
}
|
||||
else if (orderInfo != null) {
|
||||
// should load referral here
|
||||
}
|
||||
|
||||
// Delete cookie once state is loaded or reset
|
||||
deleteHeritageCookie();
|
||||
}
|
||||
|
||||
export function navigateToHeritageFunnel() {
|
||||
var referralCorrelationId = store.getters.referralCorrelationId;
|
||||
|
||||
router.navigate(
|
||||
navigationScenarios.MOVE_TO_HERITAGE_FUNNEL,
|
||||
router.currentRoute.value,
|
||||
{
|
||||
corid: referralCorrelationId,
|
||||
src: "concept-funnel",
|
||||
// TODO CSR-98 REMOVE THIS
|
||||
cns: "all",
|
||||
experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveOrder() {
|
||||
var savedOrderInfo = (await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.SAVE_ORDER)).data;
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber);
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate);
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId);
|
||||
}
|
||||
|
||||
export function getHeritageCookieValue() {
|
||||
return document.cookie
|
||||
?.split("; ")
|
||||
?.find(row => row.startsWith(`${cookieNames.ORDER_INFO}=`))
|
||||
?.split("=")[1];
|
||||
}
|
||||
|
||||
export function deleteHeritageCookie() {
|
||||
document.cookie = `${cookieNames.ORDER_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
||||
}
|
||||
41
src/helpers/heritage-integration-helper.spec.js
Normal file
41
src/helpers/heritage-integration-helper.spec.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
// test("getCookieValue: Gets correct cookie value", () => {
|
||||
// // Arrange
|
||||
// const mixIn = getMixInInstance({});
|
||||
// const testCookieName = "testCookie";
|
||||
// const testCookieValue = "testCookieValue";
|
||||
|
||||
// document.cookie = `yearMakeModel=2020 ACURA MDX;`;
|
||||
// document.cookie = `SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6;`;
|
||||
// document.cookie = `${testCookieName}=${testCookieValue};`;
|
||||
// document.cookie = `EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED;`;
|
||||
// document.cookie = `orderconfirmation=7411543;`;
|
||||
|
||||
// console.log(document.cookie)
|
||||
|
||||
// // Act
|
||||
// const actualCookieValue = mixIn.methods.getCookieValue(testCookieName);
|
||||
|
||||
// // Assert
|
||||
// expect(actualCookieValue).toEqual(testCookieValue);
|
||||
// expect(document.cookie).toEqual(`yearMakeModel=2020 ACURA MDX; SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6; ${testCookieName}=${testCookieValue}; EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED; orderconfirmation=7411543`);
|
||||
// clearCookies();
|
||||
// });
|
||||
|
||||
// test("getCookieValue: Gets undefined cookie value", () => {
|
||||
// // Arrange
|
||||
// const mixIn = getMixInInstance({});
|
||||
// const testCookieName = "testCookie";
|
||||
|
||||
// document.cookie = `yearMakeModel=2020 ACURA MDX;`;
|
||||
// document.cookie = `SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6;`;
|
||||
// document.cookie = `EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED;`;
|
||||
// document.cookie = `orderconfirmation=7411543;`;
|
||||
|
||||
// // Act
|
||||
// const actualCookieValue = mixIn.methods.getCookieValue(testCookieName);
|
||||
|
||||
// // Assert
|
||||
// expect(actualCookieValue).toEqual(undefined);
|
||||
// expect(document.cookie).toEqual(`yearMakeModel=2020 ACURA MDX; SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6; EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED; orderconfirmation=7411543;`);
|
||||
// });
|
||||
|
|
@ -77,6 +77,7 @@ import { required } from "@/helpers/validation-rules";
|
|||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
||||
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration-helper";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
|
||||
|
|
@ -296,7 +297,7 @@ export default {
|
|||
navigateForward(partsData){
|
||||
// CSR-98 TEMP
|
||||
if (store.getters.vehicle.year == 2010) {
|
||||
this.navigateToHeritageFunnel();
|
||||
navigateToHeritageFunnel();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,39 +22,6 @@ export default {
|
|||
savePageDataToStore(page, data){
|
||||
store.commit(storeMutations.UPDATE_PAGE_DATA, { page: page, data: data });
|
||||
},
|
||||
async saveOrder() {
|
||||
var savedOrderInfo = (await this.dispatchNonBlockingStoreAction(storeActions.SAVE_ORDER)).data;
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber);
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate);
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, savedOrderInfo.referralCorrelationId);
|
||||
},
|
||||
getCookieValue(cookieName) {
|
||||
return document.cookie
|
||||
?.split("; ")
|
||||
?.find(row => row.startsWith(`${cookieName}=`))
|
||||
?.split("=")[1];
|
||||
},
|
||||
setCookieValue(cookieName, cookieValue) {
|
||||
document.cookie = `${cookieName}=${cookieValue}`;
|
||||
},
|
||||
deleteCookie(cookieName) {
|
||||
document.cookie = `${cookieName}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
||||
},
|
||||
navigateToHeritageFunnel() {
|
||||
var referralCorrelationId = store.getters.referralCorrelationId;
|
||||
|
||||
router.navigate(
|
||||
navigationScenarios.MOVE_TO_HERITAGE_FUNNEL,
|
||||
router.currentRoute.value,
|
||||
{
|
||||
corid: referralCorrelationId,
|
||||
src: "concept-funnel",
|
||||
// TODO CSR-98 REMOVE THIS
|
||||
cns: "all",
|
||||
experiments: "ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
storeActions() {
|
||||
|
|
|
|||
|
|
@ -79,8 +79,6 @@ describe("baseMixin.js", () => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function getMixInInstance({ isDispatchSuccess = true }) {
|
||||
// Mock Store
|
||||
const storeDispatch = jest.fn();
|
||||
|
|
@ -103,6 +101,9 @@ function getMixInInstance({ isDispatchSuccess = true }) {
|
|||
baseMixIn.methods.$route = route;
|
||||
baseMixIn.methods.storeActions = storeActions;
|
||||
baseMixIn.methods.widgetNames = widgetNames;
|
||||
baseMixin.document = {
|
||||
cookie: ""
|
||||
}
|
||||
|
||||
store.dispatch = storeDispatch;
|
||||
store.commit = jest.fn();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { routerParameterKeys } from '@/router/router-constants/router-parameter-
|
|||
import baseMixin from "@/mixins/base-mixin";
|
||||
import eventBus from "@/helpers/event-bus/event-bus";
|
||||
import store from "@/store";
|
||||
import { cookieNames } from "@/constants/cookie-names";
|
||||
import { handleInfoFromHeritageFunnel, saveOrder, } from "@/helpers/heritage-integration-helper";
|
||||
|
||||
// Components
|
||||
import ComponentTest from "@/layouts/component-test/component-test.vue";
|
||||
|
|
@ -159,7 +159,7 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {},
|
|||
// Append page data to the store for the NEXT page, if any. It will be an empty object if none is provided.
|
||||
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
|
||||
|
||||
baseMixin.methods.saveOrder();
|
||||
saveOrder();
|
||||
|
||||
router.push({
|
||||
name: "root",
|
||||
|
|
@ -170,7 +170,7 @@ function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery = {},
|
|||
});
|
||||
} else if (matchingScenarioMap.destinationUrl !== undefined) {
|
||||
if (matchingScenarioMap.shouldNavigateToHeritageFunnel) {
|
||||
baseMixin.methods.saveOrder();
|
||||
saveOrder();
|
||||
}
|
||||
|
||||
navigateToUrl(matchingScenarioMap.destinationUrl, optionalQuery);
|
||||
|
|
@ -259,20 +259,4 @@ function resetDependentState(component) {
|
|||
return component.default.methods.resetDependentState();
|
||||
}
|
||||
|
||||
// Read info from heritage funnel and reset state or load referral
|
||||
function handleInfoFromHeritageFunnel() {
|
||||
var orderInfoJson = baseMixin.methods.getCookieValue(cookieNames.ORDER_INFO);
|
||||
var orderInfo = orderInfoJson == null ? null : JSON.parse(orderInfoJson);
|
||||
|
||||
if (orderInfo?.ShouldResetState) {
|
||||
store.dispatch(storeActions.RESET_STATE);
|
||||
}
|
||||
else if (orderInfo != null) {
|
||||
// should load referral here
|
||||
}
|
||||
|
||||
// Delete cookie once state is loaded or reset
|
||||
baseMixin.methods.deleteCookie(cookieNames.ORDER_INFO);
|
||||
}
|
||||
|
||||
export default router;
|
||||
Loading…
Reference in a new issue