CSR-98 Fix tests
This commit is contained in:
parent
d6e935a2d8
commit
1e40e0e1f8
3 changed files with 12 additions and 26 deletions
|
|
@ -6,7 +6,7 @@ import store from "@/store";
|
||||||
*/
|
*/
|
||||||
export function updateOrCreateFunnelCookie() {
|
export function updateOrCreateFunnelCookie() {
|
||||||
// Create the cookie
|
// Create the cookie
|
||||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; domain=${getDomainWithoutSubdomain()}; path=/;`;
|
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=/; ${getCookieDomainValue()};`;
|
||||||
|
|
||||||
// Set up cookie with all the props.
|
// Set up cookie with all the props.
|
||||||
setFunnelCookieProperties({
|
setFunnelCookieProperties({
|
||||||
|
|
@ -46,7 +46,7 @@ export function getFunnelCookie() {
|
||||||
Removes cookie from browser.
|
Removes cookie from browser.
|
||||||
*/
|
*/
|
||||||
export function deleteFunnelCookie() {
|
export function deleteFunnelCookie() {
|
||||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; domain=${getDomainWithoutSubdomain()}; path=/`;
|
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=/; ${getCookieDomainValue()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -64,11 +64,15 @@ function setFunnelCookieProperties(properties) {
|
||||||
|
|
||||||
const cookieValueJson = JSON.stringify(cookie);
|
const cookieValueJson = JSON.stringify(cookie);
|
||||||
|
|
||||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; domain=${getDomainWithoutSubdomain()}; path=/`;
|
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=/; ${getCookieDomainValue()}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCookieDomainValue() {
|
||||||
|
return location.hostname.includes("localhost") ? "" : `domain=${getDomainWithoutSubdomain()};`;
|
||||||
|
}
|
||||||
|
|
||||||
function getDomainWithoutSubdomain() {
|
function getDomainWithoutSubdomain() {
|
||||||
let url = location.hostname;
|
let url = location.hostname;
|
||||||
if (url == "localhost") {
|
if (url == "localhost") {
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ describe("saveOrder", () => {
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.only("saveOrder => should update DidHeritageFunnelUpdateLast cookie value to false", async () => {
|
test("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";
|
||||||
|
|
@ -160,8 +160,6 @@ describe("saveOrder", () => {
|
||||||
|
|
||||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||||
|
|
||||||
console.log(document.cookie)
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await saveOrder();
|
await saveOrder();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||||
import { cookieNames } from "@/constants/cookie-names";
|
import { cookieNames } from "@/constants/cookie-names";
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
import baseMixin from "@/mixins/base-mixin";
|
||||||
|
import { getCookieDomainValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
|
|
||||||
// Common methods
|
// Common methods
|
||||||
export function getMountOptions(mockData) {
|
export function getMountOptions(mockData) {
|
||||||
|
|
@ -62,8 +63,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;domain=${getDomainWithoutSubdomain()};`;
|
document.cookie = `${key}=;Max-Age=0;`;
|
||||||
document.cookie = `${key}=;Max-Age=0;domain=${getDomainWithoutSubdomain()};path=/`;
|
document.cookie = `${key}=;Max-Age=0;path=/;${getCookieDomainValue()}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,10 +80,8 @@ export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = t
|
||||||
Object.keys(cookies).forEach(key => {
|
Object.keys(cookies).forEach(key => {
|
||||||
const cookieValue = key == cookieNames.FUNNEL_SESSION_INFO ? funnelCookieValue : cookies[key];
|
const cookieValue = key == cookieNames.FUNNEL_SESSION_INFO ? funnelCookieValue : cookies[key];
|
||||||
if (includeHeritageCookie || key != cookieNames.FUNNEL_SESSION_INFO)
|
if (includeHeritageCookie || key != cookieNames.FUNNEL_SESSION_INFO)
|
||||||
document.cookie = `${key}=${cookieValue}; domain=${getDomainWithoutSubdomain()}; path=/;`;
|
document.cookie = `${key}=${cookieValue}; path=/; ${getCookieDomainValue()}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(document.cookie)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
|
|
@ -101,19 +100,4 @@ 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('.')}`;
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue