Fix client unit tests

This commit is contained in:
mvdbeek
2025-05-02 19:37:28 +02:00
parent 4d71d88081
commit b1509ba76d
@@ -1,5 +1,6 @@
import "jest-location-mock";
import { getFakeRegisteredUser } from "@tests/test-data";
import { mount } from "@vue/test-utils";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
@@ -8,6 +9,7 @@ import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
import { ref } from "vue";
import { useServerMock } from "@/api/client/__mocks__";
import toolsList from "@/components/ToolsView/testData/toolsList.json";
import toolsListInPanel from "@/components/ToolsView/testData/toolsListInPanel.json";
import { useUserLocalStorage } from "@/composables/userLocalStorage";
@@ -28,6 +30,7 @@ interface ToolPanelView {
}
const localVue = getLocalVue();
const { server, http } = useServerMock();
const TEST_PANELS_URI = "/api/tool_panels";
const DEFAULT_VIEW_ID = "default";
@@ -90,6 +93,12 @@ describe("ToolPanel", () => {
axiosMock.onGet(/\/api\/tool_panels\/.*/).reply(200, toolsListInPanel);
}
server.use(
http.get("/api/users/{user_id}", ({ response }) => {
return response(200).json(getFakeRegisteredUser());
})
);
// setting this because for the default view, we just show "Tools" as the name
// even though the backend returns "Full Tool Panel"
viewsList[DEFAULT_VIEW_ID]!.name = "Tools";