Merge pull request #317 from Safelite/feature/CSR-98

Feature/csr 98
This commit is contained in:
katieoh-safelite 2022-04-05 11:16:58 -04:00 committed by GitHub
commit 53762de3be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 22 deletions

View file

@ -3,7 +3,8 @@ const applicationConfig = {
CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY,
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
ANALYTICS_SESSION_TIMEOUT_MINUTES: 30,
SAVED_SESSION_TIMEOUT_DAYS: 45
SAVED_SESSION_TIMEOUT_DAYS: 45,
COOKIE_PATH: "/"
};
export { applicationConfig };

View file

@ -15,7 +15,6 @@ const storeActions = {
SAVE_ORDER: "saveOrder",
LOAD_ORDER: "loadOrder",
SET_REFERRAL_INFORMATION: "setReferralInformation",
SET_LOAD_ORDER_DATA: "setLoadOrderData",
// DEPENDENCY MUTATIONS
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",

View file

@ -34,7 +34,7 @@ const storeMutations = {
// OTHER MUTATIONS
UPDATE_PAGE_DATA: "updatePageData",
SET_LOAD_FUNNEL_SESSION_INFO: "setLoadOrderInformation"
SET_LOAD_FUNNEL_SESSION_INFO: "updateStateWithOrderInformation"
};

View file

@ -1,12 +1,13 @@
import { cookieNames } from "@/constants/cookie-names";
import store from "@/store";
import { applicationConfig } from "@/constants/application-config";
/*
Will update the cookie if present, or create a new one if not.
*/
export function updateOrCreateFunnelCookie() {
// Create the cookie
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=/; ${getCookieDomainValue()};`;
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`;
// Set up cookie with all the props.
setFunnelCookieProperties({
@ -18,7 +19,6 @@ export function updateOrCreateFunnelCookie() {
ReferralDate: store.getters.order.referralDate,
ReferralCorrelationId: store.getters.order.referralCorrelationId,
});
}
/*
@ -42,8 +42,7 @@ export function getFunnelCookie() {
Removes cookie from browser.
*/
export function deleteFunnelCookie() {
console.log("hi there")
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=/; ${getCookieDomainValue()}`;
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()}`;
}
/*
@ -61,7 +60,7 @@ function setFunnelCookieProperties(properties) {
const cookieValueJson = JSON.stringify(cookie);
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=/; ${getCookieDomainValue()}`;
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()}`;
}
}
}

View file

@ -43,10 +43,10 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
return 'vehicle-damage'
} else {
if (store.getters.vehicle.vin) {
return 'vehicle-damage';
return 'heritage';
//return "vin-lookup"; (uncomment)
} else {
return 'vehicle-damage';
return 'heritage';
//return "estimate" (uncomment)
}
}
@ -58,7 +58,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
*/
export async function navigateToHeritageFunnel() {
// Create the order (or save existing order) when navigating to Heritage Funnel.
await saveOrder();
@ -67,6 +66,9 @@ export async function navigateToHeritageFunnel() {
{
corid: store.getters.order.referralCorrelationId,
src: "concept-funnel",
// TODO CSR-28, remove this
cns: "all",
experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=NoShowPackages_CONTROL=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
}
);
}

View file

@ -229,7 +229,7 @@ describe("getPageToRouteExistingOrderTo", () => {
//Assert
//expect(result).toBe('vin-lookup');
expect(result).toBe('vehicle-damage');
expect(result).toBe('heritage');
});
test("getPageToRouteExistingOrderTo, should return estimate", async () => {
@ -285,7 +285,7 @@ describe("getPageToRouteExistingOrderTo", () => {
//Assert
//expect(result).toBe('estimate');
expect(result).toBe('vehicle-damage');
expect(result).toBe('heritage');
});
test("getPageToRouteExistingOrderTo, existing order, should return heritage", async () => {

View file

@ -10,8 +10,7 @@ import baseMixin from "@/mixins/base-mixin";
*/
export async function loadOrderIfPresent() {
const funnelCookie = getFunnelCookie();
console.log(funnelCookie)
// Do nothing if there is no cookie or no correlation id.
if (funnelCookie == null || funnelCookie.ReferralCorrelationId == null) {
return null;
@ -21,7 +20,6 @@ export async function loadOrderIfPresent() {
if (funnelCookie.ShouldResetState) {
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE);
deleteFunnelCookie();
console.log("sup")
return null;
}

View file

@ -154,7 +154,6 @@ export default {
methods: {
arePagePrerequisitesValid() {
// Check if isRepair is populated and if the pageData we need is here (Parts data)
console.log(store.getters.pageData(fmgPageValues.VEHICLE_PARTS))
if (
(store.getters.damage.isRepair != null) &&
Object.keys(store.getters.pageData(fmgPageValues.VEHICLE_PARTS))

View file

@ -45,8 +45,7 @@ const routes = [
await GoToFunnelStartOn404(next);
}
// Process funnel cookie.
updateOrCreateFunnelCookie();
// On entering the funnel "fresh", read cookie information, decide what to do next.
if (from.redirectedFrom === undefined) {
@ -64,6 +63,9 @@ const routes = [
to.query.fmgPage = pageToRedirectTo;
}
// Process funnel cookie.
updateOrCreateFunnelCookie();
// If we already have our route, go to it.
if (router.hasRoute(to.query.fmgPage)) {
// Since our route is already in scope, we can grab the component from it and call the arePagePrerequisitesValid function.

View file

@ -169,7 +169,7 @@ export const mutations = {
},
// Misc Mutations
setLoadOrderInformation(state, orderInformation) {
updateStateWithOrderInformation(state, orderInformation) {
state.order.referralNumber = orderInformation.referralNumber;
state.order.referralDate = orderInformation.referralDate;
state.order.referralCorrelationId = orderInformation.referralCorrelationId;
@ -189,6 +189,7 @@ export const mutations = {
state.order.damage.numberOfChips = orderInformation.numberOfChips;
state.order.lineItems.glassParts = orderInformation.parts;
state.order.parentAccountNumber = orderInformation.parentAccountNumber;
state.order.serviceLocation.zipCode = orderInformation.zipCode; // TODO CSR-416 Make sure this is correct
}
}
@ -374,6 +375,7 @@ export const actions = {
style: vehicle.style,
},
numberOfChips: damage.numberOfChips,
zipCode: 43215, // TODO CSR-416, should not be hardcoded (state.order.serviceLocation.zipCode)
glassToReplace: damage.glassToReplace,
referralNumber: context.state.order.referralNumber,
referralDate: context.state.order.referralDate

View file

@ -200,12 +200,12 @@ describe("Mutations", () => {
expect(storeState.applicationUser.pageData['vehicle-year']).toEqual({});
});
it("setLoadOrderInformation, should set order information in state", () => {
it("updateStateWithOrderInformation, should set order information in state", () => {
// Arrange
const storeState = state;
// Act
mutations.setLoadOrderInformation(storeState, {
mutations.updateStateWithOrderInformation(storeState, {
referralNumber: 123,
referralDate: new Date().toUTCString(),
referralCorrelationId: "xxx-xxx-xxx",