Merge pull request #650 from Safelite/feature/CSR-514

Feature/csr 514
This commit is contained in:
katieoh-safelite 2022-08-12 13:48:03 -04:00 committed by GitHub
commit db0c5de20f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 44 deletions

View file

@ -37,8 +37,6 @@ const routes = [
return next(false);
}
runExperiments(to.query.fmgPage);
// If the saved session has timed out, clear the session, execute 404 logic.
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
@ -64,6 +62,8 @@ const routes = [
to.query.fmgPage = pageToRedirectTo;
}
runExperiments(to.query.fmgPage);
// Process funnel cookie.
updateOrCreateFunnelCookie();
@ -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(),

View file

@ -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);
}

View file

@ -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;