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.doRequest('GET', '/arvados/v1/config', null, null)
126 .its('body').should((clusterConfig) => {
127 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", false);
128 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
129 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
130 const inlineUrl = clusterConfig.Services.WebDAV.ExternalURL !== ""
131 ? clusterConfig.Services.WebDAV.ExternalURL
132 : clusterConfig.Services.WebDAVDownload.ExternalURL;
133 expect(inlineUrl).to.not.contain("*");
135 .createCollection(adminUser.token, {
136 name: 'Test collection',
137 owner_uuid: this.sharedGroup.uuid,
138 properties: { someKey: 'someValue' },
139 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
141 .as('testCollection').then(function () {
142 // Share the group with active user.
143 cy.createLink(adminUser.token, {
144 name: isWritable ? 'can_write' : 'can_read',
145 link_class: 'permission',
146 head_uuid: this.sharedGroup.uuid,
147 tail_uuid: activeUser.user.uuid
149 cy.goToPath(`/collections/${this.testCollection.uuid}`);
151 // Check that name & uuid are correct.
152 cy.get('[data-cy=collection-info-panel]')
153 .should('contain', this.testCollection.name)
154 .and('contain', this.testCollection.uuid)
155 .and('not.contain', 'This is an old version');
156 // Check for the read-only icon
157 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
158 // Check that both read and write operations are available on
159 // the 'More options' menu.
160 cy.get('[data-cy=collection-panel-options-btn]')
162 cy.get('[data-cy=context-menu]')
163 .should('contain', 'Add to favorites')
164 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
165 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
166 cy.get('[data-cy=collection-properties-panel]')
167 .should('contain', 'someKey')
168 .and('contain', 'someValue')
169 .and('not.contain', 'anotherKey')
170 .and('not.contain', 'anotherValue')
171 if (isWritable === true) {
172 // Check that properties can be added.
173 cy.get('[data-cy=resource-properties-form]').within(() => {
174 cy.get('[data-cy=property-field-key]').within(() => {
175 cy.get('input').type('anotherKey');
177 cy.get('[data-cy=property-field-value]').within(() => {
178 cy.get('input').type('anotherValue');
182 cy.get('[data-cy=collection-properties-panel]')
183 .should('contain', 'anotherKey')
184 .and('contain', 'anotherValue')
186 // Properties form shouldn't be displayed.
187 cy.get('[data-cy=resource-properties-form]').should('not.exist');
189 // Check that the file listing show both read & write operations
190 cy.get('[data-cy=collection-files-panel]').within(() => {
192 cy.root().should('contain', fileName);
194 cy.get('[data-cy=upload-button]')
195 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
198 // Test context menus
199 cy.get('[data-cy=collection-files-panel]')
200 .contains(fileName).rightclick({ force: true });
201 cy.get('[data-cy=context-menu]')
202 .should('contain', 'Download')
203 .and('not.contain', 'Open in new tab')
204 .and('contain', 'Copy to clipboard')
205 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
206 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
207 cy.get('body').click(); // Collapse the menu
208 cy.get('[data-cy=collection-files-panel]')
209 .contains(subDirName).rightclick({ force: true });
210 cy.get('[data-cy=context-menu]')
211 .should('not.contain', 'Download')
212 .and('not.contain', 'Open in new tab')
213 .and('contain', 'Copy to clipboard')
214 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
215 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
216 cy.get('body').click(); // Collapse the menu
217 // Hamburger 'more options' menu button
218 cy.get('[data-cy=collection-files-panel-options-btn]')
220 cy.get('[data-cy=context-menu]')
221 .should('contain', 'Select all')
223 cy.get('[data-cy=collection-files-panel-options-btn]')
225 cy.get('[data-cy=context-menu]')
226 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
227 cy.get('body').click(); // Collapse the menu
233 it('renames a file using valid names', function () {
234 function eachPair(lst, func){
235 for(var i=0; i < lst.length - 1; i++){
236 func(lst[i], lst[i + 1])
239 // Creates the collection using the admin token so we can set up
240 // a bogus manifest text without block signatures.
241 cy.createCollection(adminUser.token, {
242 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
243 owner_uuid: activeUser.user.uuid,
244 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
246 .as('testCollection').then(function () {
247 cy.loginAs(activeUser);
248 cy.goToPath(`/collections/${this.testCollection.uuid}`);
251 'bar', // initial name already set
258 'some name with whitespaces',
260 'is this name legal? I hope it is',
268 "G%C3%BCnter's%20file.pdf",
270 'bar' // make sure we can go back to the original name as a last step
272 eachPair(names, (from, to) => {
273 cy.get('[data-cy=collection-files-panel]')
274 .contains(`${from}`).rightclick();
275 cy.get('[data-cy=context-menu]')
278 cy.get('[data-cy=form-dialog]')
279 .should('contain', 'Rename')
282 .type('{selectall}{backspace}')
283 .type(to, { parseSpecialCharSequences: false });
285 cy.get('[data-cy=form-submit-btn]').click();
286 cy.get('[data-cy=collection-files-panel]')
287 .should('not.contain', `${from}`)
288 .and('contain', `${to}`);
293 it.skip('renames a file to a different directory', function () {
294 // Creates the collection using the admin token so we can set up
295 // a bogus manifest text without block signatures.
296 cy.createCollection(adminUser.token, {
297 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
298 owner_uuid: activeUser.user.uuid,
299 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
301 .as('testCollection').then(function () {
302 cy.loginAs(activeUser);
303 cy.goToPath(`/collections/${this.testCollection.uuid}`);
305 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
306 cy.get('[data-cy=collection-files-panel]')
307 .contains('bar').rightclick({force: true});
308 cy.get('[data-cy=context-menu]')
311 cy.get('[data-cy=form-dialog]')
312 .should('contain', 'Rename')
314 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
316 cy.get('[data-cy=form-submit-btn]').click();
317 cy.get('[data-cy=collection-files-panel]')
318 .should('not.contain', 'bar')
319 .and('contain', subdir);
320 // Look for the "arrow icon" and expand the "subdir" directory.
321 cy.get('[data-cy=virtual-file-tree] > div > i').click();
322 // Rename 'subdir/foo' to 'foo'
323 cy.get('[data-cy=collection-files-panel]')
324 .contains('foo').rightclick();
325 cy.get('[data-cy=context-menu]')
328 cy.get('[data-cy=form-dialog]')
329 .should('contain', 'Rename')
332 .should('have.value', `${subdir}/foo`)
333 .type(`{selectall}{backspace}bar`);
335 cy.get('[data-cy=form-submit-btn]').click();
336 cy.get('[data-cy=collection-files-panel]')
337 .should('contain', subdir) // empty dir kept
338 .and('contain', 'bar');
340 cy.get('[data-cy=collection-files-panel]')
341 .contains(subdir).rightclick();
342 cy.get('[data-cy=context-menu]')
345 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
350 it('renames a file to a different directory', function () {
351 // Creates the collection using the admin token so we can set up
352 // a bogus manifest text without block signatures.
353 cy.createCollection(adminUser.token, {
354 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
355 owner_uuid: activeUser.user.uuid,
356 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
358 .as('testCollection').then(function () {
359 cy.loginAs(activeUser);
360 cy.goToPath(`/collections/${this.testCollection.uuid}`);
362 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
363 cy.get('[data-cy=collection-files-panel]')
364 .contains('bar').rightclick({force: true});
365 cy.get('[data-cy=context-menu]')
368 cy.get('[data-cy=form-dialog]')
369 .should('contain', 'Rename')
371 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
373 cy.get('[data-cy=form-submit-btn]').click();
374 cy.get('[data-cy=collection-files-panel]')
375 .should('not.contain', 'bar')
376 .and('contain', subdir);
378 cy.get('[data-cy=collection-files-panel]').contains(subdir).click();
379 // Rename 'subdir/foo' to 'foo'
381 cy.get('[data-cy=collection-files-panel]')
382 .contains('foo').rightclick();
383 cy.get('[data-cy=context-menu]')
386 cy.get('[data-cy=form-dialog]')
387 .should('contain', 'Rename')
390 .should('have.value', `${subdir}/foo`)
391 .type(`{selectall}{backspace}bar`);
393 cy.get('[data-cy=form-submit-btn]').click();
396 cy.get('[data-cy=collection-files-panel]')
401 cy.get('[data-cy=collection-files-panel]')
402 .should('contain', subdir) // empty dir kept
403 .and('contain', 'bar');
405 cy.get('[data-cy=collection-files-panel]')
406 .contains(subdir).rightclick();
407 cy.get('[data-cy=context-menu]')
410 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
415 it('tries to rename a file with illegal names', function () {
416 // Creates the collection using the admin token so we can set up
417 // a bogus manifest text without block signatures.
418 cy.createCollection(adminUser.token, {
419 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
420 owner_uuid: activeUser.user.uuid,
421 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
423 .as('testCollection').then(function () {
424 cy.loginAs(activeUser);
425 cy.goToPath(`/collections/${this.testCollection.uuid}`);
427 const illegalNamesFromUI = [
428 ['.', "Name cannot be '.' or '..'"],
429 ['..', "Name cannot be '.' or '..'"],
430 ['', 'This field is required'],
431 [' ', 'Leading/trailing whitespaces not allowed'],
432 [' foo', 'Leading/trailing whitespaces not allowed'],
433 ['foo ', 'Leading/trailing whitespaces not allowed'],
434 ['//foo', 'Empty dir name not allowed']
436 illegalNamesFromUI.forEach(([name, errMsg]) => {
437 cy.get('[data-cy=collection-files-panel]')
438 .contains('bar').rightclick();
439 cy.get('[data-cy=context-menu]')
442 cy.get('[data-cy=form-dialog]')
443 .should('contain', 'Rename')
445 cy.get('input').type(`{selectall}{backspace}${name}`);
447 cy.get('[data-cy=form-dialog]')
448 .should('contain', 'Rename')
450 cy.contains(`${errMsg}`);
452 cy.get('[data-cy=form-cancel-btn]').click();
457 it('can correctly display old versions', function () {
458 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
460 let oldVersionUuid = '';
461 // Make sure no other collections with this name exist
462 cy.doRequest('GET', '/arvados/v1/collections', null, {
463 filters: `[["name", "=", "${colName}"]]`,
464 include_old_versions: true
466 .its('body.items').as('collections')
468 expect(this.collections).to.be.empty;
470 // Creates the collection using the admin token so we can set up
471 // a bogus manifest text without block signatures.
472 cy.createCollection(adminUser.token, {
474 owner_uuid: activeUser.user.uuid,
475 preserve_version: true,
476 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
478 .as('originalVersion').then(function () {
479 // Change the file name to create a new version.
480 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
481 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
483 colUuid = this.originalVersion.uuid;
485 // Confirm that there are 2 versions of the collection
486 cy.doRequest('GET', '/arvados/v1/collections', null, {
487 filters: `[["name", "=", "${colName}"]]`,
488 include_old_versions: true
490 .its('body.items').as('collections')
492 expect(this.collections).to.have.lengthOf(2);
493 this.collections.map(function (aCollection) {
494 expect(aCollection.current_version_uuid).to.equal(colUuid);
495 if (aCollection.uuid !== aCollection.current_version_uuid) {
496 oldVersionUuid = aCollection.uuid;
499 // Check the old version displays as what it is.
500 cy.loginAs(activeUser)
501 cy.goToPath(`/collections/${oldVersionUuid}`);
503 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
504 cy.get('[data-cy=read-only-icon]').should('exist');
505 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
506 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
510 it('views & edits storage classes data', function () {
511 const colName= `Test Collection ${Math.floor(Math.random() * 999999)}`;
512 cy.createCollection(adminUser.token, {
514 owner_uuid: activeUser.user.uuid,
515 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
516 }).as('collection').then(function () {
517 expect(this.collection.storage_classes_desired).to.deep.equal(['default'])
519 cy.loginAs(activeUser)
520 cy.goToPath(`/collections/${this.collection.uuid}`);
522 // Initial check: it should show the 'default' storage class
523 cy.get('[data-cy=collection-info-panel]')
524 .should('contain', 'Storage classes')
525 .and('contain', 'default')
526 .and('not.contain', 'foo')
527 .and('not.contain', 'bar');
528 // Edit collection: add storage class 'foo'
529 cy.get('[data-cy=collection-panel-options-btn]').click();
530 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
531 cy.get('[data-cy=form-dialog]')
532 .should('contain', 'Edit Collection')
533 .and('contain', 'Storage classes')
534 .and('contain', 'default')
535 .and('contain', 'foo')
536 .and('contain', 'bar')
538 cy.get('[data-cy=checkbox-foo]').click();
540 cy.get('[data-cy=form-submit-btn]').click();
541 cy.get('[data-cy=collection-info-panel]')
542 .should('contain', 'default')
543 .and('contain', 'foo')
544 .and('not.contain', 'bar');
545 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
546 .its('body').as('updatedCollection')
548 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['default', 'foo']);
550 // Edit collection: remove storage class 'default'
551 cy.get('[data-cy=collection-panel-options-btn]').click();
552 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
553 cy.get('[data-cy=form-dialog]')
554 .should('contain', 'Edit Collection')
555 .and('contain', 'Storage classes')
556 .and('contain', 'default')
557 .and('contain', 'foo')
558 .and('contain', 'bar')
560 cy.get('[data-cy=checkbox-default]').click();
562 cy.get('[data-cy=form-submit-btn]').click();
563 cy.get('[data-cy=collection-info-panel]')
564 .should('not.contain', 'default')
565 .and('contain', 'foo')
566 .and('not.contain', 'bar');
567 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
568 .its('body').as('updatedCollection')
570 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['foo']);
575 it('uses the collection version browser to view a previous version', function () {
576 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
578 // Creates the collection using the admin token so we can set up
579 // a bogus manifest text without block signatures.
580 cy.createCollection(adminUser.token, {
582 owner_uuid: activeUser.user.uuid,
583 preserve_version: true,
584 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
586 .as('collection').then(function () {
587 // Visit collection, check basic information
588 cy.loginAs(activeUser)
589 cy.goToPath(`/collections/${this.collection.uuid}`);
591 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
592 cy.get('[data-cy=read-only-icon]').should('not.exist');
593 cy.get('[data-cy=collection-version-number]').should('contain', '1');
594 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
595 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
597 // Modify collection, expect version number change
598 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
599 cy.get('[data-cy=context-menu]').contains('Remove').click();
600 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
601 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
602 cy.get('[data-cy=collection-version-number]').should('contain', '2');
603 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
605 // Click on version number, check version browser. Click on past version.
606 cy.get('[data-cy=collection-version-browser]').should('not.exist');
607 cy.get('[data-cy=collection-version-number]').contains('2').click();
608 cy.get('[data-cy=collection-version-browser]')
609 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
611 // Version 1: 6 bytes in size
612 cy.get('[data-cy=collection-version-browser-select-1]')
613 .should('contain', '1')
614 .and('contain', '6 B')
615 .and('contain', adminUser.user.uuid);
616 // Version 2: 3 bytes in size (one file removed)
617 cy.get('[data-cy=collection-version-browser-select-2]')
618 .should('contain', '2')
619 .and('contain', '3 B')
620 .and('contain', activeUser.user.full_name);
621 cy.get('[data-cy=collection-version-browser-select-3]')
622 .should('not.exist');
623 cy.get('[data-cy=collection-version-browser-select-1]')
626 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
627 cy.get('[data-cy=read-only-icon]').should('exist');
628 cy.get('[data-cy=collection-version-number]').should('contain', '1');
629 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
630 cy.get('[data-cy=collection-files-panel]')
631 .should('contain', 'foo').and('contain', 'bar');
633 // Check that only old collection action are available on context menu
634 cy.get('[data-cy=collection-panel-options-btn]').click();
635 cy.get('[data-cy=context-menu]')
636 .should('contain', 'Restore version')
637 .and('not.contain', 'Add to favorites');
638 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
640 // Click on "head version" link, confirm that it's the latest version.
641 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
642 cy.get('[data-cy=collection-info-panel]')
643 .should('not.contain', 'This is an old version');
644 cy.get('[data-cy=read-only-icon]').should('not.exist');
645 cy.get('[data-cy=collection-version-number]').should('contain', '2');
646 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
647 cy.get('[data-cy=collection-files-panel]').
648 should('not.contain', 'foo').and('contain', 'bar');
650 // Check that old collection action isn't available on context menu
651 cy.get('[data-cy=collection-panel-options-btn]').click()
652 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
653 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
655 // Make another change, confirm new version.
656 cy.get('[data-cy=collection-panel-options-btn]').click();
657 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
658 cy.get('[data-cy=form-dialog]')
659 .should('contain', 'Edit Collection')
662 cy.get('input').first().type(' renamed');
664 cy.get('[data-cy=form-submit-btn]').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', '3');
669 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
670 cy.get('[data-cy=collection-files-panel]')
671 .should('not.contain', 'foo').and('contain', 'bar');
672 cy.get('[data-cy=collection-version-browser-select-3]')
673 .should('contain', '3').and('contain', '3 B');
675 // Check context menus on version browser
676 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
677 cy.get('[data-cy=context-menu]')
678 .should('contain', 'Add to favorites')
679 .and('contain', 'Make a copy')
680 .and('contain', 'Edit collection');
681 cy.get('body').click();
682 // (and now an old version...)
683 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
684 cy.get('[data-cy=context-menu]')
685 .should('not.contain', 'Add to favorites')
686 .and('contain', 'Make a copy')
687 .and('not.contain', 'Edit collection');
688 cy.get('body').click();
690 // Restore first version
691 cy.get('[data-cy=collection-version-browser]').within(() => {
692 cy.get('[data-cy=collection-version-browser-select-1]').click();
694 cy.get('[data-cy=collection-panel-options-btn]').click()
695 cy.get('[data-cy=context-menu]').contains('Restore version').click();
696 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
697 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
698 cy.get('[data-cy=collection-info-panel]')
699 .should('not.contain', 'This is an old version');
700 cy.get('[data-cy=collection-version-number]').should('contain', '4');
701 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
702 cy.get('[data-cy=collection-files-panel]')
703 .should('contain', 'foo').and('contain', 'bar');
707 it('creates new collection on home project', function () {
708 cy.loginAs(activeUser);
709 cy.goToPath(`/projects/${activeUser.user.uuid}`);
710 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
711 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
712 // Create new collection
713 cy.get('[data-cy=side-panel-button]').click();
714 cy.get('[data-cy=side-panel-new-collection]').click();
715 // Name between brackets tests bugfix #17582
716 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
717 cy.get('[data-cy=form-dialog]')
718 .should('contain', 'New collection')
719 .and('contain', 'Storage classes')
720 .and('contain', 'default')
721 .and('contain', 'foo')
722 .and('contain', 'bar')
724 cy.get('[data-cy=parent-field]').within(() => {
725 cy.get('input').should('have.value', 'Home project');
727 cy.get('[data-cy=name-field]').within(() => {
728 cy.get('input').type(collName);
730 cy.get('[data-cy=checkbox-foo]').click();
732 cy.get('[data-cy=form-submit-btn]').click();
733 // Confirm that the user was taken to the newly created thing
734 cy.get('[data-cy=form-dialog]').should('not.exist');
735 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
736 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
737 cy.get('[data-cy=collection-info-panel]')
738 .should('contain', 'default')
739 .and('contain', 'foo')
740 .and('not.contain', 'bar');
743 it('shows responsible person for collection if available', () => {
744 cy.createCollection(adminUser.token, {
745 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
746 owner_uuid: activeUser.user.uuid,
747 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
749 .as('testCollection1');
751 cy.createCollection(adminUser.token, {
752 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
753 owner_uuid: adminUser.user.uuid,
754 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
756 .as('testCollection2').then(function (testCollection2) {
757 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
760 cy.getAll('@testCollection1', '@testCollection2')
761 .then(function ([testCollection1, testCollection2]) {
762 cy.loginAs(activeUser);
764 cy.goToPath(`/collections/${testCollection1.uuid}`);
765 cy.get('[data-cy=responsible-person-wrapper]')
766 .contains(activeUser.user.uuid);
768 cy.goToPath(`/collections/${testCollection2.uuid}`);
769 cy.get('[data-cy=responsible-person-wrapper]')
770 .contains(adminUser.user.uuid);
774 describe('file upload', () => {
775 it('allows to cancel running upload', () => {
776 cy.createCollection(adminUser.token, {
777 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
778 owner_uuid: activeUser.user.uuid,
779 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
781 .as('testCollection1');
783 cy.getAll('@testCollection1')
784 .then(function([testCollection1]) {
785 cy.loginAs(activeUser);
787 cy.goToPath(`/collections/${testCollection1.uuid}`);
789 cy.get('[data-cy=upload-button]').click();
791 cy.fixture('files/5mb.bin', 'base64').then(content => {
792 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
793 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
797 cy.get('[data-cy=form-submit-btn]').click();
801 cy.get('button').contains('Cancel').click();
803 cy.get('[data-cy=form-submit-btn]').should('not.exist');
808 it('allows to cancel single file from the running upload', () => {
809 cy.createCollection(adminUser.token, {
810 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
811 owner_uuid: activeUser.user.uuid,
812 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
814 .as('testCollection1');
816 cy.getAll('@testCollection1')
817 .then(function([testCollection1]) {
818 cy.loginAs(activeUser);
820 cy.goToPath(`/collections/${testCollection1.uuid}`);
822 cy.get('[data-cy=upload-button]').click();
824 cy.fixture('files/5mb.bin', 'base64').then(content => {
825 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
826 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
830 cy.get('[data-cy=form-submit-btn]').click();
834 cy.get('button[aria-label=Remove]').eq(1).click();