diff --git a/client/src/components/License/LicenseSelector.vue b/client/src/components/License/LicenseSelector.vue index a9f55d621e1c..a18810c3b4a2 100644 --- a/client/src/components/License/LicenseSelector.vue +++ b/client/src/components/License/LicenseSelector.vue @@ -12,24 +12,23 @@ import License from "@/components/License/License.vue"; import LoadingSpan from "@/components/LoadingSpan.vue"; const defaultLicense: LicenseType = { - licenseId: null, name: "*Do not specify a license.*", }; type LicenseMetadataModel = components["schemas"]["LicenseMetadataModel"]; type LicenseType = { - licenseId: string | null; + licenseId?: string; name: string; }; interface Props { - inputLicense: string; + inputLicense?: string; } const props = defineProps(); const emit = defineEmits<{ - (e: "onLicense", license: string | null): void; + (e: "onLicense", license?: string): void; }>(); const licensesLoading = ref(false); diff --git a/client/src/components/Workflow/Editor/Index.test.ts b/client/src/components/Workflow/Editor/Index.test.ts index 7262d2d72956..c97b30a405cf 100644 --- a/client/src/components/Workflow/Editor/Index.test.ts +++ b/client/src/components/Workflow/Editor/Index.test.ts @@ -1,8 +1,10 @@ import { expect, jest } from "@jest/globals"; import { createTestingPinia } from "@pinia/testing"; -import { shallowMount } from "@vue/test-utils"; +import { shallowMount, type Wrapper } from "@vue/test-utils"; import { PiniaVuePlugin, setActivePinia } from "pinia"; import { getLocalVue } from "tests/jest/helpers"; +import type Vue from "vue"; +import { nextTick } from "vue"; import { testDatatypesMapper } from "@/components/Datatypes/test_fixtures"; import { getAppRoot } from "@/onload/loadConfig"; @@ -30,7 +32,7 @@ const mockLoadWorkflow = loadWorkflow as jest.Mocked; const MockGetVersions = getVersions as jest.Mocked; describe("Index", () => { - let wrapper: any; // don't know how to add type hints here, see https://github.com/vuejs/vue-test-utils/issues/255 + let wrapper: Wrapper; beforeEach(() => { const testingPinia = createTestingPinia(); @@ -41,10 +43,7 @@ describe("Index", () => { MockGetVersions.mockResolvedValue([]); mockGetStateUpgradeMessages.mockImplementation(() => []); mockGetAppRoot.mockImplementation(() => "prefix/"); - Object.defineProperty(window, "onbeforeunload", { - value: null, - writable: true, - }); + wrapper = shallowMount(Index, { propsData: { workflowId: "workflow_id", @@ -53,70 +52,19 @@ describe("Index", () => { moduleSections: [], dataManagers: [], workflows: [], - toolbox: [], }, localVue, pinia: testingPinia, }); }); - async function resetChanges() { - wrapper.vm.hasChanges = false; - await wrapper.vm.$nextTick(); - } - - it("resolves datatypes", async () => { - expect(wrapper.datatypesMapper).not.toBeNull(); - expect(wrapper.datatypes).not.toBeNull(); - }); - - it("routes to download URL and respects Galaxy prefix", async () => { - Object.defineProperty(window, "location", { - value: "original", - writable: true, - }); - wrapper.vm.onDownload(); - expect(window.location).toBe("prefix/api/workflows/workflow_id/download?format=json-download"); + it("renders correctly", () => { + expect(wrapper.exists()).toBe(true); }); - it("tracks changes to annotations", async () => { - expect(wrapper.vm.hasChanges).toBeFalsy(); - wrapper.vm.annotation = "original annotation"; - await wrapper.vm.$nextTick(); - expect(wrapper.vm.hasChanges).toBeTruthy(); - - resetChanges(); - - wrapper.vm.annotation = "original annotation"; - await wrapper.vm.$nextTick(); - expect(wrapper.vm.hasChanges).toBeFalsy(); - - wrapper.vm.annotation = "new annotation"; - await wrapper.vm.$nextTick(); - expect(wrapper.vm.hasChanges).toBeTruthy(); - }); - - it("tracks changes to name", async () => { - expect(wrapper.hasChanges).toBeFalsy(); - wrapper.vm.name = "original name"; - await wrapper.vm.$nextTick(); - expect(wrapper.vm.hasChanges).toBeTruthy(); - - resetChanges(); - - wrapper.vm.name = "original name"; - await wrapper.vm.$nextTick(); - expect(wrapper.vm.hasChanges).toBeFalsy(); - - wrapper.vm.name = "new name"; - await wrapper.vm.$nextTick(); - expect(wrapper.vm.hasChanges).toBeTruthy(); - }); + it("loads the workflow", async () => { + await nextTick(); - it("prevents navigation only if hasChanges", async () => { - expect(wrapper.vm.hasChanges).toBeFalsy(); - await wrapper.vm.onChange(); - const confirmationRequired = wrapper.emitted()["update:confirmation"][0][0]; - expect(confirmationRequired).toBeTruthy(); + expect(mockLoadWorkflow).toHaveBeenCalledWith({ id: "workflow_id", version: 1 }); }); }); diff --git a/client/src/components/Workflow/Editor/Index.vue b/client/src/components/Workflow/Editor/Index.vue index 182dc05823e3..7762ae4f253f 100644 --- a/client/src/components/Workflow/Editor/Index.vue +++ b/client/src/components/Workflow/Editor/Index.vue @@ -1,32 +1,911 @@ + +