1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { API_TOKEN_KEY } from "services/auth-service/auth-service";
7 import 'jest-localstorage-mock';
8 import { ServiceRepository, createServices } from "services/services";
9 import { configureStore, RootStore } from "../store";
10 import { createBrowserHistory } from "history";
11 import { Config, mockConfig } from 'common/config';
12 import { ApiActions } from "services/api/api-actions";
13 import { ACCOUNT_LINK_STATUS_KEY } from 'services/link-account-service/link-account-service';
14 import Axios from "axios";
15 import MockAdapter from "axios-mock-adapter";
16 import { ImportMock } from 'ts-mock-imports';
17 import * as servicesModule from "services/services";
18 import { SessionStatus } from "models/session";
19 import { openRunProcess } from './workflow-panel-actions';
20 import { runProcessPanelActions } from 'store/run-process-panel/run-process-panel-actions';
21 import { initialize } from 'redux-form';
22 import { RUN_PROCESS_BASIC_FORM } from 'views/run-process-panel/run-process-basic-form';
23 import { RUN_PROCESS_INPUTS_FORM } from 'views/run-process-panel/run-process-inputs-form';
24 import { ResourceKind } from 'models/resource';
25 import { WorkflowResource } from 'models/workflow';
27 describe('workflow-panel-actions', () => {
28 const axiosInst = Axios.create({ headers: {} });
29 const axiosMock = new MockAdapter(axiosInst);
32 let services: ServiceRepository;
33 const config: any = {};
34 const actions: ApiActions = {
35 progressFn: (id: string, working: boolean) => { },
36 errorFn: (id: string, message: string) => { }
38 let importMocks: any[];
42 services = createServices(mockConfig({}), actions, axiosInst);
43 store = configureStore(createBrowserHistory(), services, config);
49 importMocks.map(m => m.restore());
52 it('opens the run process panel', async () => {
53 const wflist: WorkflowResource[] = [{
54 uuid: "zzzzz-7fd4e-0123456789abcde",
57 definition: "$graph: []",
58 kind: ResourceKind.WORKFLOW,
61 modifiedByClientUuid: "",
62 modifiedByUserUuid: "",
76 const dispatchMock = jest.fn();
77 const dispatchWrapper = (action: any) => {
79 return store.dispatch(action);
82 await openRunProcess("zzzzz-7fd4e-0123456789abcde", "zzzzz-tpzed-0123456789abcde", "testing", { inputparm: "value" })(dispatchWrapper, store.getState, services);
83 expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_WORKFLOWS(wflist));
84 expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_SELECTED_WORKFLOW(wflist[0]));
85 expect(dispatchMock).toHaveBeenCalledWith(initialize(RUN_PROCESS_BASIC_FORM, { name: "testing" }));
86 expect(dispatchMock).toHaveBeenCalledWith(initialize(RUN_PROCESS_INPUTS_FORM, { inputparm: "value" }));