[ARVADOS-WORKBENCH2] updated: 2.3.0-28-gaac3dfbe
Git user
git at public.arvados.org
Tue Dec 7 22:23:50 UTC 2021
Summary of changes:
cypress/integration/project.spec.js | 4 -
.../collection-panel-files2.test.tsx | 116 -----------------
.../collection-panel-files2.tsx | 139 ---------------------
src/components/data-explorer/data-explorer.tsx | 9 +-
src/components/search-input/search-input.test.tsx | 26 ++--
5 files changed, 20 insertions(+), 274 deletions(-)
delete mode 100644 src/components/collection-panel-files/collection-panel-files2.test.tsx
delete mode 100644 src/components/collection-panel-files/collection-panel-files2.tsx
via aac3dfbed3d02cc6a2240add62439ee0dda3f335 (commit)
from 91fdf9e2d937de38309f1464b30cb699df4f6389 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit aac3dfbed3d02cc6a2240add62439ee0dda3f335
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Tue Dec 7 23:21:38 2021 +0100
17579: Fixed test issues removed not required files
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/cypress/integration/project.spec.js b/cypress/integration/project.spec.js
index 4d77d3a5..9b629438 100644
--- a/cypress/integration/project.spec.js
+++ b/cypress/integration/project.spec.js
@@ -200,10 +200,6 @@ describe('Project tests', function() {
name: `Test root project ${Math.floor(Math.random() * 999999)}`,
group_class: 'project',
}).as('testProject1');
- cy.createGroup(activeUser.token, {
- name: `Test root project ${Math.floor(Math.random() * 999999)}`,
- group_class: 'project',
- }).as('testProject2');
cy.getAll('@testProject1', '@testProject2').then(function([testProject1, testProject2]) {
cy.loginAs(activeUser);
diff --git a/src/components/collection-panel-files/collection-panel-files2.test.tsx b/src/components/collection-panel-files/collection-panel-files2.test.tsx
deleted file mode 100644
index 4d8b8150..00000000
--- a/src/components/collection-panel-files/collection-panel-files2.test.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import React from "react";
-import { configure, shallow, mount } from "enzyme";
-import { WithStyles } from "@material-ui/core";
-import Adapter from "enzyme-adapter-react-16";
-import { TreeItem, TreeItemStatus } from '../tree/tree';
-import { FileTreeData } from '../file-tree/file-tree-data';
-import { CollectionFileType } from "../../models/collection-file";
-import { CollectionPanelFilesComponent, CollectionPanelFilesProps, CssRules } from './collection-panel-files2';
-import { SearchInput } from '../search-input/search-input';
-
-configure({ adapter: new Adapter() });
-
-jest.mock('components/file-tree/file-tree', () => ({
- FileTree: () => 'FileTree',
-}));
-
-describe('<CollectionPanelFiles />', () => {
- let props: CollectionPanelFilesProps & WithStyles<CssRules>;
-
- beforeEach(() => {
- props = {
- classes: {} as Record<CssRules, string>,
- items: [],
- isWritable: true,
- isLoading: false,
- tooManyFiles: false,
- onUploadDataClick: jest.fn(),
- onSearchChange: jest.fn(),
- onItemMenuOpen: jest.fn(),
- onOptionsMenuOpen: jest.fn(),
- onSelectionToggle: jest.fn(),
- onCollapseToggle: jest.fn(),
- onFileClick: jest.fn(),
- loadFilesFunc: jest.fn(),
- currentItemUuid: '',
- };
- });
-
- it('renders properly', () => {
- // when
- const wrapper = shallow(<CollectionPanelFilesComponent {...props} />);
-
- // then
- expect(wrapper).not.toBeUndefined();
- });
-
- it('filters out files', () => {
- // given
- const searchPhrase = 'test';
- const items: Array<TreeItem<FileTreeData>> = [
- {
- data: {
- url: '',
- type: CollectionFileType.DIRECTORY,
- name: 'test',
- },
- id: '1',
- open: true,
- active: true,
- status: TreeItemStatus.LOADED,
- },
- {
- data: {
- url: '',
- type: CollectionFileType.FILE,
- name: 'test123',
- },
- id: '2',
- open: true,
- active: true,
- status: TreeItemStatus.LOADED,
- },
- {
- data: {
- url: '',
- type: CollectionFileType.FILE,
- name: 'another-file',
- },
- id: '3',
- open: true,
- active: true,
- status: TreeItemStatus.LOADED,
- }
- ];
-
- // setup
- props.items = items;
- const wrapper = mount(<CollectionPanelFilesComponent {...props} />);
- wrapper.find(SearchInput).simulate('change', { target: { value: searchPhrase } });
-
- // when
- setTimeout(() => { // we have to use set timeout because of the debounce
- expect(wrapper.find('FileTree').prop('items'))
- .toEqual([
- {
- data: { url: '', type: 'directory', name: 'test' },
- id: '1',
- open: true,
- active: true,
- status: 'loaded'
- },
- {
- data: { url: '', type: 'file', name: 'test123' },
- id: '2',
- open: true,
- active: true,
- status: 'loaded'
- }
- ]);
- }, 0);
- });
-});
\ No newline at end of file
diff --git a/src/components/collection-panel-files/collection-panel-files2.tsx b/src/components/collection-panel-files/collection-panel-files2.tsx
deleted file mode 100644
index 481844d9..00000000
--- a/src/components/collection-panel-files/collection-panel-files2.tsx
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import React from 'react';
-import { TreeItem, TreeItemStatus } from 'components/tree/tree';
-import { FileTreeData } from 'components/file-tree/file-tree-data';
-import { FileTree } from 'components/file-tree/file-tree';
-import { IconButton, Grid, Typography, StyleRulesCallback, withStyles, WithStyles, CardHeader, Card, Button, Tooltip, CircularProgress } from '@material-ui/core';
-import { CustomizeTableIcon } from 'components/icon/icon';
-import { DownloadIcon } from 'components/icon/icon';
-import { SearchInput } from '../search-input/search-input';
-
-export interface CollectionPanelFilesProps {
- items: Array<TreeItem<FileTreeData>>;
- isWritable: boolean;
- isLoading: boolean;
- tooManyFiles: boolean;
- onUploadDataClick: () => void;
- onSearchChange: (searchValue: string) => void;
- onItemMenuOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>, isWritable: boolean) => void;
- onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>, isWritable: boolean) => void;
- onSelectionToggle: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
- onCollapseToggle: (id: string, status: TreeItemStatus) => void;
- onFileClick: (id: string) => void;
- loadFilesFunc: () => void;
- currentItemUuid?: string;
-}
-
-export type CssRules = 'root' | 'cardSubheader' | 'nameHeader' | 'fileSizeHeader' | 'uploadIcon' | 'button' | 'centeredLabel' | 'cardHeaderContent' | 'cardHeaderContentTitle';
-
-const styles: StyleRulesCallback<CssRules> = theme => ({
- root: {
- paddingBottom: theme.spacing.unit,
- height: '100%'
- },
- cardSubheader: {
- paddingTop: 0,
- paddingBottom: 0,
- minHeight: 8 * theme.spacing.unit,
- },
- cardHeaderContent: {
- display: 'flex',
- paddingRight: 2 * theme.spacing.unit,
- justifyContent: 'space-between',
- },
- cardHeaderContentTitle: {
- paddingLeft: theme.spacing.unit,
- paddingTop: 2 * theme.spacing.unit,
- paddingRight: 2 * theme.spacing.unit,
- },
- nameHeader: {
- marginLeft: '75px'
- },
- fileSizeHeader: {
- marginRight: '65px'
- },
- uploadIcon: {
- transform: 'rotate(180deg)'
- },
- button: {
- marginRight: -theme.spacing.unit,
- marginTop: '8px'
- },
- centeredLabel: {
- fontSize: '0.875rem',
- textAlign: 'center'
- },
-});
-
-export const CollectionPanelFilesComponent = ({ onItemMenuOpen, onSearchChange, onOptionsMenuOpen, onUploadDataClick, classes,
- isWritable, isLoading, tooManyFiles, loadFilesFunc, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) => {
- const { useState, useEffect } = React;
- const [searchValue, setSearchValue] = useState('');
-
- useEffect(() => {
- onSearchChange(searchValue);
- }, [onSearchChange, searchValue]);
-
- return (<Card data-cy='collection-files-panel' className={classes.root}>
- <CardHeader
- title={
- <div className={classes.cardHeaderContent}>
- <span className={classes.cardHeaderContentTitle}>Files</span>
- <SearchInput
- selfClearProp={''}
- value={searchValue}
- label='Search files'
- onSearch={setSearchValue} />
- </div>
- }
- className={classes.cardSubheader}
- classes={{ action: classes.button }}
- action={<>
- {isWritable &&
- <Button
- data-cy='upload-button'
- onClick={onUploadDataClick}
- variant='contained'
- color='primary'
- size='small'>
- <DownloadIcon className={classes.uploadIcon} />
- Upload data
- </Button>}
- {!tooManyFiles &&
- <Tooltip title="More options" disableFocusListener>
- <IconButton
- data-cy='collection-files-panel-options-btn'
- onClick={(ev) => onOptionsMenuOpen(ev, isWritable)}>
- <CustomizeTableIcon />
- </IconButton>
- </Tooltip>}
- </>
- } />
- {tooManyFiles
- ? <div className={classes.centeredLabel}>
- File listing may take some time, please click to browse: <Button onClick={loadFilesFunc}><DownloadIcon />Show files</Button>
- </div>
- : <>
- <Grid container justify="space-between">
- <Typography variant="caption" className={classes.nameHeader}>
- Name
- </Typography>
- <Typography variant="caption" className={classes.fileSizeHeader}>
- File size
- </Typography>
- </Grid>
- {isLoading
- ? <div className={classes.centeredLabel}><CircularProgress /></div>
- : <div style={{ height: 'calc(100% - 60px)' }}>
- <FileTree
- onMenuOpen={(ev, item) => onItemMenuOpen(ev, item, isWritable)}
- {...treeProps} /></div>}
- </>
- }
- </Card>);
-};
-
-export const CollectionPanelFiles = withStyles(styles)(CollectionPanelFilesComponent);
diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx
index 5f396bb4..78aae350 100644
--- a/src/components/data-explorer/data-explorer.tsx
+++ b/src/components/data-explorer/data-explorer.tsx
@@ -82,13 +82,8 @@ interface DataExplorerActionProps<T> {
type DataExplorerProps<T> = DataExplorerDataProps<T> & DataExplorerActionProps<T> & WithStyles<CssRules>;
export const DataExplorer = withStyles(styles)(
- class DataExplorerGeneric<T> extends React.Component<DataExplorerProps<T>, { currentItemUuid: string }> {
- constructor(props) {
- super(props);
- this.state = {
- currentItemUuid: props.currentItemUuid
- };
- }
+ class DataExplorerGeneric<T> extends React.Component<DataExplorerProps<T>> {
+
componentDidMount() {
if (this.props.onSetColumns) {
this.props.onSetColumns(this.props.columns);
diff --git a/src/components/search-input/search-input.test.tsx b/src/components/search-input/search-input.test.tsx
index 90c52b76..db05e5d8 100644
--- a/src/components/search-input/search-input.test.tsx
+++ b/src/components/search-input/search-input.test.tsx
@@ -21,20 +21,20 @@ describe("<SearchInput />", () => {
describe("on submit", () => {
it("calls onSearch with initial value passed via props", () => {
- const searchInput = mount(<SearchInput value="initial value" onSearch={onSearch} />);
+ const searchInput = mount(<SearchInput selfClearProp="" value="initial value" onSearch={onSearch} />);
searchInput.find("form").simulate("submit");
expect(onSearch).toBeCalledWith("initial value");
});
it("calls onSearch with current value", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} />);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} />);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
searchInput.find("form").simulate("submit");
expect(onSearch).toBeCalledWith("current value");
});
it("calls onSearch with new value passed via props", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} />);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} />);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
searchInput.setProps({value: "new value"});
searchInput.find("form").simulate("submit");
@@ -42,7 +42,7 @@ describe("<SearchInput />", () => {
});
it("cancels timeout set on input value change", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} debounce={1000} />);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={1000} />);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
searchInput.find("form").simulate("submit");
jest.runTimersToTime(1000);
@@ -54,7 +54,7 @@ describe("<SearchInput />", () => {
describe("on input value change", () => {
it("calls onSearch after default timeout", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} />);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} />);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
expect(onSearch).not.toBeCalled();
jest.runTimersToTime(DEFAULT_SEARCH_DEBOUNCE);
@@ -62,7 +62,7 @@ describe("<SearchInput />", () => {
});
it("calls onSearch after the time specified in props has passed", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} debounce={2000}/>);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={2000}/>);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
jest.runTimersToTime(1000);
expect(onSearch).not.toBeCalled();
@@ -71,7 +71,7 @@ describe("<SearchInput />", () => {
});
it("calls onSearch only once after no change happened during the specified time", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} debounce={1000}/>);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={1000}/>);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
jest.runTimersToTime(500);
searchInput.find("input").simulate("change", { target: { value: "changed value" } });
@@ -80,7 +80,7 @@ describe("<SearchInput />", () => {
});
it("calls onSearch again after the specified time has passed since previous call", () => {
- const searchInput = mount(<SearchInput value="" onSearch={onSearch} debounce={1000}/>);
+ const searchInput = mount(<SearchInput selfClearProp="" value="" onSearch={onSearch} debounce={1000}/>);
searchInput.find("input").simulate("change", { target: { value: "current value" } });
jest.runTimersToTime(500);
searchInput.find("input").simulate("change", { target: { value: "intermediate value" } });
@@ -95,4 +95,14 @@ describe("<SearchInput />", () => {
});
+ describe("on input target change", () => {
+ it("clears input on target change", () => {
+ const searchInput = mount(<SearchInput selfClearProp="abc" value="123" onSearch={onSearch} debounce={1000}/>);
+ searchInput.setProps({ selfClearProp: 'aaa' });
+ jest.runTimersToTime(1000);
+ expect(onSearch).toBeCalledWith("");
+ expect(onSearch).toHaveBeenCalledTimes(1);
+ });
+ });
+
});
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list