CSR-98 Use correct domain in cookie
This commit is contained in:
parent
87820950ae
commit
e24f61e5f1
6 changed files with 58 additions and 18 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
const applicationConfig = {
|
const applicationConfig = {
|
||||||
CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY,
|
CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY,
|
||||||
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
|
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
|
||||||
ANALYTICS_SESSION_TIMEOUT: 30,
|
ANALYTICS_SESSION_TIMEOUT: 30, SAVED_SESSION_TIMEOUT: 45,
|
||||||
SAVED_SESSION_TIMEOUT: 45
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export { applicationConfig };
|
export { applicationConfig };
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { cookieNames } from "@/constants/cookie-names";
|
import { cookieNames } from "@/constants/cookie-names";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Will update the cookie if present, or create a new one if not.
|
Will update the cookie if present, or create a new one if not.
|
||||||
*/
|
*/
|
||||||
|
|
@ -17,7 +16,7 @@ export function updateOrCreateConceptCookie() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the cookie
|
// Create the cookie
|
||||||
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}={}; path=/`;
|
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}={}; domain=${getDomainWithoutSubdomain()}; path=/;`;
|
||||||
|
|
||||||
// Set up cookie with all the props.
|
// Set up cookie with all the props.
|
||||||
setConceptCookieProperties({
|
setConceptCookieProperties({
|
||||||
|
|
@ -37,11 +36,15 @@ export function updateOrCreateConceptCookie() {
|
||||||
Returns null if cookie isn't valid JSON.
|
Returns null if cookie isn't valid JSON.
|
||||||
*/
|
*/
|
||||||
export function getConceptCookie() {
|
export function getConceptCookie() {
|
||||||
|
console.log("getConceptCookie")
|
||||||
|
console.log(document.cookie)
|
||||||
|
console.log(location.hostname)
|
||||||
|
console.log(getDomainWithoutSubdomain())
|
||||||
const cookieJson = document.cookie
|
const cookieJson = document.cookie
|
||||||
?.split("; ")
|
?.split("; ")
|
||||||
?.find(row => row.startsWith(`${cookieNames.CONCEPT_SESSION_INFO}=`))
|
?.find(row => row.startsWith(`${cookieNames.CONCEPT_SESSION_INFO}=`))
|
||||||
?.split("=")[1];
|
?.split("=")[1];
|
||||||
|
console.log(cookieJson)
|
||||||
try {
|
try {
|
||||||
return JSON.parse(cookieJson);
|
return JSON.parse(cookieJson);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -53,7 +56,7 @@ export function getConceptCookie() {
|
||||||
Removes concept cookie from browser.
|
Removes concept cookie from browser.
|
||||||
*/
|
*/
|
||||||
export function deleteConceptCookie() {
|
export function deleteConceptCookie() {
|
||||||
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=; Max-Age=0; path=/; domain=${location.hostname}`;
|
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=; Max-Age=0; domain=${getDomainWithoutSubdomain()}; path=/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -71,8 +74,21 @@ function setConceptCookieProperties(properties) {
|
||||||
|
|
||||||
const cookieValueJson = JSON.stringify(cookie);
|
const cookieValueJson = JSON.stringify(cookie);
|
||||||
|
|
||||||
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=${cookieValueJson}; path=/`;
|
document.cookie = `${cookieNames.CONCEPT_SESSION_INFO}=${cookieValueJson}; domain=${getDomainWithoutSubdomain()}; path=/`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDomainWithoutSubdomain() {
|
||||||
|
let url = location.hostname;
|
||||||
|
if (url == "localhost") {
|
||||||
|
return "localhost";
|
||||||
|
}
|
||||||
|
|
||||||
|
const urlParts = url.split('.');
|
||||||
|
|
||||||
|
return `.${urlParts
|
||||||
|
.slice(0)
|
||||||
|
.slice(-(urlParts.length === 4 ? 3 : 2))
|
||||||
|
.join('.')}`;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
import {saveOrder} from "@/helpers/heritage-integration/order-helper.js";
|
import { saveOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
|
||||||
|
|
@ -45,9 +45,11 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
|
||||||
return 'vehicle-damage'
|
return 'vehicle-damage'
|
||||||
} else {
|
} else {
|
||||||
if (store.getters.vehicle.vin) {
|
if (store.getters.vehicle.vin) {
|
||||||
return "vin-lookup";
|
return "vehicle-damage";
|
||||||
|
// return "vin-lookup";
|
||||||
} else {
|
} else {
|
||||||
return "estimate"
|
return "vehicle-damage";
|
||||||
|
// return "estimate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +69,9 @@ export async function navigateToHeritageFunnel() {
|
||||||
{
|
{
|
||||||
corid: store.getters.order.referralCorrelationId,
|
corid: store.getters.order.referralCorrelationId,
|
||||||
src: "concept-funnel",
|
src: "concept-funnel",
|
||||||
|
// TODO CSR-28, remove this
|
||||||
|
cns: "all",
|
||||||
|
experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=ServAreaNoRemove_V7_TEST=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ describe("loadOrderIfPresent", () => {
|
||||||
ShouldResetState: testShouldResetState
|
ShouldResetState: testShouldResetState
|
||||||
}
|
}
|
||||||
|
|
||||||
document.cookie = `${cookieNames.ORDER_INFO}=${JSON.stringify(testCookieValue)}; path=/; domain=${location.hostname}`;
|
document.cookie = `${cookieNames.ORDER_INFO}=${JSON.stringify(testCookieValue)}; path=/; domain=.safelite.com`;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
loadOrderIfPresent();
|
loadOrderIfPresent();
|
||||||
|
|
@ -74,7 +74,6 @@ describe("loadOrderIfPresent", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("saveOrder", () => {
|
describe("saveOrder", () => {
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
removeAllTestCookies();
|
removeAllTestCookies();
|
||||||
});
|
});
|
||||||
|
|
@ -113,7 +112,7 @@ describe("saveOrder", () => {
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("saveOrder => should update DidHeritageFunnelUpdateLast cookie value to false", async () => {
|
test.only("saveOrder => should update DidHeritageFunnelUpdateLast cookie value to false", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testReferralNumber = 1566818;
|
const testReferralNumber = 1566818;
|
||||||
const testReferralDate = "2022-03-15T10:56:24.597";
|
const testReferralDate = "2022-03-15T10:56:24.597";
|
||||||
|
|
@ -139,8 +138,12 @@ describe("saveOrder", () => {
|
||||||
DidHeritageFunnelUpdateLast: true
|
DidHeritageFunnelUpdateLast: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("A")
|
||||||
|
console.log(location.hostname)
|
||||||
setupCookies({ conceptCookieValue: JSON.stringify(testCookieValue) });
|
setupCookies({ conceptCookieValue: JSON.stringify(testCookieValue) });
|
||||||
|
|
||||||
|
console.log(document.cookie)
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await saveOrder();
|
await saveOrder();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,8 @@ export const cookies = {
|
||||||
|
|
||||||
export function removeAllTestCookies() {
|
export function removeAllTestCookies() {
|
||||||
Object.keys(cookies).forEach(key => {
|
Object.keys(cookies).forEach(key => {
|
||||||
document.cookie = `${key}=;Max-Age=0;`;
|
document.cookie = `${key}=;Max-Age=0;domain=${getDomainWithoutSubdomain()};`;
|
||||||
document.cookie = `${key}=;Max-Age=0;path=/`;
|
document.cookie = `${key}=;Max-Age=0;domain=${getDomainWithoutSubdomain()};path=/`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,10 +78,11 @@ export function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockRefe
|
||||||
export function setupCookies({ conceptCookieValue = "", includeHeritageCookie = true }) {
|
export function setupCookies({ conceptCookieValue = "", includeHeritageCookie = true }) {
|
||||||
Object.keys(cookies).forEach(key => {
|
Object.keys(cookies).forEach(key => {
|
||||||
const cookieValue = key == cookieNames.CONCEPT_SESSION_INFO ? conceptCookieValue : cookies[key];
|
const cookieValue = key == cookieNames.CONCEPT_SESSION_INFO ? conceptCookieValue : cookies[key];
|
||||||
|
|
||||||
if (includeHeritageCookie || key != cookieNames.CONCEPT_SESSION_INFO)
|
if (includeHeritageCookie || key != cookieNames.CONCEPT_SESSION_INFO)
|
||||||
document.cookie = `${key}=${cookieValue}; path=/;`;
|
document.cookie = `${key}=${cookieValue}; domain=${getDomainWithoutSubdomain()}; path=/;`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(document.cookie)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
|
|
@ -100,4 +101,19 @@ function setupBaseMixinDispatchNonBlockingStoreAction(mockData) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getDomainWithoutSubdomain() {
|
||||||
|
let url = location.hostname;
|
||||||
|
if (url == "localhost") {
|
||||||
|
return "localhost";
|
||||||
|
}
|
||||||
|
|
||||||
|
const urlParts = url.split('.');
|
||||||
|
|
||||||
|
return `.${urlParts
|
||||||
|
.slice(0)
|
||||||
|
.slice(-(urlParts.length === 4 ? 3 : 2))
|
||||||
|
.join('.')}`;
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,6 @@ process.env.VUE_APP_CONSUMER_API_GATEWAY =
|
||||||
"https://consumerapidev.safelite.com";
|
"https://consumerapidev.safelite.com";
|
||||||
process.env.VUE_APP_HERITAGE_FUNNEL =
|
process.env.VUE_APP_HERITAGE_FUNNEL =
|
||||||
"http://localhost:38000/default.aspx";
|
"http://localhost:38000/default.aspx";
|
||||||
|
|
||||||
process.env.VUE_APP_GOOGLE_PLACES_API_KEY =
|
process.env.VUE_APP_GOOGLE_PLACES_API_KEY =
|
||||||
"AIzaSyDptGCkOPgN2uWJOy4ou4M33phRD4MAoJo"
|
"AIzaSyDptGCkOPgN2uWJOy4ou4M33phRD4MAoJo"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue