diff --git a/client/src/components/Common/Tags.vue b/client/src/components/Common/Tags.vue index e6470d138d3d..bb874f8382f9 100644 --- a/client/src/components/Common/Tags.vue +++ b/client/src/components/Common/Tags.vue @@ -1,5 +1,5 @@ diff --git a/client/src/components/Page/PageIndexActions.test.js b/client/src/components/Page/PageIndexActions.test.js new file mode 100644 index 000000000000..7d494b29d917 --- /dev/null +++ b/client/src/components/Page/PageIndexActions.test.js @@ -0,0 +1,28 @@ +import PageIndexActions from "./PageIndexActions"; +import { shallowMount } from "@vue/test-utils"; +import { getLocalVue } from "jest/helpers"; + +import "jest-location-mock"; + +const localVue = getLocalVue(); + +describe("PageIndexActions.vue", () => { + let wrapper; + + beforeEach(async () => { + const propsData = { + root: "/rootprefix/", + }; + wrapper = shallowMount(PageIndexActions, { + propsData, + localVue, + }); + }); + + describe("naviation", () => { + it("should create a page when create is clicked", async () => { + await wrapper.find("#page-create").trigger("click"); + expect(window.location).toBeAt("/rootprefix/pages/create"); + }); + }); +}); diff --git a/client/src/components/Page/PageIndexActions.vue b/client/src/components/Page/PageIndexActions.vue new file mode 100644 index 000000000000..717ce2f9adb1 --- /dev/null +++ b/client/src/components/Page/PageIndexActions.vue @@ -0,0 +1,35 @@ + + + diff --git a/client/src/components/Page/PageList.vue b/client/src/components/Page/PageList.vue new file mode 100644 index 000000000000..bb7e530d82ac --- /dev/null +++ b/client/src/components/Page/PageList.vue @@ -0,0 +1,194 @@ + + diff --git a/client/src/components/Page/PageUrl.test.js b/client/src/components/Page/PageUrl.test.js new file mode 100644 index 000000000000..39421807aee6 --- /dev/null +++ b/client/src/components/Page/PageUrl.test.js @@ -0,0 +1,36 @@ +import PageUrl from "./PageUrl"; +import { mount } from "@vue/test-utils"; +import { getLocalVue } from "jest/helpers"; + +const localVue = getLocalVue(true); + +describe("PageUrl.vue", () => { + let wrapper; + + beforeEach(async () => { + const propsData = { + root: "/rootprefix/", + owner: "jmchilton", + slug: "my-cool-slug", + }; + wrapper = mount(PageUrl, { + propsData, + localVue, + }); + }); + + describe("component", () => { + it("should localize title text", async () => { + expect(wrapper.find("svg title").text()).toBeLocalized(); + }); + + it("should emit an event when owner is clicked on", async () => { + const ownerEl = wrapper.find("a.page-url-owner"); + expect(ownerEl.text()).toBe("jmchilton"); + await ownerEl.trigger("click"); + + const emitted = wrapper.emitted(); + expect(emitted["click-owner"][0][0]).toEqual("jmchilton"); + }); + }); +}); diff --git a/client/src/components/Page/PageUrl.vue b/client/src/components/Page/PageUrl.vue new file mode 100644 index 000000000000..78b51744dc55 --- /dev/null +++ b/client/src/components/Page/PageUrl.vue @@ -0,0 +1,55 @@ + + + diff --git a/client/src/components/Page/services.js b/client/src/components/Page/services.js new file mode 100644 index 000000000000..1265b95c24bd --- /dev/null +++ b/client/src/components/Page/services.js @@ -0,0 +1,20 @@ +import axios from "axios"; +import { rethrowSimple } from "utils/simple-error"; +import { getAppRoot } from "onload/loadConfig"; + +/** Page request helper **/ +export class Services { + constructor(options = {}) { + this.root = options.root || getAppRoot(); + } + + async deletePage(id) { + const url = `${this.root}api/pages/${id}`; + try { + const response = await axios.delete(url); + return response.data; + } catch (e) { + rethrowSimple(e); + } + } +} diff --git a/client/src/components/Workflow/HistoryInvocations.vue b/client/src/components/Workflow/HistoryInvocations.vue new file mode 100644 index 000000000000..aa19596ce520 --- /dev/null +++ b/client/src/components/Workflow/HistoryInvocations.vue @@ -0,0 +1,33 @@ + + diff --git a/client/src/components/Workflow/Invocations.test.js b/client/src/components/Workflow/Invocations.test.js index 8b1271e2bfec..a41e3465b9c2 100644 --- a/client/src/components/Workflow/Invocations.test.js +++ b/client/src/components/Workflow/Invocations.test.js @@ -62,7 +62,11 @@ describe("Invocations.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", @@ -81,6 +85,41 @@ describe("Invocations.vue", () => { 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(Invocations, { + propsData, + localVue, + }); + }); + + it("title should be shown", async () => { + expect(wrapper.find("#invocations-title").text()).toBe("Workflow Invocations for 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", () => { @@ -155,5 +194,45 @@ describe("Invocations.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("pagiantions", () => { + 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(Invocations, { + 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/Invocations.vue b/client/src/components/Workflow/Invocations.vue index 44b517ab491f..9247252fb713 100644 --- a/client/src/components/Workflow/Invocations.vue +++ b/client/src/components/Workflow/Invocations.vue @@ -6,12 +6,11 @@ {{ headerMessage }} - {{ message }} + {{ message }} @@ -80,7 +79,6 @@