1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { configure } from 'enzyme';
7 import Adapter from 'enzyme-adapter-react-16';
8 import { copyProcess } from './process-copy-actions';
9 import { CommonService } from 'services/common-service/common-service';
10 import { snakeCase } from 'lodash';
12 configure({ adapter: new Adapter() });
14 describe('ProcessCopyAction', () => {
16 let dispatch: any, getState: any, services: any;
18 let sampleFailedProcess = {
23 "--project-uuid=zzzzz-j7d0g-yr18k784zplfeza",
24 "/var/lib/cwl/workflow.json#main",
25 "/var/lib/cwl/cwl.input.json",
28 container_count_max: 10,
29 container_image: "arvados/jobs",
30 container_uuid: "zzzzz-dz642-b9j9dtk1yikp9h0",
31 created_at: "2023-01-23T22:50:50.788284000Z",
32 cumulative_cost: 0.00120553009559028,
33 cwd: "/var/spool/cwl",
34 description: "test decsription",
36 etag: "2es6px6q7uo0yqi2i291x8gd6",
39 href: "/container_requests/zzzzz-xvhdp-111111111111111",
40 kind: "arvados#containerRequest",
41 log_uuid: "zzzzz-4zz18-a1gxqy9o6zyrdy8",
42 modified_at: "2023-01-24T21:13:54.772612000Z",
43 modified_by_client_uuid: "zzzzz-ozdt8-q6dzdi1lcc03155",
44 modified_by_user_uuid: "jutro-tpzed-vllbpebicy84rd5",
46 "/var/lib/cwl/cwl.input.json": {
51 basename: "logo.ai.no.whitespace.png",
54 "keep:5d3238c4db721a92c98b0305a47b0485+75/logo.ai.no.whitespace.png",
59 exclude_from_output: false,
63 portable_data_hash: "",
68 "/var/lib/cwl/workflow.json": {
75 doc: "Reverse the lines in a document, then sort those lines.",
80 doc: "The input file to be processed.",
86 doc: "If true, reverse (decending) sort",
87 id: "#main/reverse_sort",
93 doc: "The output with the lines reversed and sorted.",
95 outputSource: "#main/sorted/output",
102 in: [{ id: "#main/rev/input", source: "#main/input" }],
103 out: ["#main/rev/output"],
109 { id: "#main/sorted/input", source: "#main/rev/output" },
111 id: "#main/sorted/reverse",
112 source: "#main/reverse_sort",
115 out: ["#main/sorted/output"],
116 run: "#sorttool.cwl",
122 class: "CommandLineTool",
123 doc: "Reverse each line using the `rev` command",
124 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
127 { id: "#revtool.cwl/input", inputBinding: {}, type: "File" },
131 id: "#revtool.cwl/output",
132 outputBinding: { glob: "output.txt" },
136 stdout: "output.txt",
140 class: "CommandLineTool",
141 doc: "Sort lines using the `sort` command",
142 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
146 id: "#sorttool.cwl/reverse",
147 inputBinding: { position: 1, prefix: "-r" },
151 id: "#sorttool.cwl/input",
152 inputBinding: { position: 2 },
158 id: "#sorttool.cwl/output",
159 outputBinding: { glob: "output.txt" },
163 stdout: "output.txt",
169 exclude_from_output: false,
173 portable_data_hash: "",
183 exclude_from_output: false,
187 portable_data_hash: "",
197 exclude_from_output: false,
200 path: "/var/spool/cwl/cwl.output.json",
201 portable_data_hash: "",
207 name: "Copy of: Copy of: Copy of: revsort.cwl",
208 output_name: "Output from revsort.cwl",
209 output_path: "/var/spool/cwl",
210 output_properties: { key: "val" },
211 output_storage_classes: ["default"],
213 output_uuid: "zzzzz-4zz18-wolwlyfxmlhmgd4",
214 owner_uuid: "zzzzz-j7d0g-yr18k784zplfeza",
217 template_uuid: "zzzzz-7fd4e-7xsza0vgfe785cy",
218 workflowName: "revsort.cwl",
220 requesting_container_uuid: null,
221 runtime_constraints: {
223 cuda: { device_count: 0, driver_version: "", hardware_capability: "" },
230 scheduling_parameters: {
237 uuid: "zzzzz-xvhdp-111111111111111",
240 let expectedContainerRequest = {
242 "arvados-cwl-runner",
245 "--project-uuid=zzzzz-j7d0g-yr18k784zplfeza",
246 "/var/lib/cwl/workflow.json#main",
247 "/var/lib/cwl/cwl.input.json",
249 container_count_max: 10,
250 container_image: "arvados/jobs",
251 cwd: "/var/spool/cwl",
252 description: "test decsription",
254 kind: "arvados#containerRequest",
256 "/var/lib/cwl/cwl.input.json": {
261 basename: "logo.ai.no.whitespace.png",
264 "keep:5d3238c4db721a92c98b0305a47b0485+75/logo.ai.no.whitespace.png",
269 exclude_from_output: false,
273 portable_data_hash: "",
278 "/var/lib/cwl/workflow.json": {
285 doc: "Reverse the lines in a document, then sort those lines.",
290 doc: "The input file to be processed.",
296 doc: "If true, reverse (decending) sort",
297 id: "#main/reverse_sort",
303 doc: "The output with the lines reversed and sorted.",
305 outputSource: "#main/sorted/output",
312 in: [{ id: "#main/rev/input", source: "#main/input" }],
313 out: ["#main/rev/output"],
320 id: "#main/sorted/input",
321 source: "#main/rev/output",
324 id: "#main/sorted/reverse",
325 source: "#main/reverse_sort",
328 out: ["#main/sorted/output"],
329 run: "#sorttool.cwl",
335 class: "CommandLineTool",
336 doc: "Reverse each line using the `rev` command",
337 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
341 id: "#revtool.cwl/input",
348 id: "#revtool.cwl/output",
349 outputBinding: { glob: "output.txt" },
353 stdout: "output.txt",
357 class: "CommandLineTool",
358 doc: "Sort lines using the `sort` command",
359 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
363 id: "#sorttool.cwl/reverse",
364 inputBinding: { position: 1, prefix: "-r" },
368 id: "#sorttool.cwl/input",
369 inputBinding: { position: 2 },
375 id: "#sorttool.cwl/output",
376 outputBinding: { glob: "output.txt" },
380 stdout: "output.txt",
386 exclude_from_output: false,
390 portable_data_hash: "",
400 exclude_from_output: false,
404 portable_data_hash: "",
414 exclude_from_output: false,
417 path: "/var/spool/cwl/cwl.output.json",
418 portable_data_hash: "",
425 output_name: "Output from revsort.cwl",
426 output_path: "/var/spool/cwl",
427 output_properties: { key: "val" },
428 output_storage_classes: ["default"],
430 owner_uuid: "zzzzz-j7d0g-000000000000000",
433 template_uuid: "zzzzz-7fd4e-7xsza0vgfe785cy",
434 workflowName: "revsort.cwl",
436 runtime_constraints: {
441 hardware_capability: "",
448 scheduling_parameters: {
453 state: "Uncommitted",
458 dispatch = jest.fn();
460 containerRequestService: {
461 get: jest.fn().mockImplementation(async () => (CommonService.mapResponseKeys({data: sampleFailedProcess}))),
462 create: jest.fn().mockImplementation(async (data) => (CommonService.mapKeys(snakeCase)(data))),
470 it("should request the failed process and return a copy with the proper fields", async () => {
472 const newprocess = await copyProcess({
474 uuid: "zzzzz-xvhdp-111111111111111",
475 ownerUuid: "zzzzz-j7d0g-000000000000000",
476 })(dispatch, getState, services);
479 expect(services.containerRequestService.get).toHaveBeenCalledWith("zzzzz-xvhdp-111111111111111");
480 expect(newprocess).toEqual(expectedContainerRequest);