From 0461a0ef1e1ea4d635dc19b0fa108761d53526e3 Mon Sep 17 00:00:00 2001 From: EmmaLRussell Date: Fri, 27 Oct 2023 15:20:31 +0100 Subject: [PATCH] fix front end tests --- app/static/tests/unit/localStorageManager.test.ts | 8 ++++---- app/static/tests/unit/serialiser.test.ts | 3 ++- app/static/tests/unit/store/sessions/actions.test.ts | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/static/tests/unit/localStorageManager.test.ts b/app/static/tests/unit/localStorageManager.test.ts index a90d1c8ca..6f9281f44 100644 --- a/app/static/tests/unit/localStorageManager.test.ts +++ b/app/static/tests/unit/localStorageManager.test.ts @@ -37,7 +37,7 @@ describe("localStorageManager for sessions", () => { }); it("can add session id when basePath is not empty", () => { - localStorageManager.addSessionId("day1", "testInstance", "session3"); + localStorageManager.addSessionId("day1", "testInstance","session3"); expect(spyOnGetItem).toHaveBeenCalledTimes(1); expect(spyOnSetItem).toHaveBeenCalledTimes(1); expect(spyOnSetItem.mock.calls[0][0]).toBe("testInstance_day1_sessionIds"); @@ -59,7 +59,7 @@ describe("localStorageManager gets and saves user preferences", () => { beforeAll(() => { spyOnGetItem = jest.spyOn(Storage.prototype, "getItem") - .mockReturnValue("{\"showUnlabelledSessions\": false}"); + .mockReturnValue("{\"showUnlabelledSessions\": false, \"showDuplicateSessions\": true}"); spyOnSetItem = jest.spyOn(Storage.prototype, "setItem"); }); @@ -69,7 +69,7 @@ describe("localStorageManager gets and saves user preferences", () => { it("can get user preferences", () => { const result = localStorageManager.getUserPreferences(); - expect(result).toStrictEqual(mockUserPreferences()); + expect(result).toStrictEqual({showUnlabelledSessions: false, showDuplicateSessions: true}); expect(spyOnGetItem).toHaveBeenCalledWith("preferences"); }); @@ -94,7 +94,7 @@ describe("localStorageManager gets default user preferences", () => { it("can get default user preferences", () => { const result = localStorageManager.getUserPreferences(); - expect(result).toStrictEqual({ showUnlabelledSessions: true }); + expect(result).toStrictEqual({ showUnlabelledSessions: true, showDuplicateSessions: false }); expect(spyOnGetItem).toHaveBeenCalledWith("preferences"); }); }); diff --git a/app/static/tests/unit/serialiser.test.ts b/app/static/tests/unit/serialiser.test.ts index fd51d3cda..318603c40 100644 --- a/app/static/tests/unit/serialiser.test.ts +++ b/app/static/tests/unit/serialiser.test.ts @@ -328,7 +328,8 @@ describe("serialise", () => { }; const userPreferences = { - showUnlabelledSessions: true + showUnlabelledSessions: true, + showDuplicateSessions: false }; const basicState: BasicState = { diff --git a/app/static/tests/unit/store/sessions/actions.test.ts b/app/static/tests/unit/store/sessions/actions.test.ts index 5a4221c84..a3c14a2b9 100644 --- a/app/static/tests/unit/store/sessions/actions.test.ts +++ b/app/static/tests/unit/store/sessions/actions.test.ts @@ -251,10 +251,11 @@ describe("SessionsActions", () => { }); it("GetSessions commits error", async () => { - mockAxios.onGet("/apps/test-app/sessions/metadata?sessionIds=123,456") + mockAxios.onGet("/apps/test-app/sessions/metadata?sessionIds=123,456&removeDuplicates=true") .reply(500, mockFailure("TEST ERROR")); - const rootState = mockBasicState({ appName: "test-app", appsPath: "apps" }); + const userPreferences = mockUserPreferences(); + const rootState = mockBasicState({ appName: "test-app", appsPath: "apps", userPreferences }); const commit = jest.fn(); await (actions[SessionsAction.GetSessions] as any)({ commit, rootState, rootGetters });