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 (from edit dialog) 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 cy.get('[data-cy=collection-info-panel')
89 .should('contain', this.testCollection.name)
90 .and('not.contain', 'Color: Magenta');
92 cy.get('[data-cy=collection-panel-options-btn]').click();
93 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
94 cy.get('[data-cy=form-dialog]').should('contain', 'Properties');
96 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
97 cy.get('[data-cy=resource-properties-form]').within(() => {
98 cy.get('[data-cy=property-field-key]').within(() => {
99 cy.get('input').type('Color');
101 cy.get('[data-cy=property-field-value]').within(() => {
102 cy.get('input').type('Magenta');
106 // Confirm proper vocabulary labels are displayed on the UI.
107 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
108 cy.get('[data-cy=form-dialog]').contains('Save').click();
109 cy.get('[data-cy=form-dialog]').should('not.exist');
110 // Confirm proper vocabulary IDs were saved on the backend.
111 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
112 .its('body').as('collection')
114 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
116 // Confirm the property is displayed on the UI.
117 cy.get('[data-cy=collection-info-panel')
118 .should('contain', this.testCollection.name)
119 .and('contain', 'Color: Magenta');
123 it('uses the editor (from details panel) with vocabulary terms', function () {
124 cy.createCollection(adminUser.token, {
125 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
126 owner_uuid: activeUser.user.uuid,
127 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
129 .as('testCollection').then(function () {
130 cy.loginAs(activeUser);
131 cy.goToPath(`/collections/${this.testCollection.uuid}`);
133 cy.get('[data-cy=collection-info-panel')
134 .should('contain', this.testCollection.name)
135 .and('not.contain', 'Color: Magenta')
136 .and('not.contain', 'Size: S');
137 cy.get('[data-cy=additional-info-icon]').click();
139 cy.get('[data-cy=details-panel]').within(() => {
140 cy.get('[data-cy=details-panel-edit-btn]').click();
142 cy.get('[data-cy=form-dialog').contains('Edit Collection');
144 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
145 cy.get('[data-cy=resource-properties-form]').within(() => {
146 cy.get('[data-cy=property-field-key]').within(() => {
147 cy.get('input').type('Color');
149 cy.get('[data-cy=property-field-value]').within(() => {
150 cy.get('input').type('Magenta');
154 // Confirm proper vocabulary labels are displayed on the UI.
155 cy.get('[data-cy=form-dialog]')
156 .should('contain', 'Color: Magenta');
158 // Case-insensitive on-blur auto-selection test
159 // Key: Size (IDTAGSIZES) - Value: Small (IDVALSIZES2)
160 cy.get('[data-cy=resource-properties-form]').within(() => {
161 cy.get('[data-cy=property-field-key]').within(() => {
162 cy.get('input').type('sIzE');
164 cy.get('[data-cy=property-field-value]').within(() => {
165 cy.get('input').type('sMaLL');
167 // Cannot "type()" TAB on Cypress so let's click another field
168 // to trigger the onBlur event.
169 cy.get('[data-cy=property-field-key]').click();
172 // Confirm proper vocabulary labels are displayed on the UI.
173 cy.get('[data-cy=form-dialog]')
174 .should('contain', 'Size: S');
176 cy.get('[data-cy=form-dialog]').contains('Save').click();
177 cy.get('[data-cy=form-dialog]').should('not.exist');
179 // Confirm proper vocabulary IDs were saved on the backend.
180 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
181 .its('body').as('collection')
183 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
184 expect(this.collection.properties.IDTAGSIZES).to.equal('IDVALSIZES2');
187 // Confirm properties display on the UI.
188 cy.get('[data-cy=collection-info-panel')
189 .should('contain', this.testCollection.name)
190 .and('contain', 'Color: Magenta')
191 .and('contain', 'Size: S');
195 it('shows collection by URL', function () {
196 cy.loginAs(activeUser);
197 [true, false].map(function (isWritable) {
198 // Using different file names to avoid test flakyness: the second iteration
199 // on this loop may pass an assertion from the first iteration by looking
200 // for the same file name.
201 const fileName = isWritable ? 'bar' : 'foo';
202 const subDirName = 'subdir';
203 cy.createGroup(adminUser.token, {
204 name: 'Shared project',
205 group_class: 'project',
206 }).as('sharedGroup').then(function () {
207 // Creates the collection using the admin token so we can set up
208 // a bogus manifest text without block signatures.
209 cy.doRequest('GET', '/arvados/v1/config', null, null)
210 .its('body').should((clusterConfig) => {
211 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", false);
212 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
213 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
214 const inlineUrl = clusterConfig.Services.WebDAV.ExternalURL !== ""
215 ? clusterConfig.Services.WebDAV.ExternalURL
216 : clusterConfig.Services.WebDAVDownload.ExternalURL;
217 expect(inlineUrl).to.not.contain("*");
219 .createCollection(adminUser.token, {
220 name: 'Test collection',
221 owner_uuid: this.sharedGroup.uuid,
222 properties: { someKey: 'someValue' },
223 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
225 .as('testCollection').then(function () {
226 // Share the group with active user.
227 cy.createLink(adminUser.token, {
228 name: isWritable ? 'can_write' : 'can_read',
229 link_class: 'permission',
230 head_uuid: this.sharedGroup.uuid,
231 tail_uuid: activeUser.user.uuid
233 cy.goToPath(`/collections/${this.testCollection.uuid}`);
235 // Check that name & uuid are correct.
236 cy.get('[data-cy=collection-info-panel]')
237 .should('contain', this.testCollection.name)
238 .and('contain', this.testCollection.uuid)
239 .and('not.contain', 'This is an old version');
240 // Check for the read-only icon
241 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
242 // Check that both read and write operations are available on
243 // the 'More options' menu.
244 cy.get('[data-cy=collection-panel-options-btn]')
246 cy.get('[data-cy=context-menu]')
247 .should('contain', 'Add to favorites')
248 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
249 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
250 cy.get('[data-cy=collection-info-panel]')
251 .should('contain', 'someKey: someValue')
252 .and('not.contain', 'anotherKey: anotherValue');
253 // Check that the file listing show both read & write operations
254 cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
255 cy.get('[data-cy=collection-files-right-panel]', { timeout: 5000 })
256 .should('contain', fileName);
258 cy.get('[data-cy=upload-button]')
259 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
262 // Test context menus
263 cy.get('[data-cy=collection-files-panel]')
264 .contains(fileName).rightclick();
265 cy.get('[data-cy=context-menu]')
266 .should('contain', 'Download')
267 .and('not.contain', 'Open in new tab')
268 .and('contain', 'Copy to clipboard')
269 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
270 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
271 cy.get('body').click(); // Collapse the menu
272 cy.get('[data-cy=collection-files-panel]')
273 .contains(subDirName).rightclick();
274 cy.get('[data-cy=context-menu]')
275 .should('not.contain', 'Download')
276 .and('not.contain', 'Open in new tab')
277 .and('contain', 'Copy to clipboard')
278 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
279 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
280 cy.get('body').click(); // Collapse the menu
281 // Hamburger 'more options' menu button
282 cy.get('[data-cy=collection-files-panel-options-btn]')
284 cy.get('[data-cy=context-menu]')
285 .should('contain', 'Select all')
287 cy.get('[data-cy=collection-files-panel-options-btn]')
289 cy.get('[data-cy=context-menu]')
290 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
291 cy.get('body').click(); // Collapse the menu
297 it('renames a file using valid names', function () {
298 function eachPair(lst, func){
299 for(var i=0; i < lst.length - 1; i++){
300 func(lst[i], lst[i + 1])
303 // Creates the collection using the admin token so we can set up
304 // a bogus manifest text without block signatures.
305 cy.createCollection(adminUser.token, {
306 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
307 owner_uuid: activeUser.user.uuid,
308 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
310 .as('testCollection').then(function () {
311 cy.loginAs(activeUser);
312 cy.goToPath(`/collections/${this.testCollection.uuid}`);
315 'bar', // initial name already set
322 'some name with whitespaces',
324 'is this name legal? I hope it is',
332 "G%C3%BCnter's%20file.pdf",
334 'bar' // make sure we can go back to the original name as a last step
336 eachPair(names, (from, to) => {
337 cy.waitForDom().get('[data-cy=collection-files-panel]')
338 .contains(`${from}`).rightclick();
339 cy.get('[data-cy=context-menu]')
342 cy.get('[data-cy=form-dialog]')
343 .should('contain', 'Rename')
346 .type('{selectall}{backspace}')
347 .type(to, { parseSpecialCharSequences: false });
349 cy.get('[data-cy=form-submit-btn]').click();
350 cy.get('[data-cy=collection-files-panel]')
351 .should('not.contain', `${from}`)
352 .and('contain', `${to}`);
357 it('renames a file to a different directory', function () {
358 // Creates the collection using the admin token so we can set up
359 // a bogus manifest text without block signatures.
360 cy.createCollection(adminUser.token, {
361 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
362 owner_uuid: activeUser.user.uuid,
363 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
365 .as('testCollection').then(function () {
366 cy.loginAs(activeUser);
367 cy.goToPath(`/collections/${this.testCollection.uuid}`);
369 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
370 cy.get('[data-cy=collection-files-panel]')
371 .contains('bar').rightclick();
372 cy.get('[data-cy=context-menu]')
375 cy.get('[data-cy=form-dialog]')
376 .should('contain', 'Rename')
378 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
380 cy.get('[data-cy=form-submit-btn]').click();
381 cy.get('[data-cy=collection-files-panel]')
382 .should('not.contain', 'bar')
383 .and('contain', subdir);
384 cy.get('[data-cy=collection-files-panel]').contains(subdir).click();
386 // Rename 'subdir/foo' to 'bar'
388 cy.get('[data-cy=collection-files-panel]')
389 .contains('foo').rightclick();
390 cy.get('[data-cy=context-menu]')
393 cy.get('[data-cy=form-dialog]')
394 .should('contain', 'Rename')
397 .should('have.value', `${subdir}/foo`)
398 .type(`{selectall}{backspace}bar`);
400 cy.get('[data-cy=form-submit-btn]').click();
402 cy.get('[data-cy=collection-files-panel]')
407 cy.get('[data-cy=collection-files-panel]')
408 .should('contain', subdir) // empty dir kept
409 .and('contain', 'bar');
411 cy.get('[data-cy=collection-files-panel]')
412 .contains(subdir).rightclick();
413 cy.get('[data-cy=context-menu]')
416 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
421 it('shows collection owner', () => {
422 cy.createCollection(adminUser.token, {
423 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
424 owner_uuid: activeUser.user.uuid,
425 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
427 .as('testCollection').then((testCollection) => {
428 cy.loginAs(activeUser);
429 cy.goToPath(`/collections/${testCollection.uuid}`);
431 cy.get('[data-cy=collection-info-panel]').contains(`Collection User`);
435 it('tries to rename a file with illegal names', function () {
436 // Creates the collection using the admin token so we can set up
437 // a bogus manifest text without block signatures.
438 cy.createCollection(adminUser.token, {
439 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
440 owner_uuid: activeUser.user.uuid,
441 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
443 .as('testCollection').then(function () {
444 cy.loginAs(activeUser);
445 cy.goToPath(`/collections/${this.testCollection.uuid}`);
447 const illegalNamesFromUI = [
448 ['.', "Name cannot be '.' or '..'"],
449 ['..', "Name cannot be '.' or '..'"],
450 ['', 'This field is required'],
451 [' ', 'Leading/trailing whitespaces not allowed'],
452 [' foo', 'Leading/trailing whitespaces not allowed'],
453 ['foo ', 'Leading/trailing whitespaces not allowed'],
454 ['//foo', 'Empty dir name not allowed']
456 illegalNamesFromUI.forEach(([name, errMsg]) => {
457 cy.get('[data-cy=collection-files-panel]')
458 .contains('bar').rightclick();
459 cy.get('[data-cy=context-menu]')
462 cy.get('[data-cy=form-dialog]')
463 .should('contain', 'Rename')
465 cy.get('input').type(`{selectall}{backspace}${name}`);
467 cy.get('[data-cy=form-dialog]')
468 .should('contain', 'Rename')
470 cy.contains(`${errMsg}`);
472 cy.get('[data-cy=form-cancel-btn]').click();
477 it('can correctly display old versions', function () {
478 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
480 let oldVersionUuid = '';
481 // Make sure no other collections with this name exist
482 cy.doRequest('GET', '/arvados/v1/collections', null, {
483 filters: `[["name", "=", "${colName}"]]`,
484 include_old_versions: true
486 .its('body.items').as('collections')
488 expect(this.collections).to.be.empty;
490 // Creates the collection using the admin token so we can set up
491 // a bogus manifest text without block signatures.
492 cy.createCollection(adminUser.token, {
494 owner_uuid: activeUser.user.uuid,
495 preserve_version: true,
496 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
498 .as('originalVersion').then(function () {
499 // Change the file name to create a new version.
500 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
501 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
503 colUuid = this.originalVersion.uuid;
505 // Confirm that there are 2 versions of the collection
506 cy.doRequest('GET', '/arvados/v1/collections', null, {
507 filters: `[["name", "=", "${colName}"]]`,
508 include_old_versions: true
510 .its('body.items').as('collections')
512 expect(this.collections).to.have.lengthOf(2);
513 this.collections.map(function (aCollection) {
514 expect(aCollection.current_version_uuid).to.equal(colUuid);
515 if (aCollection.uuid !== aCollection.current_version_uuid) {
516 oldVersionUuid = aCollection.uuid;
519 // Check the old version displays as what it is.
520 cy.loginAs(activeUser)
521 cy.goToPath(`/collections/${oldVersionUuid}`);
523 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
524 cy.get('[data-cy=read-only-icon]').should('exist');
525 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
526 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
530 it('views & edits storage classes data', function () {
531 const colName= `Test Collection ${Math.floor(Math.random() * 999999)}`;
532 cy.createCollection(adminUser.token, {
534 owner_uuid: activeUser.user.uuid,
535 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
536 }).as('collection').then(function () {
537 expect(this.collection.storage_classes_desired).to.deep.equal(['default'])
539 cy.loginAs(activeUser)
540 cy.goToPath(`/collections/${this.collection.uuid}`);
542 // Initial check: it should show the 'default' storage class
543 cy.get('[data-cy=collection-info-panel]')
544 .should('contain', 'Storage classes')
545 .and('contain', 'default')
546 .and('not.contain', 'foo')
547 .and('not.contain', 'bar');
548 // Edit collection: add storage class 'foo'
549 cy.get('[data-cy=collection-panel-options-btn]').click();
550 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
551 cy.get('[data-cy=form-dialog]')
552 .should('contain', 'Edit Collection')
553 .and('contain', 'Storage classes')
554 .and('contain', 'default')
555 .and('contain', 'foo')
556 .and('contain', 'bar')
558 cy.get('[data-cy=checkbox-foo]').click();
560 cy.get('[data-cy=form-submit-btn]').click();
561 cy.get('[data-cy=collection-info-panel]')
562 .should('contain', 'default')
563 .and('contain', 'foo')
564 .and('not.contain', 'bar');
565 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
566 .its('body').as('updatedCollection')
568 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['default', 'foo']);
570 // Edit collection: remove storage class 'default'
571 cy.get('[data-cy=collection-panel-options-btn]').click();
572 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
573 cy.get('[data-cy=form-dialog]')
574 .should('contain', 'Edit Collection')
575 .and('contain', 'Storage classes')
576 .and('contain', 'default')
577 .and('contain', 'foo')
578 .and('contain', 'bar')
580 cy.get('[data-cy=checkbox-default]').click();
582 cy.get('[data-cy=form-submit-btn]').click();
583 cy.get('[data-cy=collection-info-panel]')
584 .should('not.contain', 'default')
585 .and('contain', 'foo')
586 .and('not.contain', 'bar');
587 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
588 .its('body').as('updatedCollection')
590 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['foo']);
595 it('moves a collection to a different project', function () {
596 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
597 const projName = `Test Project ${Math.floor(Math.random() * 999999)}`;
598 const fileName = `Test_File_${Math.floor(Math.random() * 999999)}`;
600 cy.createCollection(adminUser.token, {
602 owner_uuid: activeUser.user.uuid,
603 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
604 }).as('testCollection');
605 cy.createGroup(adminUser.token, {
607 group_class: 'project',
608 owner_uuid: activeUser.user.uuid,
609 }).as('testProject');
611 cy.getAll('@testCollection', '@testProject')
612 .then(function ([testCollection, testProject]) {
613 cy.loginAs(activeUser);
614 cy.goToPath(`/collections/${testCollection.uuid}`);
615 cy.get('[data-cy=collection-files-panel]').should('contain', fileName);
616 cy.get('[data-cy=collection-info-panel]')
617 .should('not.contain', projName)
618 .and('not.contain', testProject.uuid);
619 cy.get('[data-cy=collection-panel-options-btn]').click();
620 cy.get('[data-cy=context-menu]').contains('Move to').click();
621 cy.get('[data-cy=form-dialog]')
622 .should('contain', 'Move to')
624 cy.get('[data-cy=projects-tree-home-tree-picker]')
627 cy.get('[data-cy=projects-tree-home-tree-picker]')
631 cy.get('[data-cy=form-submit-btn]').click();
632 cy.get('[data-cy=snackbar]')
633 .contains('Collection has been moved')
634 cy.get('[data-cy=collection-info-panel]')
635 .contains(projName).and('contain', testProject.uuid);
636 // Double check that the collection is in the project
637 cy.goToPath(`/projects/${testProject.uuid}`);
638 cy.get('[data-cy=project-panel]').should('contain', collName);
642 it('automatically updates the collection UI contents without using the Refresh button', function () {
643 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
644 const fileName = 'foobar'
646 cy.createCollection(adminUser.token, {
648 owner_uuid: activeUser.user.uuid,
649 }).as('testCollection');
651 cy.getAll('@testCollection').then(function ([testCollection]) {
652 cy.loginAs(activeUser);
653 cy.goToPath(`/collections/${testCollection.uuid}`);
654 cy.get('[data-cy=collection-files-panel]').should('contain', 'This collection is empty');
655 cy.get('[data-cy=collection-files-panel]').should('not.contain', fileName);
656 cy.get('[data-cy=collection-info-panel]').should('contain', collName);
658 cy.updateCollection(adminUser.token, testCollection.uuid, {
659 name: `${collName + ' updated'}`,
660 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
661 }).as('updatedCollection');
662 cy.getAll('@updatedCollection').then(function ([updatedCollection]) {
663 expect(updatedCollection.name).to.equal(`${collName + ' updated'}`);
664 cy.get('[data-cy=collection-info-panel]').should('contain', updatedCollection.name);
665 cy.get('[data-cy=collection-files-panel]').should('contain', fileName);
670 it('makes a copy of an existing collection', function() {
671 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
672 const copyName = `Copy of: ${collName}`;
674 cy.createCollection(adminUser.token, {
676 owner_uuid: activeUser.user.uuid,
677 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
678 }).as('collection').then(function () {
679 cy.loginAs(activeUser)
680 cy.goToPath(`/collections/${this.collection.uuid}`);
681 cy.get('[data-cy=collection-files-panel]')
682 .should('contain', 'some-file');
683 cy.get('[data-cy=collection-panel-options-btn]').click();
684 cy.get('[data-cy=context-menu]').contains('Make a copy').click();
685 cy.get('[data-cy=form-dialog]')
686 .should('contain', 'Make a copy')
688 cy.get('[data-cy=projects-tree-home-tree-picker]')
689 .contains('Projects')
691 cy.get('[data-cy=form-submit-btn]').click();
693 cy.get('[data-cy=snackbar]')
694 .contains('Collection has been copied.')
695 cy.get('[data-cy=snackbar-goto-action]').click();
696 cy.get('[data-cy=project-panel]')
697 .contains(copyName).click();
698 cy.get('[data-cy=collection-files-panel]')
699 .should('contain', 'some-file');
703 it('uses the collection version browser to view a previous version', function () {
704 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
706 // Creates the collection using the admin token so we can set up
707 // a bogus manifest text without block signatures.
708 cy.createCollection(adminUser.token, {
710 owner_uuid: activeUser.user.uuid,
711 preserve_version: true,
712 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
714 .as('collection').then(function () {
715 // Visit collection, check basic information
716 cy.loginAs(activeUser)
717 cy.goToPath(`/collections/${this.collection.uuid}`);
719 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
720 cy.get('[data-cy=read-only-icon]').should('not.exist');
721 cy.get('[data-cy=collection-version-number]').should('contain', '1');
722 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
723 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
725 // Modify collection, expect version number change
726 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
727 cy.get('[data-cy=context-menu]').contains('Remove').click();
728 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
729 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
730 cy.get('[data-cy=collection-version-number]').should('contain', '2');
731 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
733 // Click on version number, check version browser. Click on past version.
734 cy.get('[data-cy=collection-version-browser]').should('not.exist');
735 cy.get('[data-cy=collection-version-number]').contains('2').click();
736 cy.get('[data-cy=collection-version-browser]')
737 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
739 // Version 1: 6 bytes in size
740 cy.get('[data-cy=collection-version-browser-select-1]')
741 .should('contain', '1')
742 .and('contain', '6 B')
743 .and('contain', adminUser.user.uuid);
744 // Version 2: 3 bytes in size (one file removed)
745 cy.get('[data-cy=collection-version-browser-select-2]')
746 .should('contain', '2')
747 .and('contain', '3 B')
748 .and('contain', activeUser.user.full_name);
749 cy.get('[data-cy=collection-version-browser-select-3]')
750 .should('not.exist');
751 cy.get('[data-cy=collection-version-browser-select-1]')
754 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
755 cy.get('[data-cy=read-only-icon]').should('exist');
756 cy.get('[data-cy=collection-version-number]').should('contain', '1');
757 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
758 cy.get('[data-cy=collection-files-panel]')
759 .should('contain', 'foo').and('contain', 'bar');
761 // Check that only old collection action are available on context menu
762 cy.get('[data-cy=collection-panel-options-btn]').click();
763 cy.get('[data-cy=context-menu]')
764 .should('contain', 'Restore version')
765 .and('not.contain', 'Add to favorites');
766 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
768 // Click on "head version" link, confirm that it's the latest version.
769 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
770 cy.get('[data-cy=collection-info-panel]')
771 .should('not.contain', 'This is an old version');
772 cy.get('[data-cy=read-only-icon]').should('not.exist');
773 cy.get('[data-cy=collection-version-number]').should('contain', '2');
774 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
775 cy.get('[data-cy=collection-files-panel]').
776 should('not.contain', 'foo').and('contain', 'bar');
778 // Check that old collection action isn't available on context menu
779 cy.get('[data-cy=collection-panel-options-btn]').click()
780 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
781 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
783 // Make another change, confirm new version.
784 cy.get('[data-cy=collection-panel-options-btn]').click();
785 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
786 cy.get('[data-cy=form-dialog]')
787 .should('contain', 'Edit Collection')
790 cy.get('input').first().type(' renamed');
792 cy.get('[data-cy=form-submit-btn]').click();
793 cy.get('[data-cy=collection-info-panel]')
794 .should('not.contain', 'This is an old version');
795 cy.get('[data-cy=read-only-icon]').should('not.exist');
796 cy.get('[data-cy=collection-version-number]').should('contain', '3');
797 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
798 cy.get('[data-cy=collection-files-panel]')
799 .should('not.contain', 'foo').and('contain', 'bar');
800 cy.get('[data-cy=collection-version-browser-select-3]')
801 .should('contain', '3').and('contain', '3 B');
803 // Check context menus on version browser
804 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
805 cy.get('[data-cy=context-menu]')
806 .should('contain', 'Add to favorites')
807 .and('contain', 'Make a copy')
808 .and('contain', 'Edit collection');
809 cy.get('body').click();
810 // (and now an old version...)
811 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
812 cy.get('[data-cy=context-menu]')
813 .should('not.contain', 'Add to favorites')
814 .and('contain', 'Make a copy')
815 .and('not.contain', 'Edit collection');
816 cy.get('body').click();
818 // Restore first version
819 cy.get('[data-cy=collection-version-browser]').within(() => {
820 cy.get('[data-cy=collection-version-browser-select-1]').click();
822 cy.get('[data-cy=collection-panel-options-btn]').click()
823 cy.get('[data-cy=context-menu]').contains('Restore version').click();
824 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
825 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
826 cy.get('[data-cy=collection-info-panel]')
827 .should('not.contain', 'This is an old version');
828 cy.get('[data-cy=collection-version-number]').should('contain', '4');
829 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
830 cy.get('[data-cy=collection-files-panel]')
831 .should('contain', 'foo').and('contain', 'bar');
835 it('creates collection from selected files of another collection', () => {
836 cy.createCollection(adminUser.token, {
837 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
838 owner_uuid: activeUser.user.uuid,
839 preserve_version: true,
840 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
842 .as('collection').then(function () {
843 // Visit collection, check basic information
844 cy.loginAs(activeUser)
845 cy.goToPath(`/collections/${this.collection.uuid}`);
847 cy.get('[data-cy=collection-files-panel]').within(() => {
848 cy.get('input[type=checkbox]').first().click();
851 cy.get('[data-cy=collection-files-panel-options-btn]').click();
852 cy.get('[data-cy=context-menu]').contains('Create a new collection with selected').click();
854 cy.get('[data-cy=form-dialog]').contains('Projects').click();
856 cy.get('[data-cy=form-submit-btn]').click();
858 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
860 cy.get('main').contains(`Files extracted from: ${this.collection.name}`).should('exist');
864 it('creates new collection with properties on home project', function () {
865 cy.loginAs(activeUser);
866 cy.goToPath(`/projects/${activeUser.user.uuid}`);
867 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
868 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
869 // Create new collection
870 cy.get('[data-cy=side-panel-button]').click();
871 cy.get('[data-cy=side-panel-new-collection]').click();
872 // Name between brackets tests bugfix #17582
873 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
875 // Select a storage class.
876 cy.get('[data-cy=form-dialog]')
877 .should('contain', 'New collection')
878 .and('contain', 'Storage classes')
879 .and('contain', 'default')
880 .and('contain', 'foo')
881 .and('contain', 'bar')
883 cy.get('[data-cy=parent-field]').within(() => {
884 cy.get('input').should('have.value', 'Home project');
886 cy.get('[data-cy=name-field]').within(() => {
887 cy.get('input').type(collName);
889 cy.get('[data-cy=checkbox-foo]').click();
893 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
894 cy.get('[data-cy=form-dialog]').should('not.contain', 'Color: Magenta');
895 cy.get('[data-cy=resource-properties-form]').within(() => {
896 cy.get('[data-cy=property-field-key]').within(() => {
897 cy.get('input').type('Color');
899 cy.get('[data-cy=property-field-value]').within(() => {
900 cy.get('input').type('Magenta');
904 // Confirm proper vocabulary labels are displayed on the UI.
905 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
907 cy.get('[data-cy=form-submit-btn]').click();
908 // Confirm that the user was taken to the newly created collection
909 cy.get('[data-cy=form-dialog]').should('not.exist');
910 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
911 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
912 cy.get('[data-cy=collection-info-panel]')
913 .should('contain', 'default')
914 .and('contain', 'foo')
915 .and('contain', 'Color: Magenta')
916 .and('not.contain', 'bar');
917 // Confirm that the collection's properties has the real values.
918 cy.doRequest('GET', '/arvados/v1/collections', null, {
919 filters: `[["name", "=", "${collName}"]]`,
921 .its('body.items').as('collections')
923 expect(this.collections).to.have.lengthOf(1);
924 expect(this.collections[0].properties).to.have.property(
925 'IDTAGCOLORS', 'IDVALCOLORS3');
929 it('shows responsible person for collection if available', () => {
930 cy.createCollection(adminUser.token, {
931 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
932 owner_uuid: activeUser.user.uuid,
933 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
934 }).as('testCollection1');
936 cy.createCollection(adminUser.token, {
937 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
938 owner_uuid: adminUser.user.uuid,
939 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
940 }).as('testCollection2').then(function (testCollection2) {
941 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
944 cy.getAll('@testCollection1', '@testCollection2')
945 .then(function ([testCollection1, testCollection2]) {
946 cy.loginAs(activeUser);
948 cy.goToPath(`/collections/${testCollection1.uuid}`);
949 cy.get('[data-cy=responsible-person-wrapper]')
950 .contains(activeUser.user.uuid);
952 cy.goToPath(`/collections/${testCollection2.uuid}`);
953 cy.get('[data-cy=responsible-person-wrapper]')
954 .contains(adminUser.user.uuid);
958 describe('file upload', () => {
960 cy.createCollection(adminUser.token, {
961 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
962 owner_uuid: activeUser.user.uuid,
963 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
964 }).as('testCollection1');
967 it('uploads a file and checks the collection UI to be fresh', () => {
968 cy.getAll('@testCollection1')
969 .then(function([testCollection1]) {
970 cy.loginAs(activeUser);
971 cy.goToPath(`/collections/${testCollection1.uuid}`);
972 cy.get('[data-cy=upload-button]').click();
973 cy.get('[data-cy=collection-files-panel]')
974 .contains('5mb_a.bin').should('not.exist');
975 cy.get('[data-cy=collection-file-count]').should('contain', '2');
976 cy.fixture('files/5mb.bin', 'base64').then(content => {
977 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
978 cy.get('[data-cy=form-submit-btn]').click();
979 cy.get('[data-cy=form-submit-btn]').should('not.exist');
980 cy.get('[data-cy=collection-files-panel]')
981 .contains('5mb_a.bin').should('exist');
982 cy.get('[data-cy=collection-file-count]').should('contain', '3');
984 cy.get('[data-cy=collection-files-panel]').contains('subdir').click();
985 cy.get('[data-cy=upload-button]').click();
986 cy.fixture('files/5mb.bin', 'base64').then(content => {
987 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
988 cy.get('[data-cy=form-submit-btn]').click();
989 cy.get('[data-cy=form-submit-btn]').should('not.exist');
990 cy.get('[data-cy=collection-files-right-panel]')
991 .contains('5mb_b.bin').should('exist');
997 it('allows to cancel running upload', () => {
998 cy.getAll('@testCollection1')
999 .then(function([testCollection1]) {
1000 cy.loginAs(activeUser);
1002 cy.goToPath(`/collections/${testCollection1.uuid}`);
1004 cy.get('[data-cy=upload-button]').click();
1006 cy.fixture('files/5mb.bin', 'base64').then(content => {
1007 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1008 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1010 cy.get('[data-cy=form-submit-btn]').click();
1012 cy.get('button').contains('Cancel').click();
1014 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1019 it('allows to cancel single file from the running upload', () => {
1020 cy.getAll('@testCollection1')
1021 .then(function([testCollection1]) {
1022 cy.loginAs(activeUser);
1024 cy.goToPath(`/collections/${testCollection1.uuid}`);
1026 cy.get('[data-cy=upload-button]').click();
1028 cy.fixture('files/5mb.bin', 'base64').then(content => {
1029 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1030 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1032 cy.get('[data-cy=form-submit-btn]').click();
1034 cy.get('button[aria-label=Remove]').eq(1).click();
1036 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1038 cy.get('[data-cy=collection-files-panel]').contains('5mb_a.bin').should('exist');
1043 it('allows to cancel all files from the running upload', () => {
1044 cy.getAll('@testCollection1')
1045 .then(function([testCollection1]) {
1046 cy.loginAs(activeUser);
1048 cy.goToPath(`/collections/${testCollection1.uuid}`);
1050 // Confirm initial collection state.
1051 cy.get('[data-cy=collection-files-panel]')
1052 .contains('bar').should('exist');
1053 cy.get('[data-cy=collection-files-panel]')
1054 .contains('5mb_a.bin').should('not.exist');
1055 cy.get('[data-cy=collection-files-panel]')
1056 .contains('5mb_b.bin').should('not.exist');
1058 cy.get('[data-cy=upload-button]').click();
1060 cy.fixture('files/5mb.bin', 'base64').then(content => {
1061 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1062 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1064 cy.get('[data-cy=form-submit-btn]').click();
1066 cy.get('button[aria-label=Remove]').should('exist');
1067 cy.get('button[aria-label=Remove]')
1068 .click({ multiple: true, force: true });
1070 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1072 // Confirm final collection state.
1073 cy.get('[data-cy=collection-files-panel]')
1074 .contains('bar').should('exist');
1075 // The following fails, but doesn't seem to happen
1076 // in the real world. Maybe there's a race between
1077 // the PUT request finishing and the 'Remove' button
1078 // dissapearing, because sometimes just one of the 2
1079 // files gets uploaded.
1080 // Maybe this will be needed to simulate a slow network:
1081 // https://docs.cypress.io/api/commands/intercept#Convenience-functions-1
1082 // cy.get('[data-cy=collection-files-panel]')
1083 // .contains('5mb_a.bin').should('not.exist');
1084 // cy.get('[data-cy=collection-files-panel]')
1085 // .contains('5mb_b.bin').should('not.exist');