diff --git a/client/src/app/app.test.js b/client/src/app/app.test.js index ff8e25eaa868..50664b289345 100644 --- a/client/src/app/app.test.js +++ b/client/src/app/app.test.js @@ -1,6 +1,7 @@ import galaxyOptions from "@tests/test-data/bootstrapped"; import { getGalaxyInstance, setGalaxyInstance } from "app"; import Backbone from "backbone"; +import { suppressDebugConsole } from "tests/jest/helpers"; export function setupTestGalaxy(galaxyOptions_ = null) { galaxyOptions_ = galaxyOptions_ || galaxyOptions; @@ -13,6 +14,10 @@ export function setupTestGalaxy(galaxyOptions_ = null) { }); } +// the app console debugs make sense but we just don't want to see them in test +// output. +suppressDebugConsole(); + describe("App base construction/initializiation defaults", () => { beforeEach(() => { setupTestGalaxy(galaxyOptions); diff --git a/client/src/components/ConfigTemplates/formUtil.ts b/client/src/components/ConfigTemplates/formUtil.ts index b6908259dcf9..6608597a32a6 100644 --- a/client/src/components/ConfigTemplates/formUtil.ts +++ b/client/src/components/ConfigTemplates/formUtil.ts @@ -218,9 +218,7 @@ export function upgradeForm(template: TemplateSummary, instance: Instance): Form } for (const secret of secrets) { const secretName = secret.name; - if (secretsSet.indexOf(secretName) >= 0) { - console.log("skipping..."); - } else { + if (secretsSet.indexOf(secretName) < 0) { form.push(templateSecretFormEntry(secret)); } } diff --git a/client/src/components/Dataset/DatasetStorage/DatasetStorage.test.ts b/client/src/components/Dataset/DatasetStorage/DatasetStorage.test.ts index a1b0b8e384de..9ef1926d5e80 100644 --- a/client/src/components/Dataset/DatasetStorage/DatasetStorage.test.ts +++ b/client/src/components/Dataset/DatasetStorage/DatasetStorage.test.ts @@ -1,6 +1,6 @@ import { shallowMount } from "@vue/test-utils"; import flushPromises from "flush-promises"; -import { getLocalVue } from "tests/jest/helpers"; +import { getLocalVue, suppressDebugConsole } from "tests/jest/helpers"; import { type DatasetStorageDetails } from "@/api"; import { useServerMock } from "@/api/client/__mocks__"; @@ -58,6 +58,7 @@ describe("DatasetStorage.vue", () => { }); it("test error rendering...", async () => { + suppressDebugConsole(); mount({ simulateError: true }); await flushPromises(); expect(wrapper.findAll(".error").length).toBe(1); diff --git a/client/src/components/Form/Elements/FormData/FormData.test.js b/client/src/components/Form/Elements/FormData/FormData.test.js index 709f2910a791..25ed1945588f 100644 --- a/client/src/components/Form/Elements/FormData/FormData.test.js +++ b/client/src/components/Form/Elements/FormData/FormData.test.js @@ -1,3 +1,5 @@ +import "tests/jest/mockHelpPopovers"; + import { createTestingPinia } from "@pinia/testing"; import { mount } from "@vue/test-utils"; import { PiniaVuePlugin } from "pinia"; diff --git a/client/src/components/Grid/GridList.test.js b/client/src/components/Grid/GridList.test.js index 0a2668c74687..3abe0006a669 100644 --- a/client/src/components/Grid/GridList.test.js +++ b/client/src/components/Grid/GridList.test.js @@ -3,8 +3,8 @@ import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { PiniaVuePlugin } from "pinia"; import { getLocalVue } from "tests/jest/helpers"; +import { setupMockConfig } from "tests/jest/mockConfig"; -import { useConfig } from "@/composables/config"; import Filtering from "@/utils/filtering"; import MountTarget from "./GridList.vue"; @@ -12,15 +12,8 @@ import MountTarget from "./GridList.vue"; jest.useFakeTimers(); jest.mock("composables/config"); -useConfig.mockReturnValue({ - config: { - value: { - disabled: false, - enabled: true, - }, - }, - isConfigLoaded: true, -}); + +setupMockConfig({ disabled: false, enabled: true }); jest.mock("vue-router/composables"); diff --git a/client/src/components/History/CurrentHistory/SelectPreferredStore.test.ts b/client/src/components/History/CurrentHistory/SelectPreferredStore.test.ts index 7638ef43b918..c500afa2af64 100644 --- a/client/src/components/History/CurrentHistory/SelectPreferredStore.test.ts +++ b/client/src/components/History/CurrentHistory/SelectPreferredStore.test.ts @@ -3,6 +3,7 @@ import axios from "axios"; import MockAdapter from "axios-mock-adapter"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; +import { h } from "vue"; import { useServerMock } from "@/api/client/__mocks__"; import { ROOT_COMPONENT } from "@/utils/navigation/schema"; @@ -42,6 +43,13 @@ async function mountComponent() { const PREFERENCES = ROOT_COMPONENT.preferences; +// bootstrap vue will try to match targets to actual HTML elements in DOM but there +// may be no DOM for jest tests, just stub out an alternative minimal implementation. +jest.mock("@/components/ObjectStore/ObjectStoreSelectButtonPopover.vue", () => ({ + name: "ObjectStoreSelectButtonPopover", + render: () => h("div", "Mocked Popover"), +})); + describe("SelectPreferredStore.vue", () => { let axiosMock: MockAdapter; diff --git a/client/src/components/History/Multiple/MultipleView.test.js b/client/src/components/History/Multiple/MultipleView.test.js index cb7f83264164..4ab167eb7029 100644 --- a/client/src/components/History/Multiple/MultipleView.test.js +++ b/client/src/components/History/Multiple/MultipleView.test.js @@ -3,6 +3,7 @@ import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { createPinia } from "pinia"; import { getLocalVue } from "tests/jest/helpers"; +import { setupMockConfig } from "tests/jest/mockConfig"; import { useServerMock } from "@/api/client/__mocks__"; import { useHistoryStore } from "@/stores/historyStore"; @@ -13,6 +14,8 @@ import MultipleView from "./MultipleView.vue"; const USER_ID = "test-user-id"; const FIRST_HISTORY_ID = "test-history-id-0"; +setupMockConfig({}); + const { server, http } = useServerMock(); const getFakeHistorySummaries = (num) => { @@ -29,10 +32,6 @@ describe("MultipleView", () => { const fakeSummaries = getFakeHistorySummaries(count); server.use( - http.get("/api/configuration", ({ response }) => { - return response(200).json({}); - }), - http.get("/api/histories/{history_id}", ({ response, params }) => { const { history_id } = params; const summary = fakeSummaries.find((s) => s.id === history_id); diff --git a/client/src/components/JobInformation/JobInformation.test.js b/client/src/components/JobInformation/JobInformation.test.js index 68602a1b6ffd..8cc65b9499c3 100644 --- a/client/src/components/JobInformation/JobInformation.test.js +++ b/client/src/components/JobInformation/JobInformation.test.js @@ -1,3 +1,5 @@ +import "tests/jest/mockHelpPopovers"; + import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; diff --git a/client/src/components/Masthead/QuotaMeter.test.ts b/client/src/components/Masthead/QuotaMeter.test.ts index b405a5b36a12..70b8b12989d5 100644 --- a/client/src/components/Masthead/QuotaMeter.test.ts +++ b/client/src/components/Masthead/QuotaMeter.test.ts @@ -3,6 +3,7 @@ import { getFakeRegisteredUser } from "@tests/test-data"; import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; +import { setupMockConfig } from "tests/jest/mockConfig"; import { type RegisteredUser } from "@/api"; import { useUserStore } from "@/stores/userStore"; @@ -11,19 +12,10 @@ import QuotaMeter from "./QuotaMeter.vue"; jest.mock("@/api/schema"); -let configValues = { enable_quotas: true }; - -jest.mock("@/composables/config", () => ({ - useConfig: jest.fn(() => ({ - config: { value: { ...configValues } }, - isConfigLoaded: true, - })), -})); - const localVue = getLocalVue(); async function createQuotaMeterWrapper(config: any, user: RegisteredUser) { - configValues = { ...config }; + setupMockConfig(config); const pinia = createTestingPinia(); const userStore = useUserStore(); userStore.currentUser = user; diff --git a/client/src/components/StsDownloadButton.test.js b/client/src/components/StsDownloadButton.test.js index e35f720a59b0..29506c7b5cd9 100644 --- a/client/src/components/StsDownloadButton.test.js +++ b/client/src/components/StsDownloadButton.test.js @@ -6,8 +6,7 @@ import MockAdapter from "axios-mock-adapter"; import flushPromises from "flush-promises"; import { createPinia } from "pinia"; import { getLocalVue } from "tests/jest/helpers"; - -import { useServerMock } from "@/api/client/__mocks__"; +import { setupMockConfig } from "tests/jest/mockConfig"; import StsDownloadButton from "./StsDownloadButton.vue"; @@ -22,14 +21,8 @@ const FALLBACK_URL = "http://cow.com/direct_download"; const DOWNLOAD_ENDPOINT = "http://cow.com/prepare_download"; const STORAGE_REQUEST_ID = "moocow1235"; -const { server, http } = useServerMock(); - async function mountStsDownloadButtonWrapper(config) { - server.use( - http.get("/api/configuration", ({ response }) => { - return response(200).json(config); - }) - ); + setupMockConfig(config); const pinia = createPinia(); const wrapper = mount(StsDownloadButton, { diff --git a/client/src/components/TagsMultiselect/StatelessTags.test.js b/client/src/components/TagsMultiselect/StatelessTags.test.js index 54a35a19bb38..487c7057f1e4 100644 --- a/client/src/components/TagsMultiselect/StatelessTags.test.js +++ b/client/src/components/TagsMultiselect/StatelessTags.test.js @@ -1,7 +1,6 @@ import { mount } from "@vue/test-utils"; import { useToast } from "composables/toast"; -import { getLocalVue } from "tests/jest/helpers"; -import { computed } from "vue"; +import { getLocalVue, suppressBootstrapVueWarnings } from "tests/jest/helpers"; import { normalizeTag, useUserTagsStore } from "@/stores/userTagsStore"; @@ -19,10 +18,12 @@ const mountWithProps = (props) => { }); }; +suppressBootstrapVueWarnings(); + jest.mock("@/stores/userTagsStore"); const onNewTagSeenMock = jest.fn((tag) => tag); useUserTagsStore.mockReturnValue({ - userTags: computed(() => autocompleteTags), + userTags: autocompleteTags, onNewTagSeen: onNewTagSeenMock, onTagUsed: jest.fn(), onMultipleNewTagsSeen: jest.fn(), diff --git a/client/src/components/TagsMultiselect/StatelessTags.vue b/client/src/components/TagsMultiselect/StatelessTags.vue index 7f2256a4aaa3..1bca9868a8f9 100644 --- a/client/src/components/TagsMultiselect/StatelessTags.vue +++ b/client/src/components/TagsMultiselect/StatelessTags.vue @@ -1,6 +1,5 @@