From e95a0c1161236001d1a01eed5950c40504ecaf22 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 13:43:03 -0500 Subject: [PATCH 01/17] Fix unmocked API calls in FilterMenu.test.ts. --- client/src/components/Common/FilterMenu.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/components/Common/FilterMenu.test.ts b/client/src/components/Common/FilterMenu.test.ts index bab978663fcb..b9ba3db65b3b 100644 --- a/client/src/components/Common/FilterMenu.test.ts +++ b/client/src/components/Common/FilterMenu.test.ts @@ -3,11 +3,14 @@ import { getLocalVue } from "@tests/jest/helpers"; import { mount, type Wrapper } from "@vue/test-utils"; import { HistoryFilters } from "@/components/History/HistoryFilters"; +import { setupSelectableMock } from "@/components/ObjectStore/mockServices"; import { WorkflowFilters } from "@/components/Workflow/List/WorkflowFilters"; import Filtering, { compare, contains, equals, toBool, toDate } from "@/utils/filtering"; import FilterMenu from "./FilterMenu.vue"; +setupSelectableMock(); + const localVue = getLocalVue(); const options = [ { text: "Any", value: "any" }, From a9e76b1234d10fccddcb2e72ac589b5d0b18d33c Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 13:43:23 -0500 Subject: [PATCH 02/17] Various fixes for CarbonEmissions.test.js. --- .../CarbonEmissions/CarbonEmissions.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js b/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js index a9cd95acdbc8..e9361922eb43 100644 --- a/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js +++ b/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js @@ -1,10 +1,13 @@ import { mount } from "@vue/test-utils"; import { getLocalVue } from "tests/jest/helpers"; +import VueRouter from "vue-router"; import { worldwideCarbonIntensity, worldwidePowerUsageEffectiveness } from "./carbonEmissionConstants.js"; import CarbonEmissions from "./CarbonEmissions"; const localVue = getLocalVue(); +localVue.use(VueRouter); +const router = new VueRouter(); const oneGibibyteMemoryInMebibyte = 1024; const oneHourInSeconds = 3600; @@ -27,8 +30,10 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { jobRuntimeInSeconds: oneHourInSeconds, memoryAllocatedInMebibyte: oneGibibyteMemoryInMebibyte, powerUsageEffectiveness: worldwidePowerUsageEffectiveness, + geographicalServerLocationName: "GLOBAL", }, localVue, + router, }); const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text(); @@ -48,8 +53,12 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { coresAllocated: 1, estimatedServerInstance: testServerInstance, jobRuntimeInSeconds: 1, + geographicalServerLocationName: "GLOBAL", + powerUsageEffectiveness: worldwidePowerUsageEffectiveness, + carbonIntensity: worldwideCarbonIntensity, }, localVue, + router, }); expect(wrapper.find("#memory-carbon-emissions").exists()).toBe(false); @@ -65,8 +74,10 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { jobRuntimeInSeconds: 1, memoryAllocatedInMebibyte: 1, powerUsageEffectiveness: 0, + geographicalServerLocationName: "GLOBAL", }, localVue, + router, }); const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text(); @@ -89,8 +100,10 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { jobRuntimeInSeconds: 1, memoryAllocatedInMebibyte: 1, powerUsageEffectiveness: 1, + geographicalServerLocationName: "GLOBAL", }, localVue, + router, }); const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text(); @@ -109,8 +122,10 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { estimatedServerInstance: testServerInstance, jobRuntimeInSeconds: 2, geographicalServerLocationName: "GLOBAL", + powerUsageEffectiveness: worldwidePowerUsageEffectiveness, }, localVue, + router, }); const locationText = wrapper.find("#location-explanation").element; expect(locationText).toHaveTextContent( @@ -132,6 +147,7 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { geographicalServerLocationName: locationName, }, localVue, + router, }); const locationElement = wrapper.find("#location-explanation").element; @@ -150,8 +166,10 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => { jobRuntimeInSeconds: 1, memoryAllocatedInMebibyte: 1, powerUsageEffectiveness, + geographicalServerLocationName: "GLOBAL", }, localVue, + router, }); const locationElement = wrapper.find("#pue").element; From 720af41de0b43e29e3b86d53c5e6f781f2d032c3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 14:47:35 -0500 Subject: [PATCH 03/17] Fix FavoritesButton.test.js. --- client/src/components/Panels/Buttons/FavoritesButton.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/components/Panels/Buttons/FavoritesButton.test.js b/client/src/components/Panels/Buttons/FavoritesButton.test.js index 6b4130f38928..2fb0b4690275 100644 --- a/client/src/components/Panels/Buttons/FavoritesButton.test.js +++ b/client/src/components/Panels/Buttons/FavoritesButton.test.js @@ -10,6 +10,9 @@ const localVue = getLocalVue(); async function createWrapper(component, localVue, userData) { const pinia = createPinia(); const wrapper = shallowMount(component, { + propsData: { + query: "mock", + }, localVue, pinia, }); From 3aa8857268edcd0f59bb54c3fee9c2ac414407f8 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 14:48:00 -0500 Subject: [PATCH 04/17] Cleanup issues in WorkflowList.test.ts. --- .../Workflow/List/WorkflowList.test.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/client/src/components/Workflow/List/WorkflowList.test.ts b/client/src/components/Workflow/List/WorkflowList.test.ts index 4d82fcf08c4f..b1851fea8740 100644 --- a/client/src/components/Workflow/List/WorkflowList.test.ts +++ b/client/src/components/Workflow/List/WorkflowList.test.ts @@ -1,9 +1,10 @@ import { createTestingPinia } from "@pinia/testing"; -import { getLocalVue } from "@tests/jest/helpers"; +import { getLocalVue, suppressBootstrapVueWarnings } from "@tests/jest/helpers"; import { getFakeRegisteredUser } from "@tests/test-data"; import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { setActivePinia } from "pinia"; +import VueRouter from "vue-router"; import { HttpResponse, useServerMock } from "@/api/client/__mocks__"; import { useUserStore } from "@/stores/userStore"; @@ -13,6 +14,8 @@ import { generateRandomWorkflowList } from "../testUtils"; import WorkflowList from "./WorkflowList.vue"; const localVue = getLocalVue(); +localVue.use(VueRouter); +const router = new VueRouter(); const { server, http } = useServerMock(); @@ -29,19 +32,10 @@ async function mountWorkflowList() { const pinia = createTestingPinia(); setActivePinia(pinia); - const mockRouter = { - push: jest.fn(), - currentRoute: { - query: {}, - }, - }; - const wrapper = mount(WorkflowList as object, { localVue, pinia, - mocks: { - $router: mockRouter, - }, + router, }); const userStore = useUserStore(); @@ -52,6 +46,9 @@ async function mountWorkflowList() { return wrapper; } +// The use of the tool tip in statelesstag without a real dom is causing issues +suppressBootstrapVueWarnings(); + describe("WorkflowList", () => { beforeEach(() => { server.use( @@ -122,5 +119,6 @@ describe("WorkflowList", () => { await wrapper.vm.$nextTick(); expect((wrapper.find("#workflow-list-filter input").element as HTMLInputElement).value).toBe(""); + await flushPromises(); }); }); From fc7d9b188df6533bb9e187b65d7fdea65d8280d1 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 14:52:12 -0500 Subject: [PATCH 05/17] Improved mocking of config in FormDirectory.test.js --- client/src/components/Form/Elements/FormDirectory.test.js | 6 ++---- client/src/components/Grid/GridList.test.js | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/client/src/components/Form/Elements/FormDirectory.test.js b/client/src/components/Form/Elements/FormDirectory.test.js index 1504e1133d2a..3aef7b6b052c 100644 --- a/client/src/components/Form/Elements/FormDirectory.test.js +++ b/client/src/components/Form/Elements/FormDirectory.test.js @@ -2,6 +2,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 { rootResponse } from "@/components/FilesDialog/testingData"; @@ -13,6 +14,7 @@ const localVue = getLocalVue(); jest.mock("app"); const { server, http } = useServerMock(); +setupMockConfig({}); describe("DirectoryPathEditableBreadcrumb", () => { let wrapper; @@ -56,10 +58,6 @@ describe("DirectoryPathEditableBreadcrumb", () => { server.use( http.get("/api/remote_files/plugins", ({ response }) => { return response(200).json(rootResponse); - }), - - http.get("/api/configuration", ({ response }) => { - return response(200).json({}); }) ); diff --git a/client/src/components/Grid/GridList.test.js b/client/src/components/Grid/GridList.test.js index 3abe0006a669..2639156b6bac 100644 --- a/client/src/components/Grid/GridList.test.js +++ b/client/src/components/Grid/GridList.test.js @@ -11,8 +11,6 @@ import MountTarget from "./GridList.vue"; jest.useFakeTimers(); -jest.mock("composables/config"); - setupMockConfig({ disabled: false, enabled: true }); jest.mock("vue-router/composables"); From 590f6e5b4170daea152dd4498972bc1938e707ca Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 14:55:44 -0500 Subject: [PATCH 06/17] Cleanup test output for WorkflowSelectPreferredObjectStore.test.js. --- .../Run/WorkflowSelectPreferredObjectStore.test.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/src/components/Workflow/Run/WorkflowSelectPreferredObjectStore.test.js b/client/src/components/Workflow/Run/WorkflowSelectPreferredObjectStore.test.js index c83456a58c3d..7cae96748199 100644 --- a/client/src/components/Workflow/Run/WorkflowSelectPreferredObjectStore.test.js +++ b/client/src/components/Workflow/Run/WorkflowSelectPreferredObjectStore.test.js @@ -1,26 +1,21 @@ +import "tests/jest/mockHelpPopovers"; + import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; +import { setupMockConfig } from "tests/jest/mockConfig"; -import { useServerMock } from "@/api/client/__mocks__"; import { setupSelectableMock } from "@/components/ObjectStore/mockServices"; import { ROOT_COMPONENT } from "@/utils/navigation"; import WorkflowSelectPreferredObjectStore from "./WorkflowSelectPreferredObjectStore.vue"; setupSelectableMock(); +setupMockConfig({}); const localVue = getLocalVue(true); -const { server, http } = useServerMock(); - function mountComponent() { - server.use( - http.get("/api/configuration", ({ response }) => { - return response(200).json({}); - }) - ); - const wrapper = mount(WorkflowSelectPreferredObjectStore, { propsData: { invocationPreferredObjectStoreId: null }, localVue, From 610cbab83ce515d02a0046eb9c5912d9cd42d826 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2024 14:59:16 -0500 Subject: [PATCH 07/17] Cleanup test output for JobOutputs. --- client/src/components/JobInformation/JobOutputs.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/components/JobInformation/JobOutputs.vue b/client/src/components/JobInformation/JobOutputs.vue index 841e08f67761..494690707c07 100644 --- a/client/src/components/JobInformation/JobOutputs.vue +++ b/client/src/components/JobInformation/JobOutputs.vue @@ -26,9 +26,9 @@ - + Show {{ totalLength - firstN >= 10 ? 10 : totalLength - firstN }} more outputs - + @@ -37,10 +37,12 @@