From: Pawel Kowalczyk Date: Thu, 23 Aug 2018 13:01:18 +0000 (+0200) Subject: cr changes + tests fix X-Git-Tag: 1.3.0~134^2~6 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/cad9f25fc5e75f6e4f09fe90abd42d0cd10eb492 cr changes + tests fix Feature #13897 Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk --- diff --git a/src/components/data-explorer/data-explorer.test.tsx b/src/components/data-explorer/data-explorer.test.tsx index a34ab1c8..3e447b40 100644 --- a/src/components/data-explorer/data-explorer.test.tsx +++ b/src/components/data-explorer/data-explorer.test.tsx @@ -13,6 +13,7 @@ import { SearchInput } from "../search-input/search-input"; import { TablePagination } from "@material-ui/core"; import { ProjectIcon } from '../icon/icon'; import { DefaultView } from '../default-view/default-view'; +import { SortDirection } from '../data-table/data-column'; configure({ adapter: new Adapter() }); @@ -20,11 +21,13 @@ describe("", () => { it("communicates with ", () => { const onSearch = jest.fn(); + const onSetColumns = jest.fn(); const dataExplorer = mount(); + onSearch={onSearch} + onSetColumns={onSetColumns} />); expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value"); dataExplorer.find(SearchInput).prop("onSearch")("new value"); expect(onSearch).toHaveBeenCalledWith("new value"); @@ -32,12 +35,14 @@ describe("", () => { it("communicates with ", () => { const onColumnToggle = jest.fn(); - const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }]; + const onSetColumns = jest.fn(); + const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }]; const dataExplorer = mount(); + items={[{ name: "item 1" }]} + onSetColumns={onSetColumns} />); expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns); dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns"); expect(onColumnToggle).toHaveBeenCalledWith("columns"); @@ -47,7 +52,8 @@ describe("", () => { const onFiltersChange = jest.fn(); const onSortToggle = jest.fn(); const onRowClick = jest.fn(); - const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }]; + const onSetColumns = jest.fn(); + const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }]; const items = [{ name: "item 1" }]; const dataExplorer = mount(", () => { items={items} onFiltersChange={onFiltersChange} onSortToggle={onSortToggle} - onRowClick={onRowClick} />); + onRowClick={onRowClick} + onSetColumns={onSetColumns} />); expect(dataExplorer.find(DataTable).prop("columns").slice(0, -1)).toEqual(columns); expect(dataExplorer.find(DataTable).prop("items")).toBe(items); dataExplorer.find(DataTable).prop("onRowClick")("event", "rowClick"); @@ -70,7 +77,7 @@ describe("", () => { const dataExplorer = mount(); + onSetColumns={jest.fn()} />); expect(dataExplorer.find(DataTable)).toHaveLength(0); expect(dataExplorer.find(DefaultView)).toHaveLength(1); }); @@ -78,6 +85,7 @@ describe("", () => { it("communicates with ", () => { const onChangePage = jest.fn(); const onChangeRowsPerPage = jest.fn(); + const onSetColumns = jest.fn(); const dataExplorer = mount(", () => { rowsPerPage={50} onChangePage={onChangePage} onChangeRowsPerPage={onChangeRowsPerPage} - />); + onSetColumns={onSetColumns} />); expect(dataExplorer.find(TablePagination).prop("page")).toEqual(10); expect(dataExplorer.find(TablePagination).prop("rowsPerPage")).toEqual(50); dataExplorer.find(TablePagination).prop("onChangePage")(undefined, 6); @@ -114,5 +122,6 @@ const mockDataExplorerProps = () => ({ onChangeRowsPerPage: jest.fn(), onContextMenu: jest.fn(), defaultIcon: ProjectIcon, + onSetColumns: jest.fn(), defaultMessages: ['testing'], }); diff --git a/src/store/collection-copy-dialog/collection-copy-dialog.ts b/src/store/collection-copy-dialog/collection-copy-dialog.ts index d2640633..458ae5e1 100644 --- a/src/store/collection-copy-dialog/collection-copy-dialog.ts +++ b/src/store/collection-copy-dialog/collection-copy-dialog.ts @@ -14,7 +14,7 @@ import { projectPanelActions } from '~/store/project-panel/project-panel-action' export const COLLECTION_COPY_DIALOG = 'projectCopy'; -export interface CopyFormDialogData { +export interface CollectionCopyFormDialogData { name: string; ownerUuid: string; uuid: string; @@ -23,12 +23,12 @@ export interface CopyFormDialogData { export const openCollectionCopyDialog = (resource: { name: string, uuid: string }) => (dispatch: Dispatch) => { dispatch(resetPickerProjectTree()); - const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: '', uuid: resource.uuid }; + const initialData: CollectionCopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: '', uuid: resource.uuid }; dispatch(initialize(COLLECTION_COPY_DIALOG, initialData)); dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_COPY_DIALOG, data: {} })); }; -export const copyCollection = (resource: CopyFormDialogData) => +export const copyCollection = (resource: CollectionCopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(startSubmit(COLLECTION_COPY_DIALOG)); try { diff --git a/src/views-components/copy-dialog/copy-collection-dialog.tsx b/src/views-components/copy-dialog/copy-collection-dialog.tsx index db721e02..d9886221 100644 --- a/src/views-components/copy-dialog/copy-collection-dialog.tsx +++ b/src/views-components/copy-dialog/copy-collection-dialog.tsx @@ -5,13 +5,13 @@ import { compose } from "redux"; import { withDialog } from "~/store/dialog/with-dialog"; import { reduxForm } from 'redux-form'; -import { COLLECTION_COPY_DIALOG, CopyFormDialogData } from '~/store/collection-copy-dialog/collection-copy-dialog'; +import { COLLECTION_COPY_DIALOG, CollectionCopyFormDialogData } from '~/store/collection-copy-dialog/collection-copy-dialog'; import { CopyFormDialog } from "~/views-components/copy-dialog/copy-dialog"; import { copyCollection } from '~/store/collection-copy-dialog/collection-copy-dialog'; export const CollectionCopyDialog = compose( withDialog(COLLECTION_COPY_DIALOG), - reduxForm({ + reduxForm({ form: COLLECTION_COPY_DIALOG, onSubmit: (data, dispatch) => { dispatch(copyCollection(data)); diff --git a/src/views-components/copy-dialog/copy-dialog.tsx b/src/views-components/copy-dialog/copy-dialog.tsx index c9b64869..3b1b4cf4 100644 --- a/src/views-components/copy-dialog/copy-dialog.tsx +++ b/src/views-components/copy-dialog/copy-dialog.tsx @@ -9,9 +9,9 @@ import { FormDialog } from '~/components/form-dialog/form-dialog'; import { ProjectTreePickerField } from '~/views-components/project-tree-picker/project-tree-picker'; import { COPY_NAME_VALIDATION, COPY_PROJECT_VALIDATION } from '~/validators/validators'; import { TextField } from "~/components/text-field/text-field"; -import { CopyFormDialogData } from "~/store/collection-copy-dialog/collection-copy-dialog"; +import { CollectionCopyFormDialogData } from "~/store/collection-copy-dialog/collection-copy-dialog"; -type CopyFormDialogProps = WithDialogProps & InjectedFormProps; +type CopyFormDialogProps = WithDialogProps & InjectedFormProps; export const CopyFormDialog = (props: CopyFormDialogProps) =>