// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { combineReducers, createStore } from "redux"; import { ThemeProvider, StyledEngineProvider, } from "@mui/material"; import { CustomTheme } from 'common/custom-theme'; import { Provider } from 'react-redux'; import { ProcessIOCard, ProcessIOCardType } from './process-io-card'; import { MemoryRouter } from 'react-router-dom'; describe('renderers', () => { let store; describe('ProcessStatus', () => { beforeEach(() => { store = createStore(combineReducers({ auth: (state = {}, action) => { return {...state, config: {} } }, collectionPanel: (state = {}, action) => state, collectionPanelFiles: (state = {}, action) => { return {...state, item: { portableDataHash: '12345'} } }, })); }); it('shows main process input loading when raw or params null', () => { // when cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=conditional-tab]').should('not.exist'); cy.get('[data-cy=process-io-circular-progress]').should('exist'); }); // when cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=conditional-tab]').should('not.exist'); cy.get('[data-cy=process-io-circular-progress]').should('exist'); }); }); it('shows main process empty params and raw', () => { // when cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=conditional-tab]').should('not.exist'); cy.get('[data-cy=process-io-circular-progress]').should('not.exist'); cy.get('[data-cy=default-view]').should('exist').within(() => { cy.contains('No parameters found'); }); }); }); it('shows main process with raw', () => { // when const raw = {some: 'data'}; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=conditional-tab]').should('exist'); cy.get('[data-cy=process-io-circular-progress]').should('not.exist'); cy.get('[data-cy=virtual-code-snippet]').should('exist').within(() => { cy.contains(JSON.stringify(raw, null, 2).replace(/\n/g, '')); }); }); }); it('shows main process with params', () => { // when const parameters = [{id: 'someId', label: 'someLabel', value: {display: 'someValue'}}]; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=process-io-circular-progress]').should('not.exist'); cy.get('[data-cy=conditional-tab]').should('have.length', 2); // Empty raw is shown if parameters are present cy.get('tbody').should('exist').within(() => { cy.contains('someId'); cy.contains('someLabel'); cy.contains('someValue'); }); }); }); it('shows main process with output collection', () => { // when const outputCollection = '987654321'; const parameters = [{id: 'someId', label: 'someLabel', value: {display: 'someValue'}}]; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=process-io-circular-progress]').should('not.exist'); cy.get('[data-cy=conditional-tab]').should('have.length', 3); // Empty raw is shown if parameters are present cy.get('tbody').should('exist').within(() => { cy.contains('someId'); cy.contains('someLabel'); cy.contains('someValue'); }); }); // Visit output tab cy.get('[data-cy=conditional-tab]').contains('Collection').should('exist').click(); cy.get('[data-cy=collection-files-panel]').should('exist'); cy.get('[data-cy=output-uuid-display]').should('contain', outputCollection); }); // Subprocess it('shows subprocess loading', () => { // when const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}}; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=conditional-tab]').should('not.exist'); cy.get('[data-cy=subprocess-circular-progress]').should('exist'); }); }); it('shows subprocess mounts', () => { // when const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}}; const sampleMount = {path: '/', pdh: 'abcdef12abcdef12abcdef12abcdef12+0'}; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=subprocess-circular-progress]').should('not.exist'); cy.getAll('[data-cy=conditional-tab]').should('have.length', 1); // Empty raw is shown if parameters are present cy.get('tbody').should('exist').within(() => { cy.contains(sampleMount.pdh); }); }); }); it('shows subprocess output collection', () => { // when const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}}; const outputCollection = '123456789'; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=process-io-circular-progress]').should('not.exist'); cy.get('[data-cy=conditional-tab]').should('have.length', 1); // Empty raw is shown if parameters are present cy.get('[data-cy=output-uuid-display]').should('contain', outputCollection); }); }); it('shows empty subprocess raw', () => { // when const subprocess = {containerRequest: {requestingContainerUuid: 'xyz'}}; const outputCollection = '123456789'; cy.mount( ); // then cy.get('[data-cy=process-io-card]').within(() => { cy.get('[data-cy=process-io-circular-progress]').should('not.exist'); cy.get('[data-cy=conditional-tab]').should('have.length', 2); // Empty raw is shown if parameters are present cy.get('[data-cy=conditional-tab]').eq(1).should('exist') cy.get('[data-cy=output-uuid-display]').should('contain', outputCollection); }); }); }); });