1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { combineReducers, createStore } from "redux";
10 } from "@mui/material";
11 import { CustomTheme } from 'common/custom-theme';
12 import { Provider } from 'react-redux';
13 import { ProcessIOCard, ProcessIOCardType } from './process-io-card';
14 import { MemoryRouter } from 'react-router-dom';
16 describe('renderers', () => {
19 describe('ProcessStatus', () => {
22 store = createStore(combineReducers({
23 auth: (state = {}, action) => { return {...state, config: {} } },
24 collectionPanel: (state = {}, action) => state,
25 collectionPanelFiles: (state = {}, action) => { return {...state, item: { portableDataHash: '12345'} } },
29 it('shows main process input loading when raw or params null', () => {
32 <Provider store={store}>
33 <StyledEngineProvider injectFirst>
34 <ThemeProvider theme={CustomTheme}>
36 label={ProcessIOCardType.INPUT}
37 process={false} // Treat as a main process, no requestingContainerUuid
42 </StyledEngineProvider>
47 cy.get('[data-cy=process-io-card]').within(() => {
48 cy.get('[data-cy=conditional-tab]').should('not.exist');
49 cy.get('[data-cy=process-io-circular-progress]').should('exist');
54 <Provider store={store}>
55 <StyledEngineProvider injectFirst>
56 <ThemeProvider theme={CustomTheme}>
58 label={ProcessIOCardType.INPUT}
59 process={false} // Treat as a main process, no requestingContainerUuid
64 </StyledEngineProvider>
69 cy.get('[data-cy=process-io-card]').within(() => {
70 cy.get('[data-cy=conditional-tab]').should('not.exist');
71 cy.get('[data-cy=process-io-circular-progress]').should('exist');
75 it('shows main process empty params and raw', () => {
78 <Provider store={store}>
79 <StyledEngineProvider injectFirst>
80 <ThemeProvider theme={CustomTheme}>
82 label={ProcessIOCardType.INPUT}
83 process={false} // Treat as a main process, no requestingContainerUuid
88 </StyledEngineProvider>
93 cy.get('[data-cy=process-io-card]').within(() => {
94 cy.get('[data-cy=conditional-tab]').should('not.exist');
95 cy.get('[data-cy=process-io-circular-progress]').should('not.exist');
96 cy.get('[data-cy=default-view]').should('exist').within(() => {
97 cy.contains('No parameters found');
102 it('shows main process with raw', () => {
104 const raw = {some: 'data'};
106 <Provider store={store}>
107 <StyledEngineProvider injectFirst>
108 <ThemeProvider theme={CustomTheme}>
110 label={ProcessIOCardType.INPUT}
111 process={false} // Treat as a main process, no requestingContainerUuid
116 </StyledEngineProvider>
121 cy.get('[data-cy=process-io-card]').within(() => {
122 cy.get('[data-cy=conditional-tab]').should('exist');
123 cy.get('[data-cy=process-io-circular-progress]').should('not.exist');
124 cy.get('[data-cy=virtual-code-snippet]').should('exist').within(() => {
125 cy.contains(JSON.stringify(raw, null, 2).replace(/\n/g, ''));
130 it('shows main process with params', () => {
132 const parameters = [{id: 'someId', label: 'someLabel', value: {display: 'someValue'}}];
134 <Provider store={store}>
135 <StyledEngineProvider injectFirst>
136 <ThemeProvider theme={CustomTheme}>
138 label={ProcessIOCardType.INPUT}
139 process={false} // Treat as a main process, no requestingContainerUuid
144 </StyledEngineProvider>
149 cy.get('[data-cy=process-io-card]').within(() => {
150 cy.get('[data-cy=process-io-circular-progress]').should('not.exist');
151 cy.get('[data-cy=conditional-tab]').should('have.length', 2); // Empty raw is shown if parameters are present
152 cy.get('tbody').should('exist').within(() => {
153 cy.contains('someId');
154 cy.contains('someLabel');
155 cy.contains('someValue');
160 it('shows main process with output collection', () => {
162 const outputCollection = '987654321';
163 const parameters = [{id: 'someId', label: 'someLabel', value: {display: 'someValue'}}];
166 <Provider store={store}>
167 <StyledEngineProvider injectFirst>
168 <ThemeProvider theme={CustomTheme}>
170 label={ProcessIOCardType.OUTPUT}
171 process={false} // Treat as a main process, no requestingContainerUuid
172 outputUuid={outputCollection}
177 </StyledEngineProvider>
182 cy.get('[data-cy=process-io-card]').within(() => {
183 cy.get('[data-cy=process-io-circular-progress]').should('not.exist');
184 cy.get('[data-cy=conditional-tab]').should('have.length', 3); // Empty raw is shown if parameters are present
185 cy.get('tbody').should('exist').within(() => {
186 cy.contains('someId');
187 cy.contains('someLabel');
188 cy.contains('someValue');
193 cy.get('[data-cy=conditional-tab]').contains('Collection').should('exist').click();
194 cy.get('[data-cy=collection-files-panel]').should('exist');
195 cy.get('[data-cy=output-uuid-display]').should('contain', outputCollection);
200 it('shows subprocess loading', () => {
202 const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}};
204 <Provider store={store}>
205 <StyledEngineProvider injectFirst>
206 <ThemeProvider theme={CustomTheme}>
208 label={ProcessIOCardType.INPUT}
209 process={subprocess} // Treat as a subprocess without outputUuid
214 </StyledEngineProvider>
219 cy.get('[data-cy=process-io-card]').within(() => {
220 cy.get('[data-cy=conditional-tab]').should('not.exist');
221 cy.get('[data-cy=subprocess-circular-progress]').should('exist');
225 it('shows subprocess mounts', () => {
227 const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}};
228 const sampleMount = {path: '/', pdh: 'abcdef12abcdef12abcdef12abcdef12+0'};
230 <Provider store={store}>
232 <StyledEngineProvider injectFirst>
233 <ThemeProvider theme={CustomTheme}>
235 label={ProcessIOCardType.INPUT}
236 process={subprocess} // Treat as a subprocess without outputUuid
239 mounts={[sampleMount]}
242 </StyledEngineProvider>
248 cy.get('[data-cy=process-io-card]').within(() => {
249 cy.get('[data-cy=subprocess-circular-progress]').should('not.exist');
250 cy.getAll('[data-cy=conditional-tab]').should('have.length', 1); // Empty raw is shown if parameters are present
251 cy.get('tbody').should('exist').within(() => {
252 cy.contains(sampleMount.pdh);
257 it('shows subprocess output collection', () => {
259 const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}};
260 const outputCollection = '123456789';
262 <Provider store={store}>
263 <StyledEngineProvider injectFirst>
264 <ThemeProvider theme={CustomTheme}>
266 label={ProcessIOCardType.OUTPUT}
267 process={subprocess} // Treat as a subprocess with outputUuid
268 outputUuid={outputCollection}
273 </StyledEngineProvider>
278 cy.get('[data-cy=process-io-card]').within(() => {
279 cy.get('[data-cy=process-io-circular-progress]').should('not.exist');
280 cy.get('[data-cy=conditional-tab]').should('have.length', 1); // Empty raw is shown if parameters are present
281 cy.get('[data-cy=output-uuid-display]').should('contain', outputCollection);
285 it('shows empty subprocess raw', () => {
287 const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}};
288 const outputCollection = '123456789';
290 <Provider store={store}>
291 <StyledEngineProvider injectFirst>
292 <ThemeProvider theme={CustomTheme}>
294 label={ProcessIOCardType.OUTPUT}
295 process={subprocess} // Treat as a subprocess with outputUuid
296 outputUuid={outputCollection}
301 </StyledEngineProvider>
306 cy.get('[data-cy=process-io-card]').within(() => {
307 cy.get('[data-cy=process-io-circular-progress]').should('not.exist');
308 cy.get('[data-cy=conditional-tab]').should('have.length', 2); // Empty raw is shown if parameters are present
309 cy.get('[data-cy=conditional-tab]').eq(1).should('exist')
310 cy.get('[data-cy=output-uuid-display]').should('contain', outputCollection);