-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17203 from davelopez/migrate_invocation_store_pinia
Migrate workflow invocation store to Pinia
- Loading branch information
Showing
12 changed files
with
171 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import axios from "axios"; | ||
|
||
import { getAppRoot } from "@/onload"; | ||
|
||
import { ApiResponse } from "./schema"; | ||
|
||
// TODO: Replace these interfaces with real schema models after https://github.com/galaxyproject/galaxy/pull/16707 is merged | ||
export interface WorkflowInvocation { | ||
id: string; | ||
} | ||
|
||
export interface WorkflowInvocationJobsSummary { | ||
id: string; | ||
} | ||
|
||
export interface WorkflowInvocationStep { | ||
id: string; | ||
} | ||
|
||
// TODO: Replace these provisional functions with fetchers after https://github.com/galaxyproject/galaxy/pull/16707 is merged | ||
export async function fetchInvocationDetails(params: { id: string }): Promise<ApiResponse<WorkflowInvocation>> { | ||
const { data } = await axios.get(`${getAppRoot()}api/invocations/${params.id}`); | ||
return { | ||
data, | ||
} as ApiResponse<WorkflowInvocation>; | ||
} | ||
|
||
export async function fetchInvocationJobsSummary(params: { | ||
id: string; | ||
}): Promise<ApiResponse<WorkflowInvocationJobsSummary>> { | ||
const { data } = await axios.get(`${getAppRoot()}api/invocations/${params.id}/jobs_summary`); | ||
return { | ||
data, | ||
} as ApiResponse<WorkflowInvocationJobsSummary>; | ||
} | ||
|
||
export async function fetchInvocationStep(params: { id: string }): Promise<ApiResponse<WorkflowInvocationStep>> { | ||
const { data } = await axios.get(`${getAppRoot()}api/invocations//any/steps/${params.id}`); | ||
return { | ||
data, | ||
} as ApiResponse<WorkflowInvocationStep>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 0 additions & 80 deletions
80
client/src/components/WorkflowInvocationState/WorkflowInvocationState.test.js
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
client/src/components/WorkflowInvocationState/WorkflowInvocationState.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { createTestingPinia } from "@pinia/testing"; | ||
import { shallowMount, Wrapper } from "@vue/test-utils"; | ||
import flushPromises from "flush-promises"; | ||
import { setActivePinia } from "pinia"; | ||
import { getLocalVue } from "tests/jest/helpers"; | ||
|
||
import type { WorkflowInvocation } from "@/api/invocations"; | ||
import JOB_STATES_MODEL from "@/utils/job-states-model"; | ||
|
||
import invocationData from "../Workflow/test/json/invocation.json"; | ||
|
||
import WorkflowInvocationState from "./WorkflowInvocationState.vue"; | ||
|
||
const localVue = getLocalVue(); | ||
|
||
const selectors = { | ||
invocationSummary: ".invocation-summary", | ||
}; | ||
|
||
const invocationJobsSummaryById = { | ||
id: "d9833097445452b0", | ||
model: "WorkflowInvocation", | ||
states: {}, | ||
populated_state: "ok", | ||
}; | ||
|
||
async function mountWorkflowInvocationState(invocation: WorkflowInvocation | null) { | ||
const pinia = createTestingPinia(); | ||
setActivePinia(pinia); | ||
|
||
const wrapper = shallowMount(WorkflowInvocationState, { | ||
propsData: { | ||
invocationId: invocationData.id, | ||
}, | ||
computed: { | ||
invocation: () => invocation, | ||
jobStatesSummary: () => new JOB_STATES_MODEL.JobStatesSummary(invocationJobsSummaryById), | ||
}, | ||
pinia, | ||
localVue, | ||
}); | ||
await flushPromises(); | ||
return wrapper; | ||
} | ||
|
||
describe("WorkflowInvocationState.vue", () => { | ||
it("determines that invocation and job states are terminal with terminal invocation", async () => { | ||
const wrapper = await mountWorkflowInvocationState(invocationData); | ||
expect(isInvocationAndJobTerminal(wrapper)).toBe(true); | ||
}); | ||
|
||
it("determines that invocation and job states are not terminal with no invocation", async () => { | ||
const wrapper = await mountWorkflowInvocationState(null); | ||
expect(isInvocationAndJobTerminal(wrapper)).toBe(false); | ||
}); | ||
|
||
it("determines that invocation and job states are not terminal with non-terminal invocation", async () => { | ||
const invocation = { | ||
...invocationData, | ||
state: "new", | ||
}; | ||
const wrapper = await mountWorkflowInvocationState(invocation); | ||
expect(isInvocationAndJobTerminal(wrapper)).toBe(false); | ||
}); | ||
}); | ||
|
||
function isInvocationAndJobTerminal(wrapper: Wrapper<Vue>): boolean { | ||
const invocationSummary = wrapper.find(selectors.invocationSummary); | ||
// This is a somewhat hacky way to determine if the invocation and job states are terminal without | ||
// exposing the internals of the component. This is just to restore the previous behavior of the test | ||
// but it would be better to test this in a more appropriate way. | ||
return invocationSummary.exists() && invocationSummary.html().includes('invocationandjobterminal="true"'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.