1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { getNewExtraToken, initAuth } from "./auth-action";
6 import { API_TOKEN_KEY } from "~/services/auth-service/auth-service";
8 import 'jest-localstorage-mock';
9 import { ServiceRepository, createServices } from "~/services/services";
10 import { configureStore, RootStore } from "../store";
11 import { createBrowserHistory } from "history";
12 import { Config, mockConfig } from '~/common/config';
13 import { ApiActions } from "~/services/api/api-actions";
14 import { ACCOUNT_LINK_STATUS_KEY } from '~/services/link-account-service/link-account-service';
15 import Axios from "axios";
16 import MockAdapter from "axios-mock-adapter";
17 import { ImportMock } from 'ts-mock-imports';
18 import * as servicesModule from "~/services/services";
19 import { SessionStatus } from "~/models/session";
20 import { openRunProcess } from './workflow-panel-actions';
21 import { runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
22 import { initialize } from 'redux-form';
23 import { RUN_PROCESS_BASIC_FORM } from '~/views/run-process-panel/run-process-basic-form';
24 import { RUN_PROCESS_INPUTS_FORM } from '~/views/run-process-panel/run-process-inputs-form';
26 describe('workflow-panel-actions', () => {
27 const axiosInst = Axios.create({ headers: {} });
28 const axiosMock = new MockAdapter(axiosInst);
31 let services: ServiceRepository;
32 const config: any = {};
33 const actions: ApiActions = {
34 progressFn: (id: string, working: boolean) => { },
35 errorFn: (id: string, message: string) => { }
37 let importMocks: any[];
41 services = createServices(mockConfig({}), actions, axiosInst);
42 store = configureStore(createBrowserHistory(), services, config);
48 importMocks.map(m => m.restore());
51 it('opens the run process panel', async () => {
53 uuid: "zzzzz-7fd4e-0123456789abcde",
56 definition: "$graph: []"
67 const dispatchMock = jest.fn();
68 const dispatchWrapper = (action: any) => {
70 return store.dispatch(action);
73 await openRunProcess("zzzzz-7fd4e-0123456789abcde", "zzzzz-tpzed-0123456789abcde", "testing", { inputparm: "value" })(dispatchWrapper, store.getState, services);
74 expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_WORKFLOWS(wflist));
75 expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_SELECTED_WORKFLOW(wflist[0]));
76 expect(dispatchMock).toHaveBeenCalledWith(runProcessPanelActions.SET_PROCESS_OWNER_UUID("zzzzz-tpzed-0123456789abcde"));
77 expect(dispatchMock).toHaveBeenCalledWith(initialize(RUN_PROCESS_BASIC_FORM, { name: "testing" }));
78 expect(dispatchMock).toHaveBeenCalledWith(initialize(RUN_PROCESS_INPUTS_FORM, { inputparm: "value" }));