1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { runProcess } from "./run-process-panel-actions";
7 jest.mock("../navigation/navigation-action", () => ({
8 navigateTo: (link: any) => link,
11 jest.mock("~/models/process", () => ({
12 createWorkflowMounts: jest.fn(),
15 jest.mock("redux-form", () => ({
16 reduxForm: () => (c: any) => c,
17 getFormValues: (name: string) => () => {
19 case "runProcessBasicForm":
21 name: "basicFormTestName",
22 description: "basicFormTestDescription",
24 case "runProcessInputsForm":
32 describe("run-process-panel-actions", () => {
33 describe("runProcess", () => {
34 const newProcessUUID = 'newProcessUUID';
35 let dispatch: any, getState: any, services: any;
40 containerRequestService: {
41 create: jest.fn().mockImplementation(async () => ({
48 it("should return when userUuid is null", async () => {
55 await runProcess(dispatch, getState, services);
58 expect(dispatch).not.toHaveBeenCalled();
61 it("should run workflow with project-uuid", async () => {
66 email: "test@gmail.com",
67 firstName: "TestFirstName",
68 lastName: "TestLastName",
69 uuid: "ce8i5-tpzed-yid70bw31f51234",
70 ownerUuid: "ce8i5-tpzed-000000000000000",
73 username: "testfirstname",
80 processPathname: "/projects/ce8i5-tpzed-yid70bw31f51234",
81 processOwnerUuid: "ce8i5-tpzed-yid70bw31f51234",
83 href: "/workflows/ce8i5-7fd4e-2tlnerdkxnl4fjt",
84 kind: "arvados#workflow",
85 etag: "8gh5xlhlgo61yqscyl1spw8tc",
86 uuid: "ce8i5-7fd4e-2tlnerdkxnl4fjt",
87 ownerUuid: "ce8i5-tpzed-o4njwilpp4ov321",
88 createdAt: "2020-07-15T19:40:50.296041000Z",
89 modifiedByClientUuid: "ce8i5-ozdt8-libnr89sc5nq111",
90 modifiedByUserUuid: "ce8i5-tpzed-o4njwilpp4ov321",
91 modifiedAt: "2020-07-15T19:40:50.296376000Z",
94 "Reverse the lines in a document, then sort those lines.",
96 '{\n "$graph": [\n {\n "class": "Workflow",\n "doc": "Reverse the lines in a document, then sort those lines.",\n "id": "#main",\n "hints":[{"class":"http://arvados.org/cwl#WorkflowRunnerResources","acrContainerImage":"arvados/jobs:2.0.4"}], "inputs": [\n {\n "default": null,\n "doc": "The input file to be processed.",\n "id": "#main/input",\n "type": "File"\n },\n {\n "default": true,\n "doc": "If true, reverse (decending) sort",\n "id": "#main/reverse_sort",\n "type": "boolean"\n }\n ],\n "outputs": [\n {\n "doc": "The output with the lines reversed and sorted.",\n "id": "#main/output",\n "outputSource": "#main/sorted/output",\n "type": "File"\n }\n ],\n "steps": [\n {\n "id": "#main/rev",\n "in": [\n {\n "id": "#main/rev/input",\n "source": "#main/input"\n }\n ],\n "out": [\n "#main/rev/output"\n ],\n "run": "#revtool.cwl"\n },\n {\n "id": "#main/sorted",\n "in": [\n {\n "id": "#main/sorted/input",\n "source": "#main/rev/output"\n },\n {\n "id": "#main/sorted/reverse",\n "source": "#main/reverse_sort"\n }\n ],\n "out": [\n "#main/sorted/output"\n ],\n "run": "#sorttool.cwl"\n }\n ]\n },\n {\n "baseCommand": "rev",\n "class": "CommandLineTool",\n "doc": "Reverse each line using the `rev` command",\n "hints": [\n {\n "class": "ResourceRequirement",\n "ramMin": 8\n }\n ],\n "id": "#revtool.cwl",\n "inputs": [\n {\n "id": "#revtool.cwl/input",\n "inputBinding": {},\n "type": "File"\n }\n ],\n "outputs": [\n {\n "id": "#revtool.cwl/output",\n "outputBinding": {\n "glob": "output.txt"\n },\n "type": "File"\n }\n ],\n "stdout": "output.txt"\n },\n {\n "baseCommand": "sort",\n "class": "CommandLineTool",\n "doc": "Sort lines using the `sort` command",\n "hints": [\n {\n "class": "ResourceRequirement",\n "ramMin": 8\n }\n ],\n "id": "#sorttool.cwl",\n "inputs": [\n {\n "id": "#sorttool.cwl/reverse",\n "inputBinding": {\n "position": 1,\n "prefix": "-r"\n },\n "type": "boolean"\n },\n {\n "id": "#sorttool.cwl/input",\n "inputBinding": {\n "position": 2\n },\n "type": "File"\n }\n ],\n "outputs": [\n {\n "id": "#sorttool.cwl/output",\n "outputBinding": {\n "glob": "output.txt"\n },\n "type": "File"\n }\n ],\n "stdout": "output.txt"\n }\n ],\n "cwlVersion": "v1.0"\n}',
102 await runProcess(dispatch, getState, services);
105 expect(services.containerRequestService.create).toHaveBeenCalledWith({
107 "arvados-cwl-runner",
110 "--project-uuid=ce8i5-tpzed-yid70bw31f51234",
111 "/var/lib/cwl/workflow.json#main",
112 "/var/lib/cwl/cwl.input.json",
114 containerImage: "arvados/jobs:2.0.4",
115 cwd: "/var/spool/cwl",
116 description: "basicFormTestDescription",
118 name: "basicFormTestName",
119 outputName: undefined,
120 outputPath: "/var/spool/cwl",
121 ownerUuid: "ce8i5-tpzed-yid70bw31f51234",
124 workflowName: "revsort.cwl",
125 workflowUuid: "ce8i5-7fd4e-2tlnerdkxnl4fjt",
127 runtimeConstraints: {
132 schedulingParameters: { max_run_time: undefined },
137 expect(dispatch).toHaveBeenCalledWith(newProcessUUID);