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_user_uuid: "jutro-tpzed-vllbpebicy84rd5",
45 "/var/lib/cwl/cwl.input.json": {
50 basename: "logo.ai.no.whitespace.png",
53 "keep:5d3238c4db721a92c98b0305a47b0485+75/logo.ai.no.whitespace.png",
58 exclude_from_output: false,
62 portable_data_hash: "",
67 "/var/lib/cwl/workflow.json": {
74 doc: "Reverse the lines in a document, then sort those lines.",
79 doc: "The input file to be processed.",
85 doc: "If true, reverse (decending) sort",
86 id: "#main/reverse_sort",
92 doc: "The output with the lines reversed and sorted.",
94 outputSource: "#main/sorted/output",
101 in: [{ id: "#main/rev/input", source: "#main/input" }],
102 out: ["#main/rev/output"],
108 { id: "#main/sorted/input", source: "#main/rev/output" },
110 id: "#main/sorted/reverse",
111 source: "#main/reverse_sort",
114 out: ["#main/sorted/output"],
115 run: "#sorttool.cwl",
121 class: "CommandLineTool",
122 doc: "Reverse each line using the `rev` command",
123 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
126 { id: "#revtool.cwl/input", inputBinding: {}, type: "File" },
130 id: "#revtool.cwl/output",
131 outputBinding: { glob: "output.txt" },
135 stdout: "output.txt",
139 class: "CommandLineTool",
140 doc: "Sort lines using the `sort` command",
141 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
145 id: "#sorttool.cwl/reverse",
146 inputBinding: { position: 1, prefix: "-r" },
150 id: "#sorttool.cwl/input",
151 inputBinding: { position: 2 },
157 id: "#sorttool.cwl/output",
158 outputBinding: { glob: "output.txt" },
162 stdout: "output.txt",
168 exclude_from_output: false,
172 portable_data_hash: "",
182 exclude_from_output: false,
186 portable_data_hash: "",
196 exclude_from_output: false,
199 path: "/var/spool/cwl/cwl.output.json",
200 portable_data_hash: "",
206 name: "Copy of: Copy of: Copy of: revsort.cwl",
207 output_name: "Output from revsort.cwl",
208 output_path: "/var/spool/cwl",
209 output_properties: { key: "val" },
210 output_storage_classes: ["default"],
212 output_uuid: "zzzzz-4zz18-wolwlyfxmlhmgd4",
213 owner_uuid: "zzzzz-j7d0g-yr18k784zplfeza",
216 template_uuid: "zzzzz-7fd4e-7xsza0vgfe785cy",
217 workflowName: "revsort.cwl",
219 requesting_container_uuid: null,
220 runtime_constraints: {
222 cuda: { device_count: 0, driver_version: "", hardware_capability: "" },
229 scheduling_parameters: {
236 uuid: "zzzzz-xvhdp-111111111111111",
239 let expectedContainerRequest = {
241 "arvados-cwl-runner",
244 "--project-uuid=zzzzz-j7d0g-yr18k784zplfeza",
245 "/var/lib/cwl/workflow.json#main",
246 "/var/lib/cwl/cwl.input.json",
248 container_count_max: 10,
249 container_image: "arvados/jobs",
250 cwd: "/var/spool/cwl",
251 description: "test decsription",
253 kind: "arvados#containerRequest",
255 "/var/lib/cwl/cwl.input.json": {
260 basename: "logo.ai.no.whitespace.png",
263 "keep:5d3238c4db721a92c98b0305a47b0485+75/logo.ai.no.whitespace.png",
268 exclude_from_output: false,
272 portable_data_hash: "",
277 "/var/lib/cwl/workflow.json": {
284 doc: "Reverse the lines in a document, then sort those lines.",
289 doc: "The input file to be processed.",
295 doc: "If true, reverse (decending) sort",
296 id: "#main/reverse_sort",
302 doc: "The output with the lines reversed and sorted.",
304 outputSource: "#main/sorted/output",
311 in: [{ id: "#main/rev/input", source: "#main/input" }],
312 out: ["#main/rev/output"],
319 id: "#main/sorted/input",
320 source: "#main/rev/output",
323 id: "#main/sorted/reverse",
324 source: "#main/reverse_sort",
327 out: ["#main/sorted/output"],
328 run: "#sorttool.cwl",
334 class: "CommandLineTool",
335 doc: "Reverse each line using the `rev` command",
336 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
340 id: "#revtool.cwl/input",
347 id: "#revtool.cwl/output",
348 outputBinding: { glob: "output.txt" },
352 stdout: "output.txt",
356 class: "CommandLineTool",
357 doc: "Sort lines using the `sort` command",
358 hints: [{ class: "ResourceRequirement", ramMin: 8 }],
362 id: "#sorttool.cwl/reverse",
363 inputBinding: { position: 1, prefix: "-r" },
367 id: "#sorttool.cwl/input",
368 inputBinding: { position: 2 },
374 id: "#sorttool.cwl/output",
375 outputBinding: { glob: "output.txt" },
379 stdout: "output.txt",
385 exclude_from_output: false,
389 portable_data_hash: "",
399 exclude_from_output: false,
403 portable_data_hash: "",
413 exclude_from_output: false,
416 path: "/var/spool/cwl/cwl.output.json",
417 portable_data_hash: "",
424 output_name: "Output from revsort.cwl",
425 output_path: "/var/spool/cwl",
426 output_properties: { key: "val" },
427 output_storage_classes: ["default"],
429 owner_uuid: "zzzzz-j7d0g-000000000000000",
432 template_uuid: "zzzzz-7fd4e-7xsza0vgfe785cy",
433 workflowName: "revsort.cwl",
435 runtime_constraints: {
440 hardware_capability: "",
447 scheduling_parameters: {
452 state: "Uncommitted",
457 dispatch = jest.fn();
459 containerRequestService: {
460 get: jest.fn().mockImplementation(async () => (CommonService.mapResponseKeys({data: sampleFailedProcess}))),
461 create: jest.fn().mockImplementation(async (data) => (CommonService.mapKeys(snakeCase)(data))),
469 it("should request the failed process and return a copy with the proper fields", async () => {
471 const newprocess = await copyProcess({
473 uuid: "zzzzz-xvhdp-111111111111111",
474 ownerUuid: "zzzzz-j7d0g-000000000000000",
475 })(dispatch, getState, services);
478 expect(services.containerRequestService.get).toHaveBeenCalledWith("zzzzz-xvhdp-111111111111111");
479 expect(newprocess).toEqual(expectedContainerRequest);