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
|
||||
} from "@/helpers/heritage-integration/navigation-helper";
|
||||
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 { externalUrls } from "@/router/router-constants/externalUrl-values";
|
||||
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 { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||
import { issPageValues } from "@/router/router-constants/issPage-values";
|
||||
|
|
@ -42,7 +41,6 @@ export function getMountOptions(mockData) {
|
|||
|
||||
|
||||
// Mock const files
|
||||
mocks.storeActions = storeActions;
|
||||
mocks.navigationScenarios = navigationScenarios;
|
||||
mocks.vehicleCategories = vehicleCategories;
|
||||
mocks.issPageValues = issPageValues;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
import {
|
||||
setCookieProperties,
|
||||
getDeviceIdValue,
|
||||
|
|
@ -17,10 +16,7 @@ import {
|
|||
} from "@/constants/analytics";
|
||||
import { cookieNames } from "@/constants/cookie-names";
|
||||
import { useMainStore } from "@/store";
|
||||
import { mapStores } from "pinia";
|
||||
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
|
||||
import { mapStores, storeToRefs } from "pinia";
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
|
|
@ -37,7 +33,7 @@ export default {
|
|||
experimentsForUser: useMainStore().applicationUser.experiments,
|
||||
};
|
||||
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.LOG_PAGE_VIEW, payload, false);
|
||||
useMainStore().logPageView(payload);
|
||||
},
|
||||
|
||||
logCustomEvent(category, action, label, value) {
|
||||
|
|
@ -56,7 +52,7 @@ export default {
|
|||
experimentsForUser: useMainStore().applicationUser.experiments,
|
||||
};
|
||||
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
|
||||
useMainStore().logCustomEvent(payload);
|
||||
},
|
||||
|
||||
pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {
|
||||
|
|
@ -138,11 +134,7 @@ export default {
|
|||
referrer: document.referrer,
|
||||
};
|
||||
|
||||
const response = await baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.INITIALIZE_SESSION,
|
||||
payload,
|
||||
false
|
||||
);
|
||||
const response = await useMainStore().initializeSession(payload);
|
||||
|
||||
if (response.data) {
|
||||
if (response.data.sessionKey && skey === 0) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||
import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import {
|
||||
analyticsPageEvents,
|
||||
GaCategories,
|
||||
|
|
@ -17,11 +16,6 @@ describe("analyticsMixin.js", () => {
|
|||
const payload = {};
|
||||
|
||||
const mockData = {
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.LOG_PAGE_VIEW,
|
||||
},
|
||||
],
|
||||
};
|
||||
const mocks = setupMocksForJsFiles(mockData);
|
||||
|
||||
|
|
@ -31,36 +25,24 @@ describe("analyticsMixin.js", () => {
|
|||
|
||||
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", () => {
|
||||
const mockData = {
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.LOG_CUSTOM_EVENT,
|
||||
},
|
||||
],
|
||||
};
|
||||
const 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", () => {
|
||||
// Arrange
|
||||
window.dataLayer = [];
|
||||
const mockData = {
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.LOG_CUSTOM_EVENT,
|
||||
},
|
||||
],
|
||||
};
|
||||
const mockData = {};
|
||||
const mocks = setupMocksForJsFiles(mockData);
|
||||
var mockDataLayer = [];
|
||||
mockDataLayer.push({
|
||||
|
|
@ -77,7 +59,7 @@ describe("analyticsMixin.js", () => {
|
|||
|
||||
// Assert
|
||||
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", () => {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
import { mapActions, mapStores } from "pinia";
|
||||
import { useMainStore } from "@/store";
|
||||
|
||||
import { storeActions } from "@/constants/store-actions.js";
|
||||
;
|
||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
|
|
@ -40,9 +39,6 @@ export default {
|
|||
// store will be accessible globally as its id + 'Store'
|
||||
//...mapStores(useMainStore),
|
||||
|
||||
storeActions() {
|
||||
return storeActions;
|
||||
},
|
||||
navigationScenarios() {
|
||||
return navigationScenarios;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue