From: Lucas Di Pentima Date: Mon, 16 May 2022 18:58:28 +0000 (-0300) Subject: 16115: Improves link rendering. Adds tests. X-Git-Tag: 2.4.1~1^2~2^2~6 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/a4c96d2e98d9f2971e9268355bd31331c2b6a5e2 16115: Improves link rendering. Adds tests. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/cypress/integration/sharing.spec.js b/cypress/integration/sharing.spec.js index df7c7436..1d3112c2 100644 --- a/cypress/integration/sharing.spec.js +++ b/cypress/integration/sharing.spec.js @@ -14,13 +14,11 @@ describe('Sharing tests', function () { cy.getUser('admin', 'Admin', 'User', true, true) .as('adminUser').then(function () { adminUser = this.adminUser; - } - ); + }); cy.getUser('collectionuser1', 'Collection', 'User', false, true) .as('activeUser').then(function () { activeUser = this.activeUser; - } - ); + }); }) beforeEach(function () { @@ -28,6 +26,38 @@ describe('Sharing tests', function () { cy.clearLocalStorage() }); + it('can create and delete sharing URLs on collections', () => { + const collName = 'shared-collection ' + new Date().getTime(); + cy.createCollection(adminUser.token, { + name: collName, + owner_uuid: adminUser.uuid, + }).as('sharedCollection').then(function (sharedCollection) { + cy.loginAs(adminUser); + + cy.get('main').contains(sharedCollection.name).rightclick(); + cy.get('[data-cy=context-menu]').within(() => { + cy.contains('Share').click(); + }); + cy.get('.sharing-dialog').within(() => { + cy.contains('Sharing URLs').click(); + cy.contains('Create sharing URL'); + cy.contains('No sharing URLs'); + cy.should('not.contain', 'Token'); + cy.should('not.contain', 'expiring at:'); + + cy.contains('Create sharing URL').click(); + cy.should('not.contain', 'No sharing URLs'); + cy.contains('Token'); + cy.contains('expiring at:'); + + cy.get('[data-cy=remove-url-btn]').find('button').click(); + cy.contains('No sharing URLs'); + cy.should('not.contain', 'Token'); + cy.should('not.contain', 'expiring at:'); + }) + }) + }); + it('can share projects to other users', () => { cy.loginAs(adminUser); @@ -46,8 +76,10 @@ describe('Sharing tests', function () { cy.get('.sharing-dialog').as('sharingDialog'); cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email); cy.get('[role=tooltip]').click(); - cy.get('@sharingDialog').contains('Save changes').click(); - cy.get('@sharingDialog').contains('Close').click(); + cy.get('@sharingDialog').within(() => { + cy.contains('Save changes').click(); + cy.contains('Close').click(); + }); }); cy.createGroup(adminUser.token, { @@ -62,8 +94,10 @@ describe('Sharing tests', function () { cy.get('.sharing-dialog').as('sharingDialog'); cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email); cy.get('[role=tooltip]').click(); - cy.get('@sharingDialog').contains('Save changes').click(); - cy.get('@sharingDialog').contains('Close').click(); + cy.get('@sharingDialog').within(() => { + cy.contains('Save changes').click(); + cy.contains('Close').click(); + }); }); cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject') diff --git a/src/views-components/sharing-dialog/sharing-urls-component.test.tsx b/src/views-components/sharing-dialog/sharing-urls-component.test.tsx index 0cbc661d..cf3884c7 100644 --- a/src/views-components/sharing-dialog/sharing-urls-component.test.tsx +++ b/src/views-components/sharing-dialog/sharing-urls-component.test.tsx @@ -57,6 +57,14 @@ describe("", () => { expect(wrapper.find('a').at(1).props().href).toBe(`${props.collectionUuid}${sharingPrefix}/t=${props.sharingTokens[1].apiToken}/_/`); }); + it("renders a list of URLs with no expiration", () => { + props.sharingTokens[0].expiresAt = null; + props.sharingTokens[1].expiresAt = null; + wrapper = mount(); + expect(wrapper.find('a').at(0).text()).toContain(`Token aaaaaaaa... with no expiration date`); + expect(wrapper.find('a').at(1).text()).toContain(`Token bbbbbbbb... with no expiration date`); + }); + it("calls delete token handler when delete button is clicked", () => { wrapper.find('button').at(0).simulate('click'); expect(props.onDeleteSharingToken).toHaveBeenCalledWith(props.sharingTokens[0].uuid); diff --git a/src/views-components/sharing-dialog/sharing-urls-component.tsx b/src/views-components/sharing-dialog/sharing-urls-component.tsx index 1638aaf7..c9cbc0df 100644 --- a/src/views-components/sharing-dialog/sharing-urls-component.tsx +++ b/src/views-components/sharing-dialog/sharing-urls-component.tsx @@ -66,7 +66,9 @@ export const SharingURLsComponent = withStyles(styles)((props: SharingURLsCompon ? `${props.sharingURLsPrefix.replace('*', props.collectionUuid)}/t=${token.apiToken}/_/` : `${props.sharingURLsPrefix}/c=${props.collectionUuid}/t=${token.apiToken}/_/`; const expDate = new Date(token.expiresAt); - const urlLabel = `Token ${token.apiToken.slice(0, 8)}... expiring at: ${expDate.toLocaleString()} (${moment(expDate).fromNow()})`; + const urlLabel = !!token.expiresAt + ? `Token ${token.apiToken.slice(0, 8)}... expiring at: ${expDate.toLocaleString()} (${moment(expDate).fromNow()})` + : `Token ${token.apiToken.slice(0, 8)}... with no expiration date`; return @@ -81,7 +83,7 @@ export const SharingURLsComponent = withStyles(styles)((props: SharingURLsCompon - + props.onDeleteSharingToken(token.uuid)}> diff --git a/tools/arvados_config.yml b/tools/arvados_config.yml index b9bcfbe0..3b2ecd8d 100644 --- a/tools/arvados_config.yml +++ b/tools/arvados_config.yml @@ -5,6 +5,7 @@ Clusters: API: RequestTimeout: 30s VocabularyPath: "" + MaxTokenLifetime: 24h TLS: Insecure: true Collections: