From 261201611113224f4a61b3979f6cd9992c4aa6c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Thu, 10 Feb 2022 22:54:13 +0100 Subject: [PATCH] 18594: Added multiple tails display, added tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- cypress/integration/project.spec.js | 58 +++++++++++++------ src/store/advanced-tab/advanced-tab.tsx | 19 ++++-- .../advanced-tab-dialog.tsx | 6 +- .../advanced-tab-dialog/metadataTab.tsx | 6 +- 4 files changed, 60 insertions(+), 29 deletions(-) diff --git a/cypress/integration/project.spec.js b/cypress/integration/project.spec.js index f369330e..96e73bc1 100644 --- a/cypress/integration/project.spec.js +++ b/cypress/integration/project.spec.js @@ -200,7 +200,10 @@ describe('Project tests', function() { cy.createGroup(activeUser.token, { name: `Test root project ${Math.floor(Math.random() * 999999)}`, group_class: 'project', - }).as('testProject1'); + }).as('testProject1').then((testProject1) => { + + cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write'); + }); cy.getAll('@testProject1').then(function([testProject1]) { cy.loginAs(activeUser); @@ -216,29 +219,46 @@ describe('Project tests', function() { }); it('opens advanced popup for project with username', () => { - const projectName = `Test root project ${Math.floor(Math.random() * 999999)}`; - - cy.createProject({ - owningUser: adminUser, - targetUser: activeUser, - projectName, - canWrite: true, - addToFavorites: true - }).as('mySharedProject'); - - cy.getAll('@mySharedProject') - .then(function ([mySharedProject]) { - cy.loginAs(activeUser); + const projectName = `Test project ${Math.floor(Math.random() * 999999)}`; + + cy.createGroup(adminUser.token, { + name: projectName, + group_class: 'project', + }).as('mainProject') + + cy.getAll('@mainProject') + .then(function ([mainProject]) { + cy.loginAs(adminUser); - cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click(); + cy.get('[data-cy=side-panel-tree]').contains('Groups').click(); + + cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => { + cy.createLink(adminUser.token, { + name: 'can_write', + link_class: 'permission', + head_uuid: mainProject.uuid, + tail_uuid: uuid + }); - cy.get('main').contains(projectName).rightclick(); + cy.createLink(adminUser.token, { + name: 'can_write', + link_class: 'permission', + head_uuid: mainProject.uuid, + tail_uuid: activeUser.user.uuid + }); + + cy.get('[data-cy=side-panel-tree]').contains('Projects').click(); + + cy.get('main').contains(projectName).rightclick(); - cy.get('[data-cy=context-menu]').contains('Advanced').click(); + cy.get('[data-cy=context-menu]').contains('Advanced').click(); - cy.get('[role=tablist]').contains('METADATA').click(); + cy.get('[role=tablist]').contains('METADATA').click(); - cy.get('td').contains('User: Active User').should('exist'); + cy.get('td').contains(uuid).should('exist'); + + cy.get('td').contains('Active User').should('exist'); + }); }); }); }); \ No newline at end of file diff --git a/src/store/advanced-tab/advanced-tab.tsx b/src/store/advanced-tab/advanced-tab.tsx index 052df3a2..33faebbe 100644 --- a/src/store/advanced-tab/advanced-tab.tsx +++ b/src/store/advanced-tab/advanced-tab.tsx @@ -18,7 +18,7 @@ import { ListResults } from 'services/common-service/common-service'; import { RepositoryResource } from 'models/repositories'; import { SshKeyResource } from 'models/ssh-key'; import { VirtualMachinesResource } from 'models/virtual-machines'; -import { UserResource } from 'models/user'; +import { UserResource, getUserDisplayName } from 'models/user'; import { LinkResource } from 'models/link'; import { KeepServiceResource } from 'models/keep-services'; import { ApiClientAuthorization } from 'models/api-client-authorization'; @@ -282,11 +282,18 @@ const getDataForAdvancedTab = (uuid: string) => }); let user; - try { - if (metadata.itemsAvailable && metadata.items[0].tailKind === ResourceKind.USER) { - user = await services.userService.get(metadata.items[0].tailUuid || ''); - } - } catch {}; + if (metadata.itemsAvailable) { + metadata.items.forEach(async (item) => { + const {tailKind, tailUuid, properties} = item; + properties['tail'] = tailUuid; + try { + if (tailKind === ResourceKind.USER && tailUuid) { + user = await services.userService.get(tailUuid); + properties['tail'] = getUserDisplayName(user); + } + } catch {}; + }); + } return { data, metadata, user }; }; diff --git a/src/views-components/advanced-tab-dialog/advanced-tab-dialog.tsx b/src/views-components/advanced-tab-dialog/advanced-tab-dialog.tsx index b631a74c..e8d4aaef 100644 --- a/src/views-components/advanced-tab-dialog/advanced-tab-dialog.tsx +++ b/src/views-components/advanced-tab-dialog/advanced-tab-dialog.tsx @@ -78,7 +78,11 @@ export const AdvancedTabDialog = compose( {value === 0 &&
{dialogContentExample(apiResponse, classes)}
} - {value === 1 &&
{metadata !== '' && metadata.items.length > 0 ? : dialogContentHeader('(No metadata links found)')}
} + {value === 1 &&
+ {metadata !== '' && metadata.items.length > 0 ? + + : dialogContentHeader('(No metadata links found)')} +
} {value === 2 && dialogContent(pythonHeader, pythonExample, classes)} {value === 3 &&
{dialogContent(cliGetHeader, cliGetExample, classes)} diff --git a/src/views-components/advanced-tab-dialog/metadataTab.tsx b/src/views-components/advanced-tab-dialog/metadataTab.tsx index 9f08d1e3..88d0137f 100644 --- a/src/views-components/advanced-tab-dialog/metadataTab.tsx +++ b/src/views-components/advanced-tab-dialog/metadataTab.tsx @@ -4,7 +4,7 @@ import React from "react"; import { Table, TableHead, TableCell, TableRow, TableBody, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core'; -import { UserResource, getUserDisplayName } from "models/user"; +import { UserResource } from "models/user"; type CssRules = 'cell'; @@ -47,9 +47,9 @@ export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles {it.uuid} {it.linkClass} {it.name} - {props.user && `User: ${getUserDisplayName(props.user)}`} + {it.properties.tail} {it.headUuid === props.uuid ? 'this' : it.headUuid} - {JSON.stringify(it.properties)} + {JSON.stringify(it.properties, (key, value) => { return key === 'tail' ? undefined : value; })} )} -- 2.30.2