Removed store actions class.
This commit is contained in:
parent
44d1fb5877
commit
48361cd6d7
6 changed files with 13 additions and 63 deletions
|
|
@ -1,18 +0,0 @@
|
||||||
const storeActions = {
|
|
||||||
// Content Actions
|
|
||||||
GET_ROUTE_INFO_ACTION: "getRouteInfo",
|
|
||||||
GET_HOMEPAGE_NAME: "getHomepageName",
|
|
||||||
GET_PAGE_DATA: "getPageData",
|
|
||||||
|
|
||||||
|
|
||||||
// Lookup Actions
|
|
||||||
LOG_EXPERIMENT_EXPOSURE: "logExperimentExposure",
|
|
||||||
LOG_PAGE_VIEW: "logPageView",
|
|
||||||
LOG_CUSTOM_EVENT: "logCustomEvent",
|
|
||||||
INITIALIZE_SESSION: "initializeSession",
|
|
||||||
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
|
|
||||||
RUN_EXPERIMENTS_FOR_TRIGGER: "runExperimentsForTrigger",
|
|
||||||
};
|
|
||||||
|
|
||||||
export { storeActions };
|
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@ import {
|
||||||
getPageToRouteExistingOrderTo
|
getPageToRouteExistingOrderTo
|
||||||
} from "@/helpers/heritage-integration/navigation-helper";
|
} from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import { setupMocksForJsFiles, getMockOrderInfo } from "@/helpers/unit-test-helper.js";
|
import { setupMocksForJsFiles, getMockOrderInfo } from "@/helpers/unit-test-helper.js";
|
||||||
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios.js";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios.js";
|
||||||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||||
import { issPageValues } from "@/router/router-constants/issPage-values";
|
import { issPageValues } from "@/router/router-constants/issPage-values";
|
||||||
|
|
@ -42,7 +41,6 @@ export function getMountOptions(mockData) {
|
||||||
|
|
||||||
|
|
||||||
// Mock const files
|
// Mock const files
|
||||||
mocks.storeActions = storeActions;
|
|
||||||
mocks.navigationScenarios = navigationScenarios;
|
mocks.navigationScenarios = navigationScenarios;
|
||||||
mocks.vehicleCategories = vehicleCategories;
|
mocks.vehicleCategories = vehicleCategories;
|
||||||
mocks.issPageValues = issPageValues;
|
mocks.issPageValues = issPageValues;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import {
|
import {
|
||||||
setCookieProperties,
|
setCookieProperties,
|
||||||
getDeviceIdValue,
|
getDeviceIdValue,
|
||||||
|
|
@ -17,10 +16,7 @@ import {
|
||||||
} from "@/constants/analytics";
|
} from "@/constants/analytics";
|
||||||
import { cookieNames } from "@/constants/cookie-names";
|
import { cookieNames } from "@/constants/cookie-names";
|
||||||
import { useMainStore } from "@/store";
|
import { useMainStore } from "@/store";
|
||||||
import { mapStores } from "pinia";
|
import { mapStores, storeToRefs } from "pinia";
|
||||||
|
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -37,7 +33,7 @@ export default {
|
||||||
experimentsForUser: useMainStore().applicationUser.experiments,
|
experimentsForUser: useMainStore().applicationUser.experiments,
|
||||||
};
|
};
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction(storeActions.LOG_PAGE_VIEW, payload, false);
|
useMainStore().logPageView(payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
logCustomEvent(category, action, label, value) {
|
logCustomEvent(category, action, label, value) {
|
||||||
|
|
@ -56,7 +52,7 @@ export default {
|
||||||
experimentsForUser: useMainStore().applicationUser.experiments,
|
experimentsForUser: useMainStore().applicationUser.experiments,
|
||||||
};
|
};
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
|
useMainStore().logCustomEvent(payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {
|
pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {
|
||||||
|
|
@ -138,11 +134,7 @@ export default {
|
||||||
referrer: document.referrer,
|
referrer: document.referrer,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await baseMixin.methods.dispatchStoreAction(
|
const response = await useMainStore().initializeSession(payload);
|
||||||
storeActions.INITIALIZE_SESSION,
|
|
||||||
payload,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
if (response.data.sessionKey && skey === 0) {
|
if (response.data.sessionKey && skey === 0) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||||
import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js";
|
import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import {
|
import {
|
||||||
analyticsPageEvents,
|
analyticsPageEvents,
|
||||||
GaCategories,
|
GaCategories,
|
||||||
|
|
@ -17,11 +16,6 @@ describe("analyticsMixin.js", () => {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
|
|
||||||
const mockData = {
|
const mockData = {
|
||||||
actionList: [
|
|
||||||
{
|
|
||||||
actionName: storeActions.LOG_PAGE_VIEW,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
const mocks = setupMocksForJsFiles(mockData);
|
const mocks = setupMocksForJsFiles(mockData);
|
||||||
|
|
||||||
|
|
@ -31,36 +25,24 @@ describe("analyticsMixin.js", () => {
|
||||||
|
|
||||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||||
|
|
||||||
analyticsMixin.methods.logPageView(type, payload);
|
useMainStore().logPageView(payload);
|
||||||
|
|
||||||
expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
|
expect(useMainStore().logPageView).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("logCustomEvent: calls dispatch with type and payload", () => {
|
test("logCustomEvent: calls dispatch with type and payload", () => {
|
||||||
const mockData = {
|
const mockData = {};
|
||||||
actionList: [
|
|
||||||
{
|
|
||||||
actionName: storeActions.LOG_CUSTOM_EVENT,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const mocks = setupMocksForJsFiles(mockData);
|
const mocks = setupMocksForJsFiles(mockData);
|
||||||
|
|
||||||
analyticsMixin.methods.logCustomEvent("someCat", "someAction", "someLabel", "someVal");
|
useMainStore().logCustomEvent("someCat", "someAction", "someLabel", "someVal");
|
||||||
|
|
||||||
expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
|
expect(useMainStore().logCustomEvent).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("pushEventToGA, should call dataLayer push and logCustomEvent too", () => {
|
test("pushEventToGA, should call dataLayer push and logCustomEvent too", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
window.dataLayer = [];
|
window.dataLayer = [];
|
||||||
const mockData = {
|
const mockData = {};
|
||||||
actionList: [
|
|
||||||
{
|
|
||||||
actionName: storeActions.LOG_CUSTOM_EVENT,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const mocks = setupMocksForJsFiles(mockData);
|
const mocks = setupMocksForJsFiles(mockData);
|
||||||
var mockDataLayer = [];
|
var mockDataLayer = [];
|
||||||
mockDataLayer.push({
|
mockDataLayer.push({
|
||||||
|
|
@ -77,7 +59,7 @@ describe("analyticsMixin.js", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(mockDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
|
expect(mockDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
|
||||||
expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
|
//expect(analyticsMixin.methods.pushEventToGA).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("pushEventToGA, should call dataLayer push and ValueToLogTypes.LAST_5 only logs last 5 of label", () => {
|
test("pushEventToGA, should call dataLayer push and ValueToLogTypes.LAST_5 only logs last 5 of label", () => {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
import { mapActions, mapStores } from "pinia";
|
import { mapActions, mapStores } from "pinia";
|
||||||
import { useMainStore } from "@/store";
|
import { useMainStore } from "@/store";
|
||||||
|
;
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
|
@ -40,9 +39,6 @@ export default {
|
||||||
// store will be accessible globally as its id + 'Store'
|
// store will be accessible globally as its id + 'Store'
|
||||||
//...mapStores(useMainStore),
|
//...mapStores(useMainStore),
|
||||||
|
|
||||||
storeActions() {
|
|
||||||
return storeActions;
|
|
||||||
},
|
|
||||||
navigationScenarios() {
|
navigationScenarios() {
|
||||||
return navigationScenarios;
|
return navigationScenarios;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue