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')
101 .and('contain', 'Magenta');
102 // Confirm proper vocabulary IDs were saved on the backend.
103 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
104 .its('body').as('collection')
106 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
111 it('shows collection by URL', function () {
112 cy.loginAs(activeUser);
113 [true, false].map(function (isWritable) {
114 // Using different file names to avoid test flakyness: the second iteration
115 // on this loop may pass an assertion from the first iteration by looking
116 // for the same file name.
117 const fileName = isWritable ? 'bar' : 'foo';
118 const subDirName = 'subdir';
119 cy.createGroup(adminUser.token, {
120 name: 'Shared project',
121 group_class: 'project',
122 }).as('sharedGroup').then(function () {
123 // Creates the collection using the admin token so we can set up
124 // a bogus manifest text without block signatures.
125 cy.createCollection(adminUser.token, {
126 name: 'Test collection',
127 owner_uuid: this.sharedGroup.uuid,
128 properties: { someKey: 'someValue' },
129 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
131 .as('testCollection').then(function () {
132 // Share the group with active user.
133 cy.createLink(adminUser.token, {
134 name: isWritable ? 'can_write' : 'can_read',
135 link_class: 'permission',
136 head_uuid: this.sharedGroup.uuid,
137 tail_uuid: activeUser.user.uuid
139 cy.goToPath(`/collections/${this.testCollection.uuid}`);
141 // Check that name & uuid are correct.
142 cy.get('[data-cy=collection-info-panel]')
143 .should('contain', this.testCollection.name)
144 .and('contain', this.testCollection.uuid)
145 .and('not.contain', 'This is an old version');
146 // Check for the read-only icon
147 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
148 // Check that both read and write operations are available on
149 // the 'More options' menu.
150 cy.get('[data-cy=collection-panel-options-btn]')
152 cy.get('[data-cy=context-menu]')
153 .should('contain', 'Add to favorites')
154 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
155 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
156 cy.get('[data-cy=collection-properties-panel]')
157 .should('contain', 'someKey')
158 .and('contain', 'someValue')
159 .and('not.contain', 'anotherKey')
160 .and('not.contain', 'anotherValue')
161 if (isWritable === true) {
162 // Check that properties can be added.
163 cy.get('[data-cy=resource-properties-form]').within(() => {
164 cy.get('[data-cy=property-field-key]').within(() => {
165 cy.get('input').type('anotherKey');
167 cy.get('[data-cy=property-field-value]').within(() => {
168 cy.get('input').type('anotherValue');
172 cy.get('[data-cy=collection-properties-panel]')
173 .should('contain', 'anotherKey')
174 .and('contain', 'anotherValue')
176 // Properties form shouldn't be displayed.
177 cy.get('[data-cy=resource-properties-form]').should('not.exist');
179 // Check that the file listing show both read & write operations
180 cy.get('[data-cy=collection-files-panel]').within(() => {
182 cy.root().should('contain', fileName);
184 cy.get('[data-cy=upload-button]')
185 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
188 // Test context menus
189 cy.get('[data-cy=collection-files-panel]')
190 .contains(fileName).rightclick({ force: true });
191 cy.get('[data-cy=context-menu]')
192 .should('contain', 'Download')
193 .and('contain', 'Open in new tab')
194 .and('contain', 'Copy to clipboard')
195 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
196 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
197 cy.get('body').click(); // Collapse the menu
198 cy.get('[data-cy=collection-files-panel]')
199 .contains(subDirName).rightclick({ force: true });
200 cy.get('[data-cy=context-menu]')
201 .should('not.contain', 'Download')
202 .and('contain', 'Open in new tab')
203 .and('contain', 'Copy to clipboard')
204 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
205 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
206 cy.get('body').click(); // Collapse the menu
207 // Hamburger 'more options' menu button
208 cy.get('[data-cy=collection-files-panel-options-btn]')
210 cy.get('[data-cy=context-menu]')
211 .should('contain', 'Select all')
213 cy.get('[data-cy=collection-files-panel-options-btn]')
215 cy.get('[data-cy=context-menu]')
216 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
217 cy.get('body').click(); // Collapse the menu
223 it('renames a file using valid names', function () {
224 function eachPair(lst, func){
225 for(var i=0; i < lst.length - 1; i++){
226 func(lst[i], lst[i + 1])
229 // Creates the collection using the admin token so we can set up
230 // a bogus manifest text without block signatures.
231 cy.createCollection(adminUser.token, {
232 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
233 owner_uuid: activeUser.user.uuid,
234 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
236 .as('testCollection').then(function () {
237 cy.loginAs(activeUser);
238 cy.goToPath(`/collections/${this.testCollection.uuid}`);
241 'bar', // initial name already set
248 'some name with whitespaces',
250 'is this name legal? I hope it is',
258 "G%C3%BCnter's%20file.pdf",
260 'bar' // make sure we can go back to the original name as a last step
262 eachPair(names, (from, to) => {
263 cy.get('[data-cy=collection-files-panel]')
264 .contains(`${from}`).rightclick();
265 cy.get('[data-cy=context-menu]')
268 cy.get('[data-cy=form-dialog]')
269 .should('contain', 'Rename')
272 .type('{selectall}{backspace}')
273 .type(to, { parseSpecialCharSequences: false });
275 cy.get('[data-cy=form-submit-btn]').click();
276 cy.get('[data-cy=collection-files-panel]')
277 .should('not.contain', `${from}`)
278 .and('contain', `${to}`);
283 it.skip('renames a file to a different directory', function () {
284 // Creates the collection using the admin token so we can set up
285 // a bogus manifest text without block signatures.
286 cy.createCollection(adminUser.token, {
287 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
288 owner_uuid: activeUser.user.uuid,
289 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
291 .as('testCollection').then(function () {
292 cy.loginAs(activeUser);
293 cy.goToPath(`/collections/${this.testCollection.uuid}`);
295 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
296 cy.get('[data-cy=collection-files-panel]')
297 .contains('bar').rightclick({force: true});
298 cy.get('[data-cy=context-menu]')
301 cy.get('[data-cy=form-dialog]')
302 .should('contain', 'Rename')
304 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
306 cy.get('[data-cy=form-submit-btn]').click();
307 cy.get('[data-cy=collection-files-panel]')
308 .should('not.contain', 'bar')
309 .and('contain', subdir);
310 // Look for the "arrow icon" and expand the "subdir" directory.
311 cy.get('[data-cy=virtual-file-tree] > div > i').click();
312 // Rename 'subdir/foo' to 'foo'
313 cy.get('[data-cy=collection-files-panel]')
314 .contains('foo').rightclick();
315 cy.get('[data-cy=context-menu]')
318 cy.get('[data-cy=form-dialog]')
319 .should('contain', 'Rename')
322 .should('have.value', `${subdir}/foo`)
323 .type(`{selectall}{backspace}bar`);
325 cy.get('[data-cy=form-submit-btn]').click();
326 cy.get('[data-cy=collection-files-panel]')
327 .should('contain', subdir) // empty dir kept
328 .and('contain', 'bar');
330 cy.get('[data-cy=collection-files-panel]')
331 .contains(subdir).rightclick();
332 cy.get('[data-cy=context-menu]')
335 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
340 it('renames a file to a different directory', function () {
341 // Creates the collection using the admin token so we can set up
342 // a bogus manifest text without block signatures.
343 cy.createCollection(adminUser.token, {
344 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
345 owner_uuid: activeUser.user.uuid,
346 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
348 .as('testCollection').then(function () {
349 cy.loginAs(activeUser);
350 cy.goToPath(`/collections/${this.testCollection.uuid}`);
352 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
353 cy.get('[data-cy=collection-files-panel]')
354 .contains('bar').rightclick({force: true});
355 cy.get('[data-cy=context-menu]')
358 cy.get('[data-cy=form-dialog]')
359 .should('contain', 'Rename')
361 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
363 cy.get('[data-cy=form-submit-btn]').click();
364 cy.get('[data-cy=collection-files-panel]')
365 .should('not.contain', 'bar')
366 .and('contain', subdir);
368 cy.get('[data-cy=collection-files-panel]').contains(subdir).click();
369 // Rename 'subdir/foo' to 'foo'
371 cy.get('[data-cy=collection-files-panel]')
372 .contains('foo').rightclick();
373 cy.get('[data-cy=context-menu]')
376 cy.get('[data-cy=form-dialog]')
377 .should('contain', 'Rename')
380 .should('have.value', `${subdir}/foo`)
381 .type(`{selectall}{backspace}bar`);
383 cy.get('[data-cy=form-submit-btn]').click();
386 cy.get('[data-cy=collection-files-panel]')
391 cy.get('[data-cy=collection-files-panel]')
392 .should('contain', subdir) // empty dir kept
393 .and('contain', 'bar');
395 cy.get('[data-cy=collection-files-panel]')
396 .contains(subdir).rightclick();
397 cy.get('[data-cy=context-menu]')
400 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
405 it('tries to rename a file with illegal names', function () {
406 // Creates the collection using the admin token so we can set up
407 // a bogus manifest text without block signatures.
408 cy.createCollection(adminUser.token, {
409 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
410 owner_uuid: activeUser.user.uuid,
411 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
413 .as('testCollection').then(function () {
414 cy.loginAs(activeUser);
415 cy.goToPath(`/collections/${this.testCollection.uuid}`);
417 const illegalNamesFromUI = [
418 ['.', "Name cannot be '.' or '..'"],
419 ['..', "Name cannot be '.' or '..'"],
420 ['', 'This field is required'],
421 [' ', 'Leading/trailing whitespaces not allowed'],
422 [' foo', 'Leading/trailing whitespaces not allowed'],
423 ['foo ', 'Leading/trailing whitespaces not allowed'],
424 ['//foo', 'Empty dir name not allowed']
426 illegalNamesFromUI.forEach(([name, errMsg]) => {
427 cy.get('[data-cy=collection-files-panel]')
428 .contains('bar').rightclick();
429 cy.get('[data-cy=context-menu]')
432 cy.get('[data-cy=form-dialog]')
433 .should('contain', 'Rename')
435 cy.get('input').type(`{selectall}{backspace}${name}`);
437 cy.get('[data-cy=form-dialog]')
438 .should('contain', 'Rename')
440 cy.contains(`${errMsg}`);
442 cy.get('[data-cy=form-cancel-btn]').click();
447 it('can correctly display old versions', function () {
448 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
450 let oldVersionUuid = '';
451 // Make sure no other collections with this name exist
452 cy.doRequest('GET', '/arvados/v1/collections', null, {
453 filters: `[["name", "=", "${colName}"]]`,
454 include_old_versions: true
456 .its('body.items').as('collections')
458 expect(this.collections).to.be.empty;
460 // Creates the collection using the admin token so we can set up
461 // a bogus manifest text without block signatures.
462 cy.createCollection(adminUser.token, {
464 owner_uuid: activeUser.user.uuid,
465 preserve_version: true,
466 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
468 .as('originalVersion').then(function () {
469 // Change the file name to create a new version.
470 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
471 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
473 colUuid = this.originalVersion.uuid;
475 // Confirm that there are 2 versions of the collection
476 cy.doRequest('GET', '/arvados/v1/collections', null, {
477 filters: `[["name", "=", "${colName}"]]`,
478 include_old_versions: true
480 .its('body.items').as('collections')
482 expect(this.collections).to.have.lengthOf(2);
483 this.collections.map(function (aCollection) {
484 expect(aCollection.current_version_uuid).to.equal(colUuid);
485 if (aCollection.uuid !== aCollection.current_version_uuid) {
486 oldVersionUuid = aCollection.uuid;
489 // Check the old version displays as what it is.
490 cy.loginAs(activeUser)
491 cy.goToPath(`/collections/${oldVersionUuid}`);
493 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
494 cy.get('[data-cy=read-only-icon]').should('exist');
495 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
496 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
500 it('views & edits storage classes data', function () {
501 const colName= `Test Collection ${Math.floor(Math.random() * 999999)}`;
502 cy.createCollection(adminUser.token, {
504 owner_uuid: activeUser.user.uuid,
505 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
506 }).as('collection').then(function () {
507 expect(this.collection.storage_classes_desired).to.deep.equal(['default'])
509 cy.loginAs(activeUser)
510 cy.goToPath(`/collections/${this.collection.uuid}`);
512 // Initial check: it should show the 'default' storage class
513 cy.get('[data-cy=collection-info-panel]')
514 .should('contain', 'Storage classes')
515 .and('contain', 'default')
516 .and('not.contain', 'foo')
517 .and('not.contain', 'bar');
518 // Edit collection: add storage class 'foo'
519 cy.get('[data-cy=collection-panel-options-btn]').click();
520 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
521 cy.get('[data-cy=form-dialog]')
522 .should('contain', 'Edit Collection')
523 .and('contain', 'Storage classes')
524 .and('contain', 'default')
525 .and('contain', 'foo')
526 .and('contain', 'bar')
528 cy.get('[data-cy=checkbox-foo]').click();
530 cy.get('[data-cy=form-submit-btn]').click();
531 cy.get('[data-cy=collection-info-panel]')
532 .should('contain', 'default')
533 .and('contain', 'foo')
534 .and('not.contain', 'bar');
535 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
536 .its('body').as('updatedCollection')
538 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['default', 'foo']);
540 // Edit collection: remove storage class 'default'
541 cy.get('[data-cy=collection-panel-options-btn]').click();
542 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
543 cy.get('[data-cy=form-dialog]')
544 .should('contain', 'Edit Collection')
545 .and('contain', 'Storage classes')
546 .and('contain', 'default')
547 .and('contain', 'foo')
548 .and('contain', 'bar')
550 cy.get('[data-cy=checkbox-default]').click();
552 cy.get('[data-cy=form-submit-btn]').click();
553 cy.get('[data-cy=collection-info-panel]')
554 .should('not.contain', 'default')
555 .and('contain', 'foo')
556 .and('not.contain', 'bar');
557 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
558 .its('body').as('updatedCollection')
560 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['foo']);
565 it('uses the collection version browser to view a previous version', function () {
566 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
568 // Creates the collection using the admin token so we can set up
569 // a bogus manifest text without block signatures.
570 cy.createCollection(adminUser.token, {
572 owner_uuid: activeUser.user.uuid,
573 preserve_version: true,
574 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
576 .as('collection').then(function () {
577 // Visit collection, check basic information
578 cy.loginAs(activeUser)
579 cy.goToPath(`/collections/${this.collection.uuid}`);
581 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
582 cy.get('[data-cy=read-only-icon]').should('not.exist');
583 cy.get('[data-cy=collection-version-number]').should('contain', '1');
584 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
585 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
587 // Modify collection, expect version number change
588 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
589 cy.get('[data-cy=context-menu]').contains('Remove').click();
590 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
591 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
592 cy.get('[data-cy=collection-version-number]').should('contain', '2');
593 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
595 // Click on version number, check version browser. Click on past version.
596 cy.get('[data-cy=collection-version-browser]').should('not.exist');
597 cy.get('[data-cy=collection-version-number]').contains('2').click();
598 cy.get('[data-cy=collection-version-browser]')
599 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
601 // Version 1: 6 bytes in size
602 cy.get('[data-cy=collection-version-browser-select-1]')
603 .should('contain', '1')
604 .and('contain', '6 B')
605 .and('contain', adminUser.user.uuid);
606 // Version 2: 3 bytes in size (one file removed)
607 cy.get('[data-cy=collection-version-browser-select-2]')
608 .should('contain', '2')
609 .and('contain', '3 B')
610 .and('contain', activeUser.user.full_name);
611 cy.get('[data-cy=collection-version-browser-select-3]')
612 .should('not.exist');
613 cy.get('[data-cy=collection-version-browser-select-1]')
616 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
617 cy.get('[data-cy=read-only-icon]').should('exist');
618 cy.get('[data-cy=collection-version-number]').should('contain', '1');
619 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
620 cy.get('[data-cy=collection-files-panel]')
621 .should('contain', 'foo').and('contain', 'bar');
623 // Check that only old collection action are available on context menu
624 cy.get('[data-cy=collection-panel-options-btn]').click();
625 cy.get('[data-cy=context-menu]')
626 .should('contain', 'Restore version')
627 .and('not.contain', 'Add to favorites');
628 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
630 // Click on "head version" link, confirm that it's the latest version.
631 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
632 cy.get('[data-cy=collection-info-panel]')
633 .should('not.contain', 'This is an old version');
634 cy.get('[data-cy=read-only-icon]').should('not.exist');
635 cy.get('[data-cy=collection-version-number]').should('contain', '2');
636 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
637 cy.get('[data-cy=collection-files-panel]').
638 should('not.contain', 'foo').and('contain', 'bar');
640 // Check that old collection action isn't available on context menu
641 cy.get('[data-cy=collection-panel-options-btn]').click()
642 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
643 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
645 // Make another change, confirm new version.
646 cy.get('[data-cy=collection-panel-options-btn]').click();
647 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
648 cy.get('[data-cy=form-dialog]')
649 .should('contain', 'Edit Collection')
652 cy.get('input').first().type(' renamed');
654 cy.get('[data-cy=form-submit-btn]').click();
655 cy.get('[data-cy=collection-info-panel]')
656 .should('not.contain', 'This is an old version');
657 cy.get('[data-cy=read-only-icon]').should('not.exist');
658 cy.get('[data-cy=collection-version-number]').should('contain', '3');
659 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
660 cy.get('[data-cy=collection-files-panel]')
661 .should('not.contain', 'foo').and('contain', 'bar');
662 cy.get('[data-cy=collection-version-browser-select-3]')
663 .should('contain', '3').and('contain', '3 B');
665 // Check context menus on version browser
666 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
667 cy.get('[data-cy=context-menu]')
668 .should('contain', 'Add to favorites')
669 .and('contain', 'Make a copy')
670 .and('contain', 'Edit collection');
671 cy.get('body').click();
672 // (and now an old version...)
673 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
674 cy.get('[data-cy=context-menu]')
675 .should('not.contain', 'Add to favorites')
676 .and('contain', 'Make a copy')
677 .and('not.contain', 'Edit collection');
678 cy.get('body').click();
680 // Restore first version
681 cy.get('[data-cy=collection-version-browser]').within(() => {
682 cy.get('[data-cy=collection-version-browser-select-1]').click();
684 cy.get('[data-cy=collection-panel-options-btn]').click()
685 cy.get('[data-cy=context-menu]').contains('Restore version').click();
686 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
687 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
688 cy.get('[data-cy=collection-info-panel]')
689 .should('not.contain', 'This is an old version');
690 cy.get('[data-cy=collection-version-number]').should('contain', '4');
691 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
692 cy.get('[data-cy=collection-files-panel]')
693 .should('contain', 'foo').and('contain', 'bar');
697 it('creates new collection on home project', function () {
698 cy.loginAs(activeUser);
699 cy.goToPath(`/projects/${activeUser.user.uuid}`);
700 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
701 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
702 // Create new collection
703 cy.get('[data-cy=side-panel-button]').click();
704 cy.get('[data-cy=side-panel-new-collection]').click();
705 // Name between brackets tests bugfix #17582
706 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
707 cy.get('[data-cy=form-dialog]')
708 .should('contain', 'New collection')
709 .and('contain', 'Storage classes')
710 .and('contain', 'default')
711 .and('contain', 'foo')
712 .and('contain', 'bar')
714 cy.get('[data-cy=parent-field]').within(() => {
715 cy.get('input').should('have.value', 'Home project');
717 cy.get('[data-cy=name-field]').within(() => {
718 cy.get('input').type(collName);
720 cy.get('[data-cy=checkbox-foo]').click();
722 cy.get('[data-cy=form-submit-btn]').click();
723 // Confirm that the user was taken to the newly created thing
724 cy.get('[data-cy=form-dialog]').should('not.exist');
725 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
726 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
727 cy.get('[data-cy=collection-info-panel]')
728 .should('contain', 'default')
729 .and('contain', 'foo')
730 .and('not.contain', 'bar');
733 it('shows responsible person for collection if available', () => {
734 cy.createCollection(adminUser.token, {
735 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
736 owner_uuid: activeUser.user.uuid,
737 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
739 .as('testCollection1');
741 cy.createCollection(adminUser.token, {
742 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
743 owner_uuid: adminUser.user.uuid,
744 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
746 .as('testCollection2').then(function (testCollection2) {
747 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
750 cy.getAll('@testCollection1', '@testCollection2')
751 .then(function ([testCollection1, testCollection2]) {
752 cy.loginAs(activeUser);
754 cy.goToPath(`/collections/${testCollection1.uuid}`);
755 cy.get('[data-cy=responsible-person-wrapper]')
756 .contains(activeUser.user.uuid);
758 cy.goToPath(`/collections/${testCollection2.uuid}`);
759 cy.get('[data-cy=responsible-person-wrapper]')
760 .contains(adminUser.user.uuid);