collection-creation-test
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Mon, 30 Jul 2018 11:12:44 +0000 (13:12 +0200)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Mon, 30 Jul 2018 11:12:44 +0000 (13:12 +0200)
Feature #13893

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

src/store/collections/creator/collection-creator-reducer.test.ts
src/store/collections/creator/collection-creator-reducer.ts
src/store/project/project-reducer.test.ts
src/store/project/project-reducer.ts
src/views-components/dialog-create/dialog-collection-create.tsx
src/views-components/dialog-create/dialog-project-create.tsx

index df2c36280212b6730235d068134bda236e2eca41..0da18c81ef319b28b81674b68fb7feff423f5d43 100644 (file)
@@ -1,3 +1,45 @@
 // Copyright (C) The Arvados Authors. All rights reserved.
 //
-// SPDX-License-Identifier: AGPL-3.0
\ No newline at end of file
+// SPDX-License-Identifier: AGPL-3.0
+
+import { collectionCreationReducer } from "./collection-creator-reducer";
+import { collectionCreateActions } from "./collection-creator-action";
+
+describe('collection-reducer', () => {
+
+    it('should open collection creator dialog', () => {
+        const initialState = {
+            creator: { opened: false, ownerUuid: "" }
+        };
+        const collection = {
+            creator: { opened: true, ownerUuid: "" },
+        };
+
+        const state = collectionCreationReducer(initialState, collectionCreateActions.OPEN_COLLECTION_CREATOR(initialState.creator));
+        expect(state).toEqual(collection);
+    });
+
+    it('should close collection creator dialog', () => {
+        const initialState = {
+            creator: { opened: true, ownerUuid: "" }
+        };
+        const collection = {
+            creator: { opened: false, ownerUuid: "" },
+        };
+
+        const state = collectionCreationReducer(initialState, collectionCreateActions.CLOSE_COLLECTION_CREATOR());
+        expect(state).toEqual(collection);
+    });
+
+    it('should reset collection creator dialog props', () => {
+        const initialState = {
+            creator: { opened: true, ownerUuid: "test" }
+        };
+        const collection = {
+            creator: { opened: false, ownerUuid: "" },
+        };
+
+        const state = collectionCreationReducer(initialState, collectionCreateActions.CREATE_COLLECTION_SUCCESS());
+        expect(state).toEqual(collection);
+    });
+});
\ No newline at end of file
index c7854808c6b840edc244c8a30ab90850406f3a79..769766e192f1178886a9c746a6e459fa30ea67a5 100644 (file)
@@ -10,11 +10,10 @@ export type CollectionCreatorState = {
 
 interface CollectionCreator {
     opened: boolean;
-    pending: boolean;
     ownerUuid: string;
 }
 
-const updateCreator = (state: CollectionCreatorState, creator: Partial<CollectionCreator>) => ({
+const updateCreator = (state: CollectionCreatorState, creator?: Partial<CollectionCreator>) => ({
     ...state,
     creator: {
         ...state.creator,
@@ -25,16 +24,15 @@ const updateCreator = (state: CollectionCreatorState, creator: Partial<Collectio
 const initialState: CollectionCreatorState = {
     creator: {
         opened: false,
-        pending: false,
         ownerUuid: ""
     }
 };
 
 export const collectionCreationReducer = (state: CollectionCreatorState = initialState, action: CollectionCreateAction) => {
     return collectionCreateActions.match(action, {
-        OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true, pending: false }),
+        OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
         CLOSE_COLLECTION_CREATOR: () => updateCreator(state, { opened: false }),
-        CREATE_COLLECTION: () => updateCreator(state, { opened: true }),
+        CREATE_COLLECTION: () => updateCreator(state),
         CREATE_COLLECTION_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),
         default: () => state
     });
index 0fc28960b6652a154bc3ffccc552be3cc9de18f8..92274b3d281efba4886f8aff65687e4d6625e426 100644 (file)
@@ -35,7 +35,6 @@ describe('project-reducer', () => {
             creator: {
                 opened: false,
                 ownerUuid: "",
-                pending: false
             }
         });
     });
@@ -50,7 +49,7 @@ describe('project-reducer', () => {
                 status: TreeItemStatus.PENDING
             }],
             currentItemId: "1",
-            creator: { opened: false, pending: false, ownerUuid: "" },
+            creator: { opened: false, ownerUuid: "" },
         };
         const project = {
             items: [{
@@ -61,7 +60,7 @@ describe('project-reducer', () => {
                 status: TreeItemStatus.PENDING
             }],
             currentItemId: "",
-            creator: { opened: false, pending: false, ownerUuid: "" },
+            creator: { opened: false, ownerUuid: "" },
         };
 
         const state = projectsReducer(initialState, projectActions.RESET_PROJECT_TREE_ACTIVITY(initialState.items[0].id));
@@ -78,7 +77,7 @@ describe('project-reducer', () => {
                 status: TreeItemStatus.PENDING
             }],
             currentItemId: "1",
-            creator: { opened: false, pending: false, ownerUuid: "" }
+            creator: { opened: false, ownerUuid: "" }
         };
         const project = {
             items: [{
@@ -89,7 +88,7 @@ describe('project-reducer', () => {
                 status: TreeItemStatus.PENDING,
             }],
             currentItemId: "1",
-            creator: { opened: false, pending: false, ownerUuid: "" },
+            creator: { opened: false, ownerUuid: "" },
         };
 
         const state = projectsReducer(initialState, projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(initialState.items[0].id));
@@ -107,7 +106,7 @@ describe('project-reducer', () => {
                 status: TreeItemStatus.PENDING,
             }],
             currentItemId: "1",
-            creator: { opened: false, pending: false, ownerUuid: "" }
+            creator: { opened: false, ownerUuid: "" }
         };
         const project = {
             items: [{
@@ -118,7 +117,7 @@ describe('project-reducer', () => {
                 status: TreeItemStatus.PENDING,
             }],
             currentItemId: "1",
-            creator: { opened: false, pending: false, ownerUuid: "" },
+            creator: { opened: false, ownerUuid: "" },
         };
 
         const state = projectsReducer(initialState, projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(initialState.items[0].id));
index 45e0e19527253ea03e39603a673e8e477232c484..f5af23ab3a3f6e5501bcd115ab0bf994b79ab0e1 100644 (file)
@@ -16,7 +16,6 @@ export type ProjectState = {
 
 interface ProjectCreator {
     opened: boolean;
-    pending: boolean;
     ownerUuid: string;
     error?: string;
 }
@@ -106,7 +105,6 @@ const initialState: ProjectState = {
     currentItemId: "",
     creator: {
         opened: false,
-        pending: false,
         ownerUuid: ""
     }
 };
@@ -114,7 +112,7 @@ const initialState: ProjectState = {
 
 export const projectsReducer = (state: ProjectState = initialState, action: ProjectAction) => {
     return projectActions.match(action, {
-        OPEN_PROJECT_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true, pending: false }),
+        OPEN_PROJECT_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
         CLOSE_PROJECT_CREATOR: () => updateCreator(state, { opened: false }),
         CREATE_PROJECT: () => updateCreator(state, { error: undefined }),
         CREATE_PROJECT_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),
index 8ce0c5d252f4606d6c33112f259dc1ef0711e4ae..d0f793bfd854887df5b3afc1dbf6685d5b4290c0 100644 (file)
@@ -42,7 +42,7 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     createProgress: {
         position: "absolute",
         minWidth: "20px",
-        right: "95px"
+        right: "110px"
     },
     dialogActions: {
         marginBottom: "24px"
@@ -102,7 +102,7 @@ export const DialogCollectionCreate = compose(
                                 <Button type="submit"
                                         className={classes.lastButton}
                                         color="primary"
-                                        disabled={invalid|| submitting || pristine}
+                                        disabled={invalid || submitting || pristine}
                                         variant="contained">
                                     CREATE A COLLECTION
                                 </Button>
index e05a3bd9d8e2b316a0004941fd4e3dc04d3d593a..acfe3973b2d0dfdb69826f586fb568795c0f65a0 100644 (file)
@@ -103,7 +103,7 @@ export const DialogProjectCreate = compose(
                                 <Button type="submit"
                                         className={classes.lastButton}
                                         color="primary"
-                                        disabled={invalid|| submitting || pristine}
+                                        disabled={invalid || submitting || pristine}
                                         variant="contained">
                                     CREATE A PROJECT
                                 </Button>