1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Collection panel tests', function() {
10 // Only set up common users once. These aren't set up as aliases because
11 // aliases are cleaned up after every test. Also it doesn't make sense
12 // to set the same users on beforeEach() over and over again, so we
13 // separate a little from Cypress' 'Best Practices' here.
14 cy.getUser('admin', 'Admin', 'User', true, true)
15 .as('adminUser').then(function() {
16 adminUser = this.adminUser;
19 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
20 .as('activeUser').then(function() {
21 activeUser = this.activeUser;
26 beforeEach(function() {
28 cy.clearLocalStorage()
31 it('shows collection by URL', function() {
32 cy.loginAs(activeUser);
33 [true, false].map(function(isWritable) {
34 // Creates the collection using the admin token so we can set up
35 // a bogus manifest text without block signatures.
36 cy.createCollection(adminUser.token, {
37 name: 'Test collection',
38 owner_uuid: isWritable
39 ? activeUser.user.uuid
40 : adminUser.user.uuid,
41 properties: {someKey: 'someValue'},
42 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
43 .as('testCollection').then(function() {
44 if (isWritable === false) {
45 // Share collection as read-only
46 cy.do_request('POST', '/arvados/v1/links', {
47 link: JSON.stringify({
49 link_class: 'permission',
50 head_uuid: this.testCollection.uuid,
51 tail_uuid: activeUser.user.uuid
53 }, null, adminUser.token, null);
55 cy.visit(`/collections/${this.testCollection.uuid}`);
56 // Check that name & uuid are correct.
57 cy.get('[data-cy=collection-info-panel]')
58 .should('contain', this.testCollection.name)
59 .and(`${isWritable ? 'not.': ''}contain`, 'Read-only')
60 .and('contain', this.testCollection.uuid);
61 // Check that both read and write operations are available on
62 // the 'More options' menu.
63 cy.get('[data-cy=collection-panel-options-btn]')
65 cy.get('[data-cy=context-menu]')
66 .should('contain', 'Add to favorites')
67 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection')
68 .type('{esc}'); // Collapse the options menu
69 cy.get('[data-cy=collection-properties-panel]')
70 .should('contain', 'someKey')
71 .and('contain', 'someValue')
72 .and('not.contain', 'anotherKey')
73 .and('not.contain', 'anotherValue')
74 // Check that properties can be added.
75 if (isWritable === true) {
76 cy.get('[data-cy=collection-properties-form]').within(() => {
77 cy.get('[data-cy=property-field-key]').within(() => {
78 cy.get('input').type('anotherKey');
80 cy.get('[data-cy=property-field-value]').within(() => {
81 cy.get('input').type('anotherValue');
85 cy.get('[data-cy=collection-properties-panel]')
86 .should('contain', 'anotherKey')
87 .and('contain', 'anotherValue')
89 // Check that the file listing show both read & write operations
90 cy.get('[data-cy=collection-files-panel]').within(() => {
91 cy.root().should('contain', 'bar');
92 cy.get('[data-cy=upload-button]')
93 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
95 // Hamburger 'more options' menu button
96 cy.get('[data-cy=collection-files-panel-options-btn]')
98 cy.get('[data-cy=context-menu]')
99 .should('contain', 'Select all')
101 cy.get('[data-cy=collection-files-panel-options-btn]')
103 cy.get('[data-cy=context-menu]')
104 .should('contain', 'Download selected')
105 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
106 .type('{esc}'); // Collapse the options menu
107 // File item 'more options' button
108 cy.get('[data-cy=file-item-options-btn')
110 cy.get('[data-cy=context-menu]')
111 .should('contain', 'Download')
112 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove')
113 .type('{esc}'); // Collapse