Merge pull request #658 from Safelite/feature/CSR-514
CSR-514 Save experiments
This commit is contained in:
commit
b7ced3bdf8
3 changed files with 30 additions and 10 deletions
|
|
@ -6,7 +6,7 @@ const applicationConfig = {
|
|||
SAVED_SESSION_TIMEOUT_DAYS: 45,
|
||||
COOKIE_PATH: "/",
|
||||
CURRENT_ENVIRONMENT: process.env.VUE_APP_CURRENT_ENVIRONMENT, // "Localhost", "Dev", "QA", and "Prod"
|
||||
APPLICATION_NAME: "SafeliteDotCom",
|
||||
APPLICATION_NAME: "FixMyGlass",
|
||||
SITE_ENTRY_TRIGGER_VALUE: "FixMyGlass"
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ export const actions = {
|
|||
});
|
||||
},
|
||||
|
||||
runExperimentsForTrigger(context, { userId, triggerEvent, triggerValue }) {
|
||||
async runExperimentsForTrigger(context, { userId, triggerEvent, triggerValue }) {
|
||||
if (triggerEvent == experimentTriggers.SITE_ENTRY) {
|
||||
context.commit(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true);
|
||||
}
|
||||
|
|
@ -659,11 +659,13 @@ export const actions = {
|
|||
experimentOrder: context.getters.experimentOrder
|
||||
};
|
||||
|
||||
globalMethods.callHttpClient({
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.RunExperimentsForTrigger.method,
|
||||
endpoint: endpoints.RunExperimentsForTrigger.url,
|
||||
payload: payload,
|
||||
});
|
||||
|
||||
context.commit(storeMutations.UPDATE_EXPERIMENTS, response.data.experiments);
|
||||
},
|
||||
|
||||
getEvoxImage(context, { relativeUrl }) {
|
||||
|
|
|
|||
|
|
@ -1091,10 +1091,18 @@ describe("Actions", () => {
|
|||
describe("runExperimentsForTrigger", () => {
|
||||
beforeEach(() => {
|
||||
mutations.resetState(state);
|
||||
globalMethods.callHttpClient = jest.fn();
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue({
|
||||
data: {
|
||||
experiments: [
|
||||
{
|
||||
mockProperty: "mockValue"
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
test("triggerEvent is SiteEntry => set triggeredSiteEntry to true in store", () => {
|
||||
test("triggerEvent is SiteEntry => set triggeredSiteEntry to true in store", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
context.commit = jest.fn().mockImplementation((storeMutation, value) => mutations[storeMutation](context, value));
|
||||
|
|
@ -1104,17 +1112,22 @@ describe("Actions", () => {
|
|||
};
|
||||
|
||||
// Act
|
||||
actions.runExperimentsForTrigger(context, {
|
||||
await actions.runExperimentsForTrigger(context, {
|
||||
triggerEvent: experimentTriggers.SITE_ENTRY,
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(context.commit).toHaveBeenCalledWith(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true);
|
||||
expect(context.commit).toHaveBeenNthCalledWith(1, storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true);
|
||||
expect(context.getters.applicationUser.triggeredSiteEntry).toBe(true);
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
||||
expect(context.commit).toHaveBeenNthCalledWith(2, storeMutations.UPDATE_EXPERIMENTS, [
|
||||
{
|
||||
mockProperty: "mockValue"
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
test("triggerEvent is not SiteEntry => triggeredSiteEntry is false in store", () => {
|
||||
test("triggerEvent is not SiteEntry => triggeredSiteEntry is false in store", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
context.commit = jest.fn().mockImplementation((storeMutation, value) => mutations[storeMutation](context, value));
|
||||
|
|
@ -1125,15 +1138,20 @@ describe("Actions", () => {
|
|||
expect(context.commit).toHaveBeenCalledTimes(0);
|
||||
|
||||
// Act
|
||||
actions.runExperimentsForTrigger(context, {
|
||||
await actions.runExperimentsForTrigger(context, {
|
||||
triggerEvent: "NotSiteEntry",
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(context.commit).not.toHaveBeenCalled();
|
||||
expect(context.commit).not.toHaveBeenCalledWith(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, expect.any);
|
||||
expect(context.getters.applicationUser.triggeredSiteEntry).toBe(false);
|
||||
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledTimes(1);
|
||||
expect(context.commit).toHaveBeenNthCalledWith(1, storeMutations.UPDATE_EXPERIMENTS, [
|
||||
{
|
||||
mockProperty: "mockValue"
|
||||
}
|
||||
]);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue