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 cy.createGroup(adminUser.token, {
35 name: 'Shared project',
36 group_class: 'project',
37 }).as('sharedGroup').then(function() {
38 // Creates the collection using the admin token so we can set up
39 // a bogus manifest text without block signatures.
40 cy.createCollection(adminUser.token, {
41 name: 'Test collection',
42 owner_uuid: this.sharedGroup.uuid,
43 properties: {someKey: 'someValue'},
44 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
45 .as('testCollection').then(function() {
46 // Share the group with active user.
47 cy.createLink(adminUser.token, {
48 name: isWritable ? 'can_write' : 'can_read',
49 link_class: 'permission',
50 head_uuid: this.sharedGroup.uuid,
51 tail_uuid: activeUser.user.uuid
53 cy.visit(`/collections/${this.testCollection.uuid}`);
54 // Check that name & uuid are correct.
55 cy.get('[data-cy=collection-info-panel]')
56 .should('contain', this.testCollection.name)
57 .and('contain', this.testCollection.uuid);
58 // Check for the read-only icon
59 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
60 // Check that both read and write operations are available on
61 // the 'More options' menu.
62 cy.get('[data-cy=collection-panel-options-btn]')
64 cy.get('[data-cy=context-menu]')
65 .should('contain', 'Add to favorites')
66 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection')
67 .type('{esc}'); // Collapse the options menu
68 cy.get('[data-cy=collection-properties-panel]')
69 .should('contain', 'someKey')
70 .and('contain', 'someValue')
71 .and('not.contain', 'anotherKey')
72 .and('not.contain', 'anotherValue')
73 if (isWritable === true) {
74 // Check that properties can be added.
75 cy.get('[data-cy=collection-properties-form]').within(() => {
76 cy.get('[data-cy=property-field-key]').within(() => {
77 cy.get('input').type('anotherKey');
79 cy.get('[data-cy=property-field-value]').within(() => {
80 cy.get('input').type('anotherValue');
84 cy.get('[data-cy=collection-properties-panel]')
85 .should('contain', 'anotherKey')
86 .and('contain', 'anotherValue')
88 // Properties form shouldn't be displayed.
89 cy.get('[data-cy=collection-properties-form]').should('not.exist');
91 // Check that the file listing show both read & write operations
92 cy.get('[data-cy=collection-files-panel]').within(() => {
93 cy.root().should('contain', 'bar');
94 cy.get('[data-cy=upload-button]')
95 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
97 // Hamburger 'more options' menu button
98 cy.get('[data-cy=collection-files-panel-options-btn]')
100 cy.get('[data-cy=context-menu]')
101 .should('contain', 'Select all')
103 cy.get('[data-cy=collection-files-panel-options-btn]')
105 cy.get('[data-cy=context-menu]')
106 // .should('contain', 'Download selected')
107 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
108 .type('{esc}'); // Collapse the options menu
109 // File item 'more options' button
110 cy.get('[data-cy=file-item-options-btn')
112 cy.get('[data-cy=context-menu]')
113 .should('contain', 'Download')
114 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove')
115 .type('{esc}'); // Collapse