1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 const path = require('path');
7 describe('Collection panel tests', function () {
13 // Only set up common users once. These aren't set up as aliases because
14 // aliases are cleaned up after every test. Also it doesn't make sense
15 // to set the same users on beforeEach() over and over again, so we
16 // separate a little from Cypress' 'Best Practices' here.
17 cy.getUser('admin', 'Admin', 'User', true, true)
18 .as('adminUser').then(function () {
19 adminUser = this.adminUser;
22 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
23 .as('activeUser').then(function () {
24 activeUser = this.activeUser;
27 downloadsFolder = Cypress.config('downloadsFolder');
30 beforeEach(function () {
32 cy.clearLocalStorage();
35 it('allows to download mountain duck config for a collection', () => {
36 cy.createCollection(adminUser.token, {
37 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
38 owner_uuid: activeUser.user.uuid,
39 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
41 .as('testCollection').then(function (testCollection) {
42 cy.loginAs(activeUser);
43 cy.goToPath(`/collections/${testCollection.uuid}`);
45 cy.get('[data-cy=collection-panel-options-btn]').click();
46 cy.get('[data-cy=context-menu]').contains('Open with 3rd party client').click();
47 cy.get('[data-cy=download-button').click();
49 const filename = path.join(downloadsFolder, `${testCollection.name}.duck`);
51 cy.readFile(filename, { timeout: 15000 })
53 const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find('dict')[0].children);
57 for (i=0; i < childrenCollection.length; i += j) {
58 map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
61 cy.get('#simple-tabpanel-0').find('a')
63 const [host, port] = a.text().split('@')[1].split('/')[0].split(':');
64 expect(map['Protocol']).to.equal('davs');
65 expect(map['UUID']).to.equal(testCollection.uuid);
66 expect(map['Username']).to.equal(activeUser.user.username);
67 expect(map['Port']).to.equal(port);
68 expect(map['Hostname']).to.equal(host);
70 expect(map['Path']).to.equal(`/c=${testCollection.uuid}`);
74 .then(() => cy.task('clearDownload', { filename }));
78 it('uses the property editor with vocabulary terms', function () {
79 cy.createCollection(adminUser.token, {
80 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
81 owner_uuid: activeUser.user.uuid,
82 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
84 .as('testCollection').then(function () {
85 cy.loginAs(activeUser);
86 cy.goToPath(`/collections/${this.testCollection.uuid}`);
88 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
89 cy.get('[data-cy=resource-properties-form]').within(() => {
90 cy.get('[data-cy=property-field-key]').within(() => {
91 cy.get('input').type('Color');
93 cy.get('[data-cy=property-field-value]').within(() => {
94 cy.get('input').type('Magenta');
98 // Confirm proper vocabulary labels are displayed on the UI.
99 cy.get('[data-cy=collection-properties-panel]')
100 .should('contain', 'Color: Magenta');
101 // Confirm proper vocabulary IDs were saved on the backend.
102 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
103 .its('body').as('collection')
105 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
108 // Case-insensitive on-blur auto-selection test
109 // Key: Size (IDTAGSIZES) - Value: Small (IDVALSIZES2)
110 cy.get('[data-cy=resource-properties-form]').within(() => {
111 cy.get('[data-cy=property-field-key]').within(() => {
112 cy.get('input').type('sIzE');
114 cy.get('[data-cy=property-field-value]').within(() => {
115 cy.get('input').type('sMaLL');
117 // Cannot "type()" TAB on Cypress so let's click another field
118 // to trigger the onBlur event.
119 cy.get('[data-cy=property-field-key]').click();
122 // Confirm proper vocabulary labels are displayed on the UI.
123 cy.get('[data-cy=collection-properties-panel]')
124 .should('contain', 'Size: S');
125 // Confirm proper vocabulary IDs were saved on the backend.
126 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
127 .its('body').as('collection')
129 expect(this.collection.properties.IDTAGSIZES).to.equal('IDVALSIZES2');
134 it('shows collection by URL', function () {
135 cy.loginAs(activeUser);
136 [true, false].map(function (isWritable) {
137 // Using different file names to avoid test flakyness: the second iteration
138 // on this loop may pass an assertion from the first iteration by looking
139 // for the same file name.
140 const fileName = isWritable ? 'bar' : 'foo';
141 const subDirName = 'subdir';
142 cy.createGroup(adminUser.token, {
143 name: 'Shared project',
144 group_class: 'project',
145 }).as('sharedGroup').then(function () {
146 // Creates the collection using the admin token so we can set up
147 // a bogus manifest text without block signatures.
148 cy.doRequest('GET', '/arvados/v1/config', null, null)
149 .its('body').should((clusterConfig) => {
150 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", false);
151 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
152 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
153 const inlineUrl = clusterConfig.Services.WebDAV.ExternalURL !== ""
154 ? clusterConfig.Services.WebDAV.ExternalURL
155 : clusterConfig.Services.WebDAVDownload.ExternalURL;
156 expect(inlineUrl).to.not.contain("*");
158 .createCollection(adminUser.token, {
159 name: 'Test collection',
160 owner_uuid: this.sharedGroup.uuid,
161 properties: { someKey: 'someValue' },
162 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
164 .as('testCollection').then(function () {
165 // Share the group with active user.
166 cy.createLink(adminUser.token, {
167 name: isWritable ? 'can_write' : 'can_read',
168 link_class: 'permission',
169 head_uuid: this.sharedGroup.uuid,
170 tail_uuid: activeUser.user.uuid
172 cy.goToPath(`/collections/${this.testCollection.uuid}`);
174 // Check that name & uuid are correct.
175 cy.get('[data-cy=collection-info-panel]')
176 .should('contain', this.testCollection.name)
177 .and('contain', this.testCollection.uuid)
178 .and('not.contain', 'This is an old version');
179 // Check for the read-only icon
180 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
181 // Check that both read and write operations are available on
182 // the 'More options' menu.
183 cy.get('[data-cy=collection-panel-options-btn]')
185 cy.get('[data-cy=context-menu]')
186 .should('contain', 'Add to favorites')
187 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
188 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
189 cy.get('[data-cy=collection-properties-panel]')
190 .should('contain', 'someKey')
191 .and('contain', 'someValue')
192 .and('not.contain', 'anotherKey')
193 .and('not.contain', 'anotherValue')
194 if (isWritable === true) {
195 // Check that properties can be added.
196 cy.get('[data-cy=resource-properties-form]').within(() => {
197 cy.get('[data-cy=property-field-key]').within(() => {
198 cy.get('input').type('anotherKey');
200 cy.get('[data-cy=property-field-value]').within(() => {
201 cy.get('input').type('anotherValue');
205 cy.get('[data-cy=collection-properties-panel]')
206 .should('contain', 'anotherKey')
207 .and('contain', 'anotherValue')
209 // Properties form shouldn't be displayed.
210 cy.get('[data-cy=resource-properties-form]').should('not.exist');
212 // Check that the file listing show both read & write operations
213 cy.get('[data-cy=collection-files-panel]').within(() => {
215 cy.root().should('contain', fileName);
217 cy.get('[data-cy=upload-button]')
218 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
221 // Test context menus
222 cy.get('[data-cy=collection-files-panel]')
223 .contains(fileName).rightclick({ force: true });
224 cy.get('[data-cy=context-menu]')
225 .should('contain', 'Download')
226 .and('not.contain', 'Open in new tab')
227 .and('contain', 'Copy to clipboard')
228 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
229 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
230 cy.get('body').click(); // Collapse the menu
231 cy.get('[data-cy=collection-files-panel]')
232 .contains(subDirName).rightclick({ force: true });
233 cy.get('[data-cy=context-menu]')
234 .should('not.contain', 'Download')
235 .and('not.contain', 'Open in new tab')
236 .and('contain', 'Copy to clipboard')
237 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
238 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
239 cy.get('body').click(); // Collapse the menu
240 // Hamburger 'more options' menu button
241 cy.get('[data-cy=collection-files-panel-options-btn]')
243 cy.get('[data-cy=context-menu]')
244 .should('contain', 'Select all')
246 cy.get('[data-cy=collection-files-panel-options-btn]')
248 cy.get('[data-cy=context-menu]')
249 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
250 cy.get('body').click(); // Collapse the menu
256 it('renames a file using valid names', function () {
257 function eachPair(lst, func){
258 for(var i=0; i < lst.length - 1; i++){
259 func(lst[i], lst[i + 1])
262 // Creates the collection using the admin token so we can set up
263 // a bogus manifest text without block signatures.
264 cy.createCollection(adminUser.token, {
265 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
266 owner_uuid: activeUser.user.uuid,
267 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
269 .as('testCollection').then(function () {
270 cy.loginAs(activeUser);
271 cy.goToPath(`/collections/${this.testCollection.uuid}`);
274 'bar', // initial name already set
281 'some name with whitespaces',
283 'is this name legal? I hope it is',
291 "G%C3%BCnter's%20file.pdf",
293 'bar' // make sure we can go back to the original name as a last step
295 eachPair(names, (from, to) => {
296 cy.get('[data-cy=collection-files-panel]')
297 .contains(`${from}`).rightclick();
298 cy.get('[data-cy=context-menu]')
301 cy.get('[data-cy=form-dialog]')
302 .should('contain', 'Rename')
305 .type('{selectall}{backspace}')
306 .type(to, { parseSpecialCharSequences: false });
308 cy.get('[data-cy=form-submit-btn]').click();
309 cy.get('[data-cy=collection-files-panel]')
310 .should('not.contain', `${from}`)
311 .and('contain', `${to}`);
316 it.skip('renames a file to a different directory', function () {
317 // Creates the collection using the admin token so we can set up
318 // a bogus manifest text without block signatures.
319 cy.createCollection(adminUser.token, {
320 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
321 owner_uuid: activeUser.user.uuid,
322 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
324 .as('testCollection').then(function () {
325 cy.loginAs(activeUser);
326 cy.goToPath(`/collections/${this.testCollection.uuid}`);
328 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
329 cy.get('[data-cy=collection-files-panel]')
330 .contains('bar').rightclick({force: true});
331 cy.get('[data-cy=context-menu]')
334 cy.get('[data-cy=form-dialog]')
335 .should('contain', 'Rename')
337 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
339 cy.get('[data-cy=form-submit-btn]').click();
340 cy.get('[data-cy=collection-files-panel]')
341 .should('not.contain', 'bar')
342 .and('contain', subdir);
343 // Look for the "arrow icon" and expand the "subdir" directory.
344 cy.get('[data-cy=virtual-file-tree] > div > i').click();
345 // Rename 'subdir/foo' to 'foo'
346 cy.get('[data-cy=collection-files-panel]')
347 .contains('foo').rightclick();
348 cy.get('[data-cy=context-menu]')
351 cy.get('[data-cy=form-dialog]')
352 .should('contain', 'Rename')
355 .should('have.value', `${subdir}/foo`)
356 .type(`{selectall}{backspace}bar`);
358 cy.get('[data-cy=form-submit-btn]').click();
359 cy.get('[data-cy=collection-files-panel]')
360 .should('contain', subdir) // empty dir kept
361 .and('contain', 'bar');
363 cy.get('[data-cy=collection-files-panel]')
364 .contains(subdir).rightclick();
365 cy.get('[data-cy=context-menu]')
368 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
373 it('renames a file to a different directory', function () {
374 // Creates the collection using the admin token so we can set up
375 // a bogus manifest text without block signatures.
376 cy.createCollection(adminUser.token, {
377 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
378 owner_uuid: activeUser.user.uuid,
379 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
381 .as('testCollection').then(function () {
382 cy.loginAs(activeUser);
383 cy.goToPath(`/collections/${this.testCollection.uuid}`);
385 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
386 cy.get('[data-cy=collection-files-panel]')
387 .contains('bar').rightclick({force: true});
388 cy.get('[data-cy=context-menu]')
391 cy.get('[data-cy=form-dialog]')
392 .should('contain', 'Rename')
394 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
396 cy.get('[data-cy=form-submit-btn]').click();
397 cy.get('[data-cy=collection-files-panel]')
398 .should('not.contain', 'bar')
399 .and('contain', subdir);
401 cy.get('[data-cy=collection-files-panel]').contains(subdir).click();
402 // Rename 'subdir/foo' to 'foo'
404 cy.get('[data-cy=collection-files-panel]')
405 .contains('foo').rightclick();
406 cy.get('[data-cy=context-menu]')
409 cy.get('[data-cy=form-dialog]')
410 .should('contain', 'Rename')
413 .should('have.value', `${subdir}/foo`)
414 .type(`{selectall}{backspace}bar`);
416 cy.get('[data-cy=form-submit-btn]').click();
419 cy.get('[data-cy=collection-files-panel]')
424 cy.get('[data-cy=collection-files-panel]')
425 .should('contain', subdir) // empty dir kept
426 .and('contain', 'bar');
428 cy.get('[data-cy=collection-files-panel]')
429 .contains(subdir).rightclick();
430 cy.get('[data-cy=context-menu]')
433 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
438 it('tries to rename a file with illegal names', function () {
439 // Creates the collection using the admin token so we can set up
440 // a bogus manifest text without block signatures.
441 cy.createCollection(adminUser.token, {
442 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
443 owner_uuid: activeUser.user.uuid,
444 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
446 .as('testCollection').then(function () {
447 cy.loginAs(activeUser);
448 cy.goToPath(`/collections/${this.testCollection.uuid}`);
450 const illegalNamesFromUI = [
451 ['.', "Name cannot be '.' or '..'"],
452 ['..', "Name cannot be '.' or '..'"],
453 ['', 'This field is required'],
454 [' ', 'Leading/trailing whitespaces not allowed'],
455 [' foo', 'Leading/trailing whitespaces not allowed'],
456 ['foo ', 'Leading/trailing whitespaces not allowed'],
457 ['//foo', 'Empty dir name not allowed']
459 illegalNamesFromUI.forEach(([name, errMsg]) => {
460 cy.get('[data-cy=collection-files-panel]')
461 .contains('bar').rightclick();
462 cy.get('[data-cy=context-menu]')
465 cy.get('[data-cy=form-dialog]')
466 .should('contain', 'Rename')
468 cy.get('input').type(`{selectall}{backspace}${name}`);
470 cy.get('[data-cy=form-dialog]')
471 .should('contain', 'Rename')
473 cy.contains(`${errMsg}`);
475 cy.get('[data-cy=form-cancel-btn]').click();
480 it('can correctly display old versions', function () {
481 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
483 let oldVersionUuid = '';
484 // Make sure no other collections with this name exist
485 cy.doRequest('GET', '/arvados/v1/collections', null, {
486 filters: `[["name", "=", "${colName}"]]`,
487 include_old_versions: true
489 .its('body.items').as('collections')
491 expect(this.collections).to.be.empty;
493 // Creates the collection using the admin token so we can set up
494 // a bogus manifest text without block signatures.
495 cy.createCollection(adminUser.token, {
497 owner_uuid: activeUser.user.uuid,
498 preserve_version: true,
499 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
501 .as('originalVersion').then(function () {
502 // Change the file name to create a new version.
503 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
504 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
506 colUuid = this.originalVersion.uuid;
508 // Confirm that there are 2 versions of the collection
509 cy.doRequest('GET', '/arvados/v1/collections', null, {
510 filters: `[["name", "=", "${colName}"]]`,
511 include_old_versions: true
513 .its('body.items').as('collections')
515 expect(this.collections).to.have.lengthOf(2);
516 this.collections.map(function (aCollection) {
517 expect(aCollection.current_version_uuid).to.equal(colUuid);
518 if (aCollection.uuid !== aCollection.current_version_uuid) {
519 oldVersionUuid = aCollection.uuid;
522 // Check the old version displays as what it is.
523 cy.loginAs(activeUser)
524 cy.goToPath(`/collections/${oldVersionUuid}`);
526 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
527 cy.get('[data-cy=read-only-icon]').should('exist');
528 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
529 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
533 it('views & edits storage classes data', function () {
534 const colName= `Test Collection ${Math.floor(Math.random() * 999999)}`;
535 cy.createCollection(adminUser.token, {
537 owner_uuid: activeUser.user.uuid,
538 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
539 }).as('collection').then(function () {
540 expect(this.collection.storage_classes_desired).to.deep.equal(['default'])
542 cy.loginAs(activeUser)
543 cy.goToPath(`/collections/${this.collection.uuid}`);
545 // Initial check: it should show the 'default' storage class
546 cy.get('[data-cy=collection-info-panel]')
547 .should('contain', 'Storage classes')
548 .and('contain', 'default')
549 .and('not.contain', 'foo')
550 .and('not.contain', 'bar');
551 // Edit collection: add storage class 'foo'
552 cy.get('[data-cy=collection-panel-options-btn]').click();
553 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
554 cy.get('[data-cy=form-dialog]')
555 .should('contain', 'Edit Collection')
556 .and('contain', 'Storage classes')
557 .and('contain', 'default')
558 .and('contain', 'foo')
559 .and('contain', 'bar')
561 cy.get('[data-cy=checkbox-foo]').click();
563 cy.get('[data-cy=form-submit-btn]').click();
564 cy.get('[data-cy=collection-info-panel]')
565 .should('contain', 'default')
566 .and('contain', 'foo')
567 .and('not.contain', 'bar');
568 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
569 .its('body').as('updatedCollection')
571 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['default', 'foo']);
573 // Edit collection: remove storage class 'default'
574 cy.get('[data-cy=collection-panel-options-btn]').click();
575 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
576 cy.get('[data-cy=form-dialog]')
577 .should('contain', 'Edit Collection')
578 .and('contain', 'Storage classes')
579 .and('contain', 'default')
580 .and('contain', 'foo')
581 .and('contain', 'bar')
583 cy.get('[data-cy=checkbox-default]').click();
585 cy.get('[data-cy=form-submit-btn]').click();
586 cy.get('[data-cy=collection-info-panel]')
587 .should('not.contain', 'default')
588 .and('contain', 'foo')
589 .and('not.contain', 'bar');
590 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
591 .its('body').as('updatedCollection')
593 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['foo']);
598 it('uses the collection version browser to view a previous version', function () {
599 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
601 // Creates the collection using the admin token so we can set up
602 // a bogus manifest text without block signatures.
603 cy.createCollection(adminUser.token, {
605 owner_uuid: activeUser.user.uuid,
606 preserve_version: true,
607 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
609 .as('collection').then(function () {
610 // Visit collection, check basic information
611 cy.loginAs(activeUser)
612 cy.goToPath(`/collections/${this.collection.uuid}`);
614 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
615 cy.get('[data-cy=read-only-icon]').should('not.exist');
616 cy.get('[data-cy=collection-version-number]').should('contain', '1');
617 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
618 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
620 // Modify collection, expect version number change
621 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
622 cy.get('[data-cy=context-menu]').contains('Remove').click();
623 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
624 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
625 cy.get('[data-cy=collection-version-number]').should('contain', '2');
626 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
628 // Click on version number, check version browser. Click on past version.
629 cy.get('[data-cy=collection-version-browser]').should('not.exist');
630 cy.get('[data-cy=collection-version-number]').contains('2').click();
631 cy.get('[data-cy=collection-version-browser]')
632 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
634 // Version 1: 6 bytes in size
635 cy.get('[data-cy=collection-version-browser-select-1]')
636 .should('contain', '1')
637 .and('contain', '6 B')
638 .and('contain', adminUser.user.uuid);
639 // Version 2: 3 bytes in size (one file removed)
640 cy.get('[data-cy=collection-version-browser-select-2]')
641 .should('contain', '2')
642 .and('contain', '3 B')
643 .and('contain', activeUser.user.full_name);
644 cy.get('[data-cy=collection-version-browser-select-3]')
645 .should('not.exist');
646 cy.get('[data-cy=collection-version-browser-select-1]')
649 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
650 cy.get('[data-cy=read-only-icon]').should('exist');
651 cy.get('[data-cy=collection-version-number]').should('contain', '1');
652 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
653 cy.get('[data-cy=collection-files-panel]')
654 .should('contain', 'foo').and('contain', 'bar');
656 // Check that only old collection action are available on context menu
657 cy.get('[data-cy=collection-panel-options-btn]').click();
658 cy.get('[data-cy=context-menu]')
659 .should('contain', 'Restore version')
660 .and('not.contain', 'Add to favorites');
661 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
663 // Click on "head version" link, confirm that it's the latest version.
664 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
665 cy.get('[data-cy=collection-info-panel]')
666 .should('not.contain', 'This is an old version');
667 cy.get('[data-cy=read-only-icon]').should('not.exist');
668 cy.get('[data-cy=collection-version-number]').should('contain', '2');
669 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
670 cy.get('[data-cy=collection-files-panel]').
671 should('not.contain', 'foo').and('contain', 'bar');
673 // Check that old collection action isn't available on context menu
674 cy.get('[data-cy=collection-panel-options-btn]').click()
675 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
676 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
678 // Make another change, confirm new version.
679 cy.get('[data-cy=collection-panel-options-btn]').click();
680 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
681 cy.get('[data-cy=form-dialog]')
682 .should('contain', 'Edit Collection')
685 cy.get('input').first().type(' renamed');
687 cy.get('[data-cy=form-submit-btn]').click();
688 cy.get('[data-cy=collection-info-panel]')
689 .should('not.contain', 'This is an old version');
690 cy.get('[data-cy=read-only-icon]').should('not.exist');
691 cy.get('[data-cy=collection-version-number]').should('contain', '3');
692 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
693 cy.get('[data-cy=collection-files-panel]')
694 .should('not.contain', 'foo').and('contain', 'bar');
695 cy.get('[data-cy=collection-version-browser-select-3]')
696 .should('contain', '3').and('contain', '3 B');
698 // Check context menus on version browser
699 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
700 cy.get('[data-cy=context-menu]')
701 .should('contain', 'Add to favorites')
702 .and('contain', 'Make a copy')
703 .and('contain', 'Edit collection');
704 cy.get('body').click();
705 // (and now an old version...)
706 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
707 cy.get('[data-cy=context-menu]')
708 .should('not.contain', 'Add to favorites')
709 .and('contain', 'Make a copy')
710 .and('not.contain', 'Edit collection');
711 cy.get('body').click();
713 // Restore first version
714 cy.get('[data-cy=collection-version-browser]').within(() => {
715 cy.get('[data-cy=collection-version-browser-select-1]').click();
717 cy.get('[data-cy=collection-panel-options-btn]').click()
718 cy.get('[data-cy=context-menu]').contains('Restore version').click();
719 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
720 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
721 cy.get('[data-cy=collection-info-panel]')
722 .should('not.contain', 'This is an old version');
723 cy.get('[data-cy=collection-version-number]').should('contain', '4');
724 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
725 cy.get('[data-cy=collection-files-panel]')
726 .should('contain', 'foo').and('contain', 'bar');
730 it('creates new collection on home project', function () {
731 cy.loginAs(activeUser);
732 cy.goToPath(`/projects/${activeUser.user.uuid}`);
733 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
734 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
735 // Create new collection
736 cy.get('[data-cy=side-panel-button]').click();
737 cy.get('[data-cy=side-panel-new-collection]').click();
738 // Name between brackets tests bugfix #17582
739 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
740 cy.get('[data-cy=form-dialog]')
741 .should('contain', 'New collection')
742 .and('contain', 'Storage classes')
743 .and('contain', 'default')
744 .and('contain', 'foo')
745 .and('contain', 'bar')
747 cy.get('[data-cy=parent-field]').within(() => {
748 cy.get('input').should('have.value', 'Home project');
750 cy.get('[data-cy=name-field]').within(() => {
751 cy.get('input').type(collName);
753 cy.get('[data-cy=checkbox-foo]').click();
755 cy.get('[data-cy=form-submit-btn]').click();
756 // Confirm that the user was taken to the newly created thing
757 cy.get('[data-cy=form-dialog]').should('not.exist');
758 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
759 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
760 cy.get('[data-cy=collection-info-panel]')
761 .should('contain', 'default')
762 .and('contain', 'foo')
763 .and('not.contain', 'bar');
766 it('shows responsible person for collection if available', () => {
767 cy.createCollection(adminUser.token, {
768 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
769 owner_uuid: activeUser.user.uuid,
770 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
772 .as('testCollection1');
774 cy.createCollection(adminUser.token, {
775 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
776 owner_uuid: adminUser.user.uuid,
777 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
779 .as('testCollection2').then(function (testCollection2) {
780 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
783 cy.getAll('@testCollection1', '@testCollection2')
784 .then(function ([testCollection1, testCollection2]) {
785 cy.loginAs(activeUser);
787 cy.goToPath(`/collections/${testCollection1.uuid}`);
788 cy.get('[data-cy=responsible-person-wrapper]')
789 .contains(activeUser.user.uuid);
791 cy.goToPath(`/collections/${testCollection2.uuid}`);
792 cy.get('[data-cy=responsible-person-wrapper]')
793 .contains(adminUser.user.uuid);
797 describe('file upload', () => {
799 cy.createCollection(adminUser.token, {
800 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
801 owner_uuid: activeUser.user.uuid,
802 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
804 .as('testCollection1');
807 it('allows to cancel running upload', () => {
808 cy.getAll('@testCollection1')
809 .then(function([testCollection1]) {
810 cy.loginAs(activeUser);
812 cy.goToPath(`/collections/${testCollection1.uuid}`);
814 cy.get('[data-cy=upload-button]').click();
816 cy.fixture('files/5mb.bin', 'base64').then(content => {
817 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
818 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
820 cy.get('[data-cy=form-submit-btn]').click();
822 cy.get('button').contains('Cancel').click();
824 cy.get('[data-cy=form-submit-btn]').should('not.exist');
829 it('allows to cancel single file from the running upload', () => {
830 cy.getAll('@testCollection1')
831 .then(function([testCollection1]) {
832 cy.loginAs(activeUser);
834 cy.goToPath(`/collections/${testCollection1.uuid}`);
836 cy.get('[data-cy=upload-button]').click();
838 cy.fixture('files/5mb.bin', 'base64').then(content => {
839 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
840 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
842 cy.get('[data-cy=form-submit-btn]').click();
844 cy.get('button[aria-label=Remove]').eq(1).click();
846 cy.get('[data-cy=form-submit-btn]').should('not.exist');
848 cy.get('[data-cy=collection-files-panel]').contains('5mb_a.bin').should('exist');
853 it('allows to cancel all files from the running upload', () => {
854 cy.getAll('@testCollection1')
855 .then(function([testCollection1]) {
856 cy.loginAs(activeUser);
858 cy.goToPath(`/collections/${testCollection1.uuid}`);
860 cy.get('[data-cy=upload-button]').click();
862 cy.fixture('files/5mb.bin', 'base64').then(content => {
863 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
864 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
866 cy.get('[data-cy=form-submit-btn]').click();
868 cy.get('button[aria-label=Remove]').click({ multiple: true });
870 cy.get('[data-cy=form-submit-btn]').should('not.exist');