19052: fixed wrong owner being displayed added test 19052-fix-for-wrong-owner-on-search-list
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 19 May 2022 15:36:17 +0000 (17:36 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 19 May 2022 15:36:17 +0000 (17:36 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/search.spec.js
src/views-components/data-explorer/renderers.tsx

index 491292bece641a79e977974faccafc0fea7b6379..5434ca248a5167e5461014491d77f422980ae693 100644 (file)
@@ -104,4 +104,26 @@ describe('Search tests', function() {
             cy.get('[data-cy=element-path]').should('contain', `/ Projects / ${colName}`);
         });
     });
             cy.get('[data-cy=element-path]').should('contain', `/ Projects / ${colName}`);
         });
     });
+
+    it('can display owner of the item', function() {
+        const colName = `Collection ${Math.floor(Math.random() * Math.floor(999999))}`;
+
+        cy.createCollection(adminUser.token, {
+            name: colName,
+            owner_uuid: activeUser.user.uuid,
+            preserve_version: true,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        }).then(function() {
+            cy.loginAs(activeUser);
+
+            cy.doSearch(colName);
+
+            cy.get('[data-cy=search-results]').should('contain', colName);
+
+            cy.get('[data-cy=search-results]').contains(colName).closest('tr')
+                .within(() => {
+                    cy.get('p').contains(activeUser.user.uuid).should('contain', activeUser.user.full_name);
+                });
+        });
+    });
 });
\ No newline at end of file
 });
\ No newline at end of file
index cd9f972e249a32e6111bc17de17fab8b8c7e0b45..3edce4f81aa3f5059b611ad674bb787fc3c92789 100644 (file)
@@ -713,9 +713,18 @@ const userFromID =
             return { uuid: props.uuid, userFullname };
         });
 
             return { uuid: props.uuid, userFullname };
         });
 
+const ownerFromResourceId = 
+    compose(
+        connect((state: RootState, props: { uuid: string }) => {
+            const childResource = getResource<GroupContentsResource & UserResource>(props.uuid)(state.resources);
+            return { uuid: childResource ? (childResource as Resource).ownerUuid : '' };
+        }),
+        userFromID
+    );
+
 export const ResourceOwnerWithName =
     compose(
 export const ResourceOwnerWithName =
     compose(
-        userFromID,
+        ownerFromResourceId,
         withStyles({}, { withTheme: true }))
         ((props: { uuid: string, userFullname: string, dispatch: Dispatch, theme: ArvadosTheme }) => {
             const { uuid, userFullname, dispatch, theme } = props;
         withStyles({}, { withTheme: true }))
         ((props: { uuid: string, userFullname: string, dispatch: Dispatch, theme: ArvadosTheme }) => {
             const { uuid, userFullname, dispatch, theme } = props;