CSR-514 Add condition back to router
This commit is contained in:
parent
0afa4d815c
commit
febbe96534
3 changed files with 7 additions and 42 deletions
|
|
@ -270,11 +270,13 @@ function arePagePrerequisitesValid(component) {
|
|||
|
||||
// Run SiteEntry and PageEntry triggers for experiments
|
||||
function runExperiments(nextPage) {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, {
|
||||
userId: getDeviceIdValue(),
|
||||
triggerEvent: experimentTriggers.SITE_ENTRY,
|
||||
triggerValue: applicationConfig.SITE_ENTRY_TRIGGER_VALUE
|
||||
})
|
||||
if (!store.getters.applicationUser.triggeredSiteEntry) {
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, {
|
||||
userId: getDeviceIdValue(),
|
||||
triggerEvent: experimentTriggers.SITE_ENTRY,
|
||||
triggerValue: applicationConfig.SITE_ENTRY_TRIGGER_VALUE
|
||||
})
|
||||
}
|
||||
|
||||
baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, {
|
||||
userId: getDeviceIdValue(),
|
||||
|
|
|
|||
|
|
@ -648,11 +648,6 @@ export const actions = {
|
|||
|
||||
runExperimentsForTrigger(context, { userId, triggerEvent, triggerValue }) {
|
||||
if (triggerEvent == experimentTriggers.SITE_ENTRY) {
|
||||
// If site entry event was already triggered, don't rerun experiments
|
||||
if (context.getters.applicationUser.triggeredSiteEntry) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.commit(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1114,38 +1114,6 @@ describe("Actions", () => {
|
|||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("runExperimentsForTrigger is called twice with triggerEvent == SiteEntry => only update store's triggeredSiteEntry value once", () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
context.commit = jest.fn().mockImplementation((storeMutation, value) => mutations[storeMutation](context, value));
|
||||
context.getters = {
|
||||
...getters,
|
||||
applicationUser: getters.applicationUser(context)
|
||||
};
|
||||
expect(context.commit).toHaveBeenCalledTimes(0);
|
||||
|
||||
// Act
|
||||
actions.runExperimentsForTrigger(context, {
|
||||
triggerEvent: experimentTriggers.SITE_ENTRY,
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(context.commit).toHaveBeenCalledTimes(1);
|
||||
expect(context.commit).toHaveBeenCalledWith(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true);
|
||||
expect(context.getters.applicationUser.triggeredSiteEntry).toBe(true);
|
||||
|
||||
// Act
|
||||
actions.runExperimentsForTrigger(context, {
|
||||
triggerEvent: experimentTriggers.SITE_ENTRY,
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(context.commit).toHaveBeenCalledTimes(1);
|
||||
expect(context.getters.applicationUser.triggeredSiteEntry).toBe(true);
|
||||
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("triggerEvent is not SiteEntry => triggeredSiteEntry is false in store", () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
|
|
|
|||
Loading…
Reference in a new issue