From b787357e1c27f1e676db07a797400b3047c8bc17 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Mon, 22 May 2023 13:10:26 -0700 Subject: [PATCH 1/6] add option to history for displaying invocation related to it --- .../CurrentHistory/HistoryNavigation.test.js | 1 + .../CurrentHistory/HistoryNavigation.vue | 8 ++ .../Workflow/HistoryInvocations.vue | 34 +++++++ .../Workflow/InvocationsList.test.js | 93 +++++++++++++++++-- .../components/Workflow/InvocationsList.vue | 69 +++++++++----- client/src/entry/analysis/router.js | 6 ++ lib/galaxy/webapps/galaxy/buildapp.py | 1 + 7 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 client/src/components/Workflow/HistoryInvocations.vue diff --git a/client/src/components/History/CurrentHistory/HistoryNavigation.test.js b/client/src/components/History/CurrentHistory/HistoryNavigation.test.js index e96b45d0c03..798e7e55b52 100644 --- a/client/src/components/History/CurrentHistory/HistoryNavigation.test.js +++ b/client/src/components/History/CurrentHistory/HistoryNavigation.test.js @@ -15,6 +15,7 @@ const expectedOptions = [ "Export Tool Citations", "Export History to File", "Extract Workflow", + "Show Invocations", "Share or Publish", "Set Permissions", "Make Private", diff --git a/client/src/components/History/CurrentHistory/HistoryNavigation.vue b/client/src/components/History/CurrentHistory/HistoryNavigation.vue index 4650262e70f..9ad0e697038 100644 --- a/client/src/components/History/CurrentHistory/HistoryNavigation.vue +++ b/client/src/components/History/CurrentHistory/HistoryNavigation.vue @@ -104,6 +104,14 @@ Extract Workflow + + + Show Invocations + + +
+ +
+ + diff --git a/client/src/components/Workflow/InvocationsList.test.js b/client/src/components/Workflow/InvocationsList.test.js index eed58f6d305..5e8383e3e8d 100644 --- a/client/src/components/Workflow/InvocationsList.test.js +++ b/client/src/components/Workflow/InvocationsList.test.js @@ -66,7 +66,11 @@ describe("InvocationsList.vue", () => { describe("for a workflow with an empty invocation list", () => { beforeEach(async () => { - axiosMock.onAny().reply(200, [], { total_matches: "0" }); + axiosMock + .onGet("/api/invocations", { + params: { limit: 50, offset: 0, include_terminal: false, workflow_id: "abcde145678" }, + }) + .reply(200, [], { total_matches: "0" }); const propsData = { ownerGrid: false, storedWorkflowName: "My Workflow", @@ -80,12 +84,47 @@ describe("InvocationsList.vue", () => { }); it("title should be shown", async () => { - expect(wrapper.find("#invocations-title").text()).toBe("Workflow Invocations for My Workflow"); + expect(wrapper.find("#invocations-title").text()).toBe('Workflow Invocations for workflow "My Workflow"'); }); it("no invocations message should be shown when not loading", async () => { expect(wrapper.find("#no-invocations").exists()).toBe(true); }); + + it("should not render pager", async () => { + expect(wrapper.find(".gx-invocations-grid-pager").exists()).toBeFalsy(); + }); + }); + + describe("for a history with an empty invocation list", () => { + beforeEach(async () => { + axiosMock + .onGet("/api/invocations", { + params: { limit: 50, offset: 0, include_terminal: false, history_id: "abcde145678" }, + }) + .reply(200, [], { total_matches: "0" }); + const propsData = { + ownerGrid: false, + historyName: "My History", + historyId: "abcde145678", + }; + wrapper = mount(InvocationsList, { + propsData, + localVue, + }); + }); + + it("title should be shown", async () => { + expect(wrapper.find("#invocations-title").text()).toBe('Workflow Invocations for history "My History"'); + }); + + it("no invocations message should be shown when not loading", async () => { + expect(wrapper.find("#no-invocations").exists()).toBe(true); + }); + + it("should not render pager", async () => { + expect(wrapper.find(".gx-invocations-grid-pager").exists()).toBeFalsy(); + }); }); describe("with invocation", () => { @@ -132,11 +171,11 @@ describe("InvocationsList.vue", () => { expect(columns.at(3).text()).toBe( formatDistanceToNow(parseISO(`${mockInvocationData.create_time}Z`), { addSuffix: true }) ); - expect(columns.at(4).text()).toBe( - formatDistanceToNow(parseISO(`${mockInvocationData.update_time}Z`), { addSuffix: true }) - ); - expect(columns.at(5).text()).toBe("scheduled"); - expect(columns.at(6).text()).toBe(""); + // expect(columns.at(4).text()).toBe( + // formatDistanceToNow(parseISO(`${mockInvocationData.update_time}Z`), { addSuffix: true }) + // ); + expect(columns.at(4).text()).toBe("scheduled"); + expect(columns.at(5).text()).toBe(""); }); it("toggles detail rendering", async () => { @@ -161,5 +200,45 @@ describe("InvocationsList.vue", () => { await wrapper.find(".workflow-run").trigger("click"); expect(window.location).toBeAt("workflows/run?id=workflowId"); }); + + it("should not render pager", async () => { + expect(wrapper.find(".gx-invocations-grid-pager").exists()).toBeFalsy(); + }); + }); + + describe("paginations", () => { + beforeEach(async () => { + axiosMock + .onGet("/api/invocations", { params: { limit: 1, offset: 0, include_terminal: false } }) + .reply(200, [mockInvocationData], { total_matches: "3" }); + const propsData = { + ownerGrid: false, + loading: false, + defaultPerPage: 1, + }; + wrapper = mount(InvocationsList, { + propsData, + computed: { + getWorkflowNameByInstanceId: (state) => (id) => "workflow name", + getWorkflowByInstanceId: (state) => (id) => { + return { id: "workflowId" }; + }, + getHistoryById: (state) => (id) => { + return { id: "historyId" }; + }, + getHistoryNameById: () => () => "history name", + }, + stubs: { + "workflow-invocation-state": { + template: "", + }, + }, + localVue, + }); + }); + + it("title should render pager", async () => { + expect(wrapper.find(".gx-invocations-grid-pager").exists()).toBeTruthy(); + }); }); }); diff --git a/client/src/components/Workflow/InvocationsList.vue b/client/src/components/Workflow/InvocationsList.vue index d478551d1f8..db4847323fc 100644 --- a/client/src/components/Workflow/InvocationsList.vue +++ b/client/src/components/Workflow/InvocationsList.vue @@ -6,13 +6,12 @@ {{ headerMessage }} - {{ message }} + {{ message }}