diff --git a/client/src/components/WorkflowInvocationState/WorkflowInvocationState.test.js b/client/src/components/WorkflowInvocationState/WorkflowInvocationState.test.js index 6f9fe2cf27f..a751c05a1e8 100644 --- a/client/src/components/WorkflowInvocationState/WorkflowInvocationState.test.js +++ b/client/src/components/WorkflowInvocationState/WorkflowInvocationState.test.js @@ -34,16 +34,6 @@ describe("WorkflowInvocationState.vue with terminal invocation", () => { it("determines that invocation and job states are terminal", async () => { expect(wrapper.vm.invocationAndJobTerminal).toBeTruthy(); }); - - it("displays report links", async () => { - expect(wrapper.find(".invocation-pdf-link").exists()).toBeTruthy(); - expect(wrapper.find(".invocation-report-link").exists()).toBeTruthy(); - expect(wrapper.find(".bco-json").exists()).toBeTruthy(); - }); - - it("doesn't show cancel invocation button", async () => { - expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeFalsy(); - }); }); describe("WorkflowInvocationState.vue with no invocation", () => { @@ -77,14 +67,4 @@ describe("WorkflowInvocationState.vue with no invocation", () => { it("determines that invocation and job states are not terminal", async () => { expect(wrapper.vm.invocationAndJobTerminal).toBeFalsy(); }); - - it("does not display report links", async () => { - expect(wrapper.find(".invocation-pdf-link").exists()).toBeFalsy(); - expect(wrapper.find(".invocation-report-link").exists()).toBeFalsy(); - expect(wrapper.find(".bco-json").exists()).toBeFalsy(); - }); - - it("shows cancel invocation button", async () => { - expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeTruthy(); - }); }); diff --git a/client/src/components/WorkflowInvocationState/WorkflowInvocationSummary.test.js b/client/src/components/WorkflowInvocationState/WorkflowInvocationSummary.test.js new file mode 100644 index 00000000000..12486f60649 --- /dev/null +++ b/client/src/components/WorkflowInvocationState/WorkflowInvocationSummary.test.js @@ -0,0 +1,82 @@ +import WorkflowInvocationSummary from "./WorkflowInvocationSummary"; +import { shallowMount } from "@vue/test-utils"; +import { getLocalVue } from "jest/helpers"; +import Vuex from "vuex"; +import invocationData from "../Workflow/test/json/invocation.json"; + +const invocationJobsSummaryById = { + id: "d9833097445452b0", + model: "WorkflowInvocation", + states: {}, + populated_state: "ok", +}; + +const mockComputed = { + getInvocationJobsSummaryById: () => () => invocationJobsSummaryById, +}; + +const localVue = getLocalVue(); + +describe("WorkflowInvocationSummary.vue with terminal invocation", () => { + let wrapper; + let propsData; + + beforeEach(async () => { + propsData = { + invocation: invocationData, + invocationAndJobTerminal: true, + invocationSchedulingTerminal: true, + }; + wrapper = shallowMount(WorkflowInvocationSummary, { + propsData, + computed: mockComputed, + localVue, + }); + }); + + it("displays report links", async () => { + expect(wrapper.find(".invocation-pdf-link").exists()).toBeTruthy(); + expect(wrapper.find(".invocation-report-link").exists()).toBeTruthy(); + }); + + it("doesn't show cancel invocation button", async () => { + expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeFalsy(); + }); +}); + +describe("WorkflowInvocationSummary.vue with invocation scheduling running", () => { + let wrapper; + let propsData; + let store; + let actions; + + beforeEach(async () => { + actions = { + fetchInvocationForId: jest.fn(), + fetchInvocationJobsSummaryForId: jest.fn(), + }; + store = new Vuex.Store({ + actions, + }); + propsData = { + invocation: invocationData, + invocationAndJobTerminal: false, + invocationSchedulingTerminal: false, + }; + wrapper = shallowMount(WorkflowInvocationSummary, { + store, + propsData, + computed: mockComputed, + localVue, + }); + }); + + it("does not display report links", async () => { + expect(wrapper.find(".invocation-pdf-link").exists()).toBeFalsy(); + expect(wrapper.find(".invocation-report-link").exists()).toBeFalsy(); + }); + + it("shows cancel invocation button", async () => { + expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeTruthy(); + }); +});