1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { isEqual } from "lodash";
6 import { createServices } from "services/services";
7 import { configureStore } from "../store";
8 import { createBrowserHistory } from "history";
9 import { mockConfig } from 'common/config';
10 import Axios from "axios";
11 import MockAdapter from "axios-mock-adapter";
12 import { openRunProcess } from './workflow-panel-actions';
13 import { runProcessPanelActions } from 'store/run-process-panel/run-process-panel-actions';
14 import { initialize } from 'redux-form';
15 import { RUN_PROCESS_INPUTS_FORM, RUN_PROCESS_BASIC_FORM } from 'store/run-process-panel/run-process-panel-actions';
16 import { ResourceKind } from 'models/resource';
18 describe('workflow-panel-actions', () => {
19 const axiosInst = Axios.create({ headers: {} });
20 const axiosMock = new MockAdapter(axiosInst);
26 progressFn: (id, working) => { },
27 errorFn: (id, message) => { }
33 services = createServices(mockConfig({}), actions, axiosInst);
34 store = configureStore(createBrowserHistory(), services, config);
40 importMocks.map(m => m.restore());
43 it('opens the run process panel', async () => {
45 uuid: "zzzzz-7fd4e-0123456789abcde",
48 definition: "$graph: []",
49 kind: ResourceKind.WORKFLOW,
52 modifiedByUserUuid: "",
66 const dispatchMock = cy.spy().as('dispatchMock');
67 const dispatchWrapper = (action ) => {
69 return store.dispatch(action);
72 const expectedBasicArgs = {
73 type: "@@redux-form/INITIALIZE",
75 form: RUN_PROCESS_BASIC_FORM,
84 await openRunProcess("zzzzz-7fd4e-0123456789abcde", "zzzzz-tpzed-0123456789abcde", "testing", { inputparm: "value" })(dispatchWrapper, store.getState, services);
85 cy.get('@dispatchMock').then((dispatchMock) => {
86 expect(dispatchMock).to.be.calledWith(runProcessPanelActions.SET_WORKFLOWS(wflist));
87 expect(dispatchMock).to.be.calledWith(runProcessPanelActions.SET_SELECTED_WORKFLOW(wflist[0]));
88 expect(arrayDeeplyIncludesObject(dispatchMock.args, expectedBasicArgs)).to.be.true;
89 expect(dispatchMock).to.be.calledWith(initialize(RUN_PROCESS_INPUTS_FORM, { inputparm: "value" }));
94 const arrayDeeplyIncludesObject = (array, object) => {
95 return array.some((item) => {
96 if (isEqual(item, object)) {
99 if (typeof item === 'object') {
100 return arrayDeeplyIncludesObject(Object.values(item), object);