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('moves a collection to a different project', function () {
599 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
600 const projName = `Test Project ${Math.floor(Math.random() * 999999)}`;
601 const fileName = `Test_File_${Math.floor(Math.random() * 999999)}`;
603 cy.createCollection(adminUser.token, {
605 owner_uuid: activeUser.user.uuid,
606 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
607 }).as('testCollection');
608 cy.createGroup(adminUser.token, {
610 group_class: 'project',
611 owner_uuid: activeUser.user.uuid,
612 }).as('testProject');
614 cy.getAll('@testCollection', '@testProject')
615 .then(function ([testCollection, testProject]) {
616 cy.loginAs(activeUser);
617 cy.goToPath(`/collections/${testCollection.uuid}`);
618 cy.get('[data-cy=collection-files-panel]').should('contain', fileName);
619 cy.get('[data-cy=collection-info-panel]')
620 .should('not.contain', projName)
621 .and('not.contain', testProject.uuid);
622 cy.get('[data-cy=collection-panel-options-btn]').click();
623 cy.get('[data-cy=context-menu]').contains('Move to').click();
624 cy.get('[data-cy=form-dialog]')
625 .should('contain', 'Move to')
627 cy.get('[data-cy=projects-tree-home-tree-picker]')
630 cy.get('[data-cy=projects-tree-home-tree-picker]')
634 cy.get('[data-cy=form-submit-btn]').click();
635 cy.get('[data-cy=snackbar]')
636 .contains('Collection has been moved')
637 cy.get('[data-cy=collection-info-panel]')
638 .contains(projName).and('contain', testProject.uuid);
639 // Double check that the collection is in the project
640 cy.goToPath(`/projects/${testProject.uuid}`);
641 cy.get('[data-cy=project-panel]').should('contain', collName);
645 it('makes a copy of an existing collection', function() {
646 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
647 const copyName = `Copy of: ${collName}`;
649 cy.createCollection(adminUser.token, {
651 owner_uuid: activeUser.user.uuid,
652 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
653 }).as('collection').then(function () {
654 cy.loginAs(activeUser)
655 cy.goToPath(`/collections/${this.collection.uuid}`);
656 cy.get('[data-cy=collection-files-panel]')
657 .should('contain', 'some-file');
658 cy.get('[data-cy=collection-panel-options-btn]').click();
659 cy.get('[data-cy=context-menu]').contains('Make a copy').click();
660 cy.get('[data-cy=form-dialog]')
661 .should('contain', 'Make a copy')
663 cy.get('[data-cy=projects-tree-home-tree-picker]')
664 .contains('Projects')
666 cy.get('[data-cy=form-submit-btn]').click();
668 cy.get('[data-cy=snackbar]')
669 .contains('Collection has been copied.')
670 cy.get('[data-cy=snackbar-goto-action]').click();
671 cy.get('[data-cy=project-panel]')
672 .contains(copyName).click();
673 cy.get('[data-cy=collection-files-panel]')
674 .should('contain', 'some-file');
678 it('uses the collection version browser to view a previous version', function () {
679 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
681 // Creates the collection using the admin token so we can set up
682 // a bogus manifest text without block signatures.
683 cy.createCollection(adminUser.token, {
685 owner_uuid: activeUser.user.uuid,
686 preserve_version: true,
687 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
689 .as('collection').then(function () {
690 // Visit collection, check basic information
691 cy.loginAs(activeUser)
692 cy.goToPath(`/collections/${this.collection.uuid}`);
694 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
695 cy.get('[data-cy=read-only-icon]').should('not.exist');
696 cy.get('[data-cy=collection-version-number]').should('contain', '1');
697 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
698 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
700 // Modify collection, expect version number change
701 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
702 cy.get('[data-cy=context-menu]').contains('Remove').click();
703 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
704 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
705 cy.get('[data-cy=collection-version-number]').should('contain', '2');
706 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
708 // Click on version number, check version browser. Click on past version.
709 cy.get('[data-cy=collection-version-browser]').should('not.exist');
710 cy.get('[data-cy=collection-version-number]').contains('2').click();
711 cy.get('[data-cy=collection-version-browser]')
712 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
714 // Version 1: 6 bytes in size
715 cy.get('[data-cy=collection-version-browser-select-1]')
716 .should('contain', '1')
717 .and('contain', '6 B')
718 .and('contain', adminUser.user.uuid);
719 // Version 2: 3 bytes in size (one file removed)
720 cy.get('[data-cy=collection-version-browser-select-2]')
721 .should('contain', '2')
722 .and('contain', '3 B')
723 .and('contain', activeUser.user.full_name);
724 cy.get('[data-cy=collection-version-browser-select-3]')
725 .should('not.exist');
726 cy.get('[data-cy=collection-version-browser-select-1]')
729 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
730 cy.get('[data-cy=read-only-icon]').should('exist');
731 cy.get('[data-cy=collection-version-number]').should('contain', '1');
732 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
733 cy.get('[data-cy=collection-files-panel]')
734 .should('contain', 'foo').and('contain', 'bar');
736 // Check that only old collection action are available on context menu
737 cy.get('[data-cy=collection-panel-options-btn]').click();
738 cy.get('[data-cy=context-menu]')
739 .should('contain', 'Restore version')
740 .and('not.contain', 'Add to favorites');
741 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
743 // Click on "head version" link, confirm that it's the latest version.
744 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
745 cy.get('[data-cy=collection-info-panel]')
746 .should('not.contain', 'This is an old version');
747 cy.get('[data-cy=read-only-icon]').should('not.exist');
748 cy.get('[data-cy=collection-version-number]').should('contain', '2');
749 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
750 cy.get('[data-cy=collection-files-panel]').
751 should('not.contain', 'foo').and('contain', 'bar');
753 // Check that old collection action isn't available on context menu
754 cy.get('[data-cy=collection-panel-options-btn]').click()
755 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
756 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
758 // Make another change, confirm new version.
759 cy.get('[data-cy=collection-panel-options-btn]').click();
760 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
761 cy.get('[data-cy=form-dialog]')
762 .should('contain', 'Edit Collection')
765 cy.get('input').first().type(' renamed');
767 cy.get('[data-cy=form-submit-btn]').click();
768 cy.get('[data-cy=collection-info-panel]')
769 .should('not.contain', 'This is an old version');
770 cy.get('[data-cy=read-only-icon]').should('not.exist');
771 cy.get('[data-cy=collection-version-number]').should('contain', '3');
772 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
773 cy.get('[data-cy=collection-files-panel]')
774 .should('not.contain', 'foo').and('contain', 'bar');
775 cy.get('[data-cy=collection-version-browser-select-3]')
776 .should('contain', '3').and('contain', '3 B');
778 // Check context menus on version browser
779 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
780 cy.get('[data-cy=context-menu]')
781 .should('contain', 'Add to favorites')
782 .and('contain', 'Make a copy')
783 .and('contain', 'Edit collection');
784 cy.get('body').click();
785 // (and now an old version...)
786 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
787 cy.get('[data-cy=context-menu]')
788 .should('not.contain', 'Add to favorites')
789 .and('contain', 'Make a copy')
790 .and('not.contain', 'Edit collection');
791 cy.get('body').click();
793 // Restore first version
794 cy.get('[data-cy=collection-version-browser]').within(() => {
795 cy.get('[data-cy=collection-version-browser-select-1]').click();
797 cy.get('[data-cy=collection-panel-options-btn]').click()
798 cy.get('[data-cy=context-menu]').contains('Restore version').click();
799 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
800 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
801 cy.get('[data-cy=collection-info-panel]')
802 .should('not.contain', 'This is an old version');
803 cy.get('[data-cy=collection-version-number]').should('contain', '4');
804 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
805 cy.get('[data-cy=collection-files-panel]')
806 .should('contain', 'foo').and('contain', 'bar');
810 it('creates new collection on home project', function () {
811 cy.loginAs(activeUser);
812 cy.goToPath(`/projects/${activeUser.user.uuid}`);
813 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
814 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
815 // Create new collection
816 cy.get('[data-cy=side-panel-button]').click();
817 cy.get('[data-cy=side-panel-new-collection]').click();
818 // Name between brackets tests bugfix #17582
819 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
820 cy.get('[data-cy=form-dialog]')
821 .should('contain', 'New collection')
822 .and('contain', 'Storage classes')
823 .and('contain', 'default')
824 .and('contain', 'foo')
825 .and('contain', 'bar')
827 cy.get('[data-cy=parent-field]').within(() => {
828 cy.get('input').should('have.value', 'Home project');
830 cy.get('[data-cy=name-field]').within(() => {
831 cy.get('input').type(collName);
833 cy.get('[data-cy=checkbox-foo]').click();
835 cy.get('[data-cy=form-submit-btn]').click();
836 // Confirm that the user was taken to the newly created thing
837 cy.get('[data-cy=form-dialog]').should('not.exist');
838 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
839 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
840 cy.get('[data-cy=collection-info-panel]')
841 .should('contain', 'default')
842 .and('contain', 'foo')
843 .and('not.contain', 'bar');
846 it('shows responsible person for collection if available', () => {
847 cy.createCollection(adminUser.token, {
848 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
849 owner_uuid: activeUser.user.uuid,
850 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
852 .as('testCollection1');
854 cy.createCollection(adminUser.token, {
855 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
856 owner_uuid: adminUser.user.uuid,
857 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
859 .as('testCollection2').then(function (testCollection2) {
860 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
863 cy.getAll('@testCollection1', '@testCollection2')
864 .then(function ([testCollection1, testCollection2]) {
865 cy.loginAs(activeUser);
867 cy.goToPath(`/collections/${testCollection1.uuid}`);
868 cy.get('[data-cy=responsible-person-wrapper]')
869 .contains(activeUser.user.uuid);
871 cy.goToPath(`/collections/${testCollection2.uuid}`);
872 cy.get('[data-cy=responsible-person-wrapper]')
873 .contains(adminUser.user.uuid);
877 describe('file upload', () => {
879 cy.createCollection(adminUser.token, {
880 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
881 owner_uuid: activeUser.user.uuid,
882 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
884 .as('testCollection1');
887 it('allows to cancel running upload', () => {
888 cy.getAll('@testCollection1')
889 .then(function([testCollection1]) {
890 cy.loginAs(activeUser);
892 cy.goToPath(`/collections/${testCollection1.uuid}`);
894 cy.get('[data-cy=upload-button]').click();
896 cy.fixture('files/5mb.bin', 'base64').then(content => {
897 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
898 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
900 cy.get('[data-cy=form-submit-btn]').click();
902 cy.get('button').contains('Cancel').click();
904 cy.get('[data-cy=form-submit-btn]').should('not.exist');
909 it('allows to cancel single file from the running upload', () => {
910 cy.getAll('@testCollection1')
911 .then(function([testCollection1]) {
912 cy.loginAs(activeUser);
914 cy.goToPath(`/collections/${testCollection1.uuid}`);
916 cy.get('[data-cy=upload-button]').click();
918 cy.fixture('files/5mb.bin', 'base64').then(content => {
919 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
920 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
922 cy.get('[data-cy=form-submit-btn]').click();
924 cy.get('button[aria-label=Remove]').eq(1).click();
926 cy.get('[data-cy=form-submit-btn]').should('not.exist');
928 cy.get('[data-cy=collection-files-panel]').contains('5mb_a.bin').should('exist');
933 it('allows to cancel all files from the running upload', () => {
934 cy.getAll('@testCollection1')
935 .then(function([testCollection1]) {
936 cy.loginAs(activeUser);
938 cy.goToPath(`/collections/${testCollection1.uuid}`);
940 cy.get('[data-cy=upload-button]').click();
942 cy.fixture('files/5mb.bin', 'base64').then(content => {
943 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
944 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
946 cy.get('[data-cy=form-submit-btn]').click();
948 cy.get('button[aria-label=Remove]').should('exist');
949 cy.get('button[aria-label=Remove]').click({ multiple: true, force: true });
951 cy.get('[data-cy=form-submit-btn]').should('not.exist');