CSR-18 specs
This commit is contained in:
parent
da748b95fd
commit
c71056db22
6 changed files with 54 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import {getFunnelCookie, getDeviceIdValue, getSessionKeyValue} from "@/helpers/heritage-integration/cookie-helper.js";
|
import {getFunnelCookie, getDeviceIdValue, getSessionKeyValue, getSessionIdValue} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||||
import { removeAllTestCookies, setupCookies } from "@/helpers/unit-test-helper";
|
import { removeAllTestCookies, setupCookies } from "@/helpers/unit-test-helper";
|
||||||
|
|
||||||
describe("cookies", () => {
|
describe("cookies", () => {
|
||||||
|
|
@ -126,5 +126,19 @@ describe("cookies", () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getSessionIdValue", () => {
|
||||||
|
test("getSessionIdValue, should return GUID", () => {
|
||||||
|
// Arrange
|
||||||
|
setupCookies({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = getSessionIdValue();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe('cba0c3d1-3c1b-4305-bb56-31aa50f58e27');
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -62,6 +62,7 @@ export const cookies = {
|
||||||
"anotherCookie": "{}",
|
"anotherCookie": "{}",
|
||||||
"someOtherCookie": "{}",
|
"someOtherCookie": "{}",
|
||||||
"dxdev": "did=21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe",
|
"dxdev": "did=21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe",
|
||||||
|
"sid": "cba0c3d1-3c1b-4305-bb56-31aa50f58e27",
|
||||||
"skey": "12345"
|
"skey": "12345"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import ComponentTest from "@/layouts/component-test/component-test.vue";
|
||||||
import FormTest from "@/layouts/form-test/form-test.vue";
|
import FormTest from "@/layouts/form-test/form-test.vue";
|
||||||
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
import { analyticsPageEvents } from "./router-constants/analytics-page-events";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +79,7 @@ const routes = [
|
||||||
await GoToFunnelStartOn404(next);
|
await GoToFunnelStartOn404(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
logPageEvent(to.query.fmgPage);
|
// logPageEvent(to.query.fmgPage, analyticsPageEvents.ENTRY);
|
||||||
return next({ name: to.query.fmgPage, query: to.query, params: to.params });
|
return next({ name: to.query.fmgPage, query: to.query, params: to.params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +101,7 @@ const routes = [
|
||||||
await GoToFunnelStartOn404(next);
|
await GoToFunnelStartOn404(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
logPageEvent(to.query.fmgPage);
|
// logPageEvent(to.query.fmgPage, analyticsPageEvents.ENTRY);
|
||||||
|
|
||||||
// Assign current query string parameters, as well as our fmgPage one.
|
// Assign current query string parameters, as well as our fmgPage one.
|
||||||
next({
|
next({
|
||||||
|
|
@ -127,6 +128,7 @@ const router = createRouter({
|
||||||
|
|
||||||
router.afterEach((to, from) => {
|
router.afterEach((to, from) => {
|
||||||
baseMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
|
baseMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
|
||||||
|
logPageEvent(to.query[queryStrings.FMG_PAGE], analyticsPageEvents.ENTRY);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
||||||
|
|
@ -273,7 +275,7 @@ function resetDependentState(component) {
|
||||||
return component.default.methods.resetDependentState();
|
return component.default.methods.resetDependentState();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logPageEvent(destinationFmgPageValue){
|
async function logPageEvent(destinationFmgPageValue, pageEvent){
|
||||||
const logActivityPromise = baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY,
|
const logActivityPromise = baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY,
|
||||||
{
|
{
|
||||||
userId: getDeviceIdValue(),
|
userId: getDeviceIdValue(),
|
||||||
|
|
@ -283,7 +285,7 @@ async function logPageEvent(destinationFmgPageValue){
|
||||||
shouldUseSessionId: true,
|
shouldUseSessionId: true,
|
||||||
pageEvent: {
|
pageEvent: {
|
||||||
action: '',
|
action: '',
|
||||||
event: 'ENTRY',
|
event: pageEvent,
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
|
||||||
5
src/router/router-constants/analytics-page-events.js
Normal file
5
src/router/router-constants/analytics-page-events.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
const analyticsPageEvents = {
|
||||||
|
ENTRY: "ENTRY",
|
||||||
|
};
|
||||||
|
|
||||||
|
export { analyticsPageEvents };
|
||||||
|
|
@ -433,7 +433,7 @@ export const actions = {
|
||||||
sessionKey: sessionKey,
|
sessionKey: sessionKey,
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
pageName: pageName,
|
pageName: pageName,
|
||||||
applicationName: 'SafeliteContent',
|
applicationName: 'SafeliteDotCom',
|
||||||
shouldUseSessionId: shouldUseSessionId,
|
shouldUseSessionId: shouldUseSessionId,
|
||||||
pageEvent: {
|
pageEvent: {
|
||||||
action: pageEvent.action,
|
action: pageEvent.action,
|
||||||
|
|
|
||||||
|
|
@ -617,6 +617,32 @@ describe("Actions", () => {
|
||||||
expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx");
|
expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("logActivity action, should return nothing", async () => {
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const context = state;
|
||||||
|
var pageEvent = {
|
||||||
|
action: "",
|
||||||
|
event: "ENTRY",
|
||||||
|
}
|
||||||
|
|
||||||
|
var customEvent = [{
|
||||||
|
category: "tstCat",
|
||||||
|
action: "click",
|
||||||
|
label: "damage",
|
||||||
|
value: "psych"
|
||||||
|
}];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
globalMethods.callHttpClient.mockImplementation(() => {
|
||||||
|
return Promise.resolve({ });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
const response = await actions.logActivity(context, { userId: "userId", sessionKey: "sessionKey", pageName: "pageName", sessionId: "sessionId", pageEvent: pageEvent, customEvent: customEvent, shouldUseSessionId: true });
|
||||||
|
expect(response).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Getters", () => {
|
describe("Getters", () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue