Skip to content

Commit

Permalink
fix jest fails caused by modifications made for invocation graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Apr 17, 2024
1 parent 189a5ae commit 91a8b7b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 17 additions & 2 deletions client/src/components/WorkflowInvocationState/JobStep.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,29 @@ describe("DatasetUIWrapper.vue with Dataset", () => {
expect(wrapper.vm.toggledItems["1"]).toBeTruthy();
expect(wrapper.find(".expanded").exists()).toBeTruthy();
// 2 collapsed rows, plus 1 expanded row
expect(wrapper.find("tbody").findAll("tr").length).toBe(3);
expect(countVisibleRows(wrapper)).toBe(3);
// update data
const additionalJob = { ...jobs[0], id: 3 };
await wrapper.setProps({ jobs: [...jobs, additionalJob] });
// verify new data is displayed
expect(wrapper.find("tbody").findAll("tr").length).toBe(4);
expect(countVisibleRows(wrapper)).toBe(4);
// verify first row is still expanded
expect(wrapper.vm.toggledItems["1"]).toBeTruthy();
expect(wrapper.find(".expanded").exists()).toBeTruthy();
});
});

/** When expanding a row, a hidden `<tr>` may be added like:
* ```
* <tr aria-hidden="true" role="presentation" class="d-none"></tr>
* ```
* and this function will count rows other than these hidden ones.
*/
function countVisibleRows(wrapper) {
const rows = wrapper.find("tbody").find("tbody").findAll("tr");
const visibleRows = rows.filter((row) => {
// only count rows that are not hidden
return !(row.attributes("aria-hidden") && row.attributes("aria-hidden") === "true");
});
return visibleRows.length;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createTestingPinia } from "@pinia/testing";
import { shallowMount } from "@vue/test-utils";
import { getLocalVue } from "tests/jest/helpers";

Expand All @@ -15,10 +16,12 @@ describe("WorkflowInvocationSummary.vue with terminal invocation", () => {
invocation: invocationData,
invocationAndJobTerminal: true,
invocationSchedulingTerminal: true,
jobStatesSummary: {},
};
wrapper = shallowMount(WorkflowInvocationSummary, {
propsData,
localVue,
pinia: createTestingPinia(),
});
});

Expand All @@ -42,6 +45,7 @@ describe("WorkflowInvocationSummary.vue with invocation scheduling running", ()
invocation: invocationData,
invocationAndJobTerminal: false,
invocationSchedulingTerminal: false,
jobStatesSummary: {},
};
wrapper = shallowMount(WorkflowInvocationSummary, {
store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const invocationPdfLink = computed<string | null>(() => {
});
const hasMessages = computed<boolean>(() => {
return !!props.invocation?.messages.length;
return props.invocation?.messages.length ? true : false;
});
const stepStatesStr = computed<string>(() => {
Expand Down

0 comments on commit 91a8b7b

Please sign in to comment.