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('attempts to use a preexisting name creating or updating a collection', function() {
79 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
80 cy.createCollection(adminUser.token, {
82 owner_uuid: activeUser.user.uuid,
83 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
85 cy.loginAs(activeUser);
86 cy.goToPath(`/projects/${activeUser.user.uuid}`);
87 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
88 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
89 // Attempt to create new collection with a duplicate name
90 cy.get('[data-cy=side-panel-button]').click();
91 cy.get('[data-cy=side-panel-new-collection]').click();
92 cy.get('[data-cy=form-dialog]')
93 .should('contain', 'New collection')
95 cy.get('[data-cy=name-field]').within(() => {
96 cy.get('input').type(name);
98 cy.get('[data-cy=form-submit-btn]').click();
100 // Error message should display, allowing editing the name
101 cy.get('[data-cy=form-dialog]').should('exist')
102 .and('contain', 'Collection with the same name already exists')
104 cy.get('[data-cy=name-field]').within(() => {
105 cy.get('input').type(' renamed');
107 cy.get('[data-cy=form-submit-btn]').click();
109 cy.get('[data-cy=form-dialog]').should('not.exist');
110 // Attempt to rename the collection with the duplicate name
111 cy.get('[data-cy=collection-panel-options-btn]').click();
112 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
113 cy.get('[data-cy=form-dialog]')
114 .should('contain', 'Edit Collection')
116 cy.get('[data-cy=name-field]').within(() => {
118 .type('{selectall}{backspace}')
121 cy.get('[data-cy=form-submit-btn]').click();
123 cy.get('[data-cy=form-dialog]').should('exist')
124 .and('contain', 'Collection with the same name already exists');
127 it('uses the property editor (from edit dialog) with vocabulary terms', function () {
128 cy.createCollection(adminUser.token, {
129 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
130 owner_uuid: activeUser.user.uuid,
131 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
133 .as('testCollection').then(function () {
134 cy.loginAs(activeUser);
135 cy.goToPath(`/collections/${this.testCollection.uuid}`);
137 cy.get('[data-cy=collection-info-panel')
138 .should('contain', this.testCollection.name)
139 .and('not.contain', 'Color: Magenta');
141 cy.get('[data-cy=collection-panel-options-btn]').click();
142 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
143 cy.get('[data-cy=form-dialog]').should('contain', 'Properties');
145 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
146 cy.get('[data-cy=resource-properties-form]').within(() => {
147 cy.get('[data-cy=property-field-key]').within(() => {
148 cy.get('input').type('Color');
150 cy.get('[data-cy=property-field-value]').within(() => {
151 cy.get('input').type('Magenta');
155 // Confirm proper vocabulary labels are displayed on the UI.
156 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
157 cy.get('[data-cy=form-dialog]').contains('Save').click();
158 cy.get('[data-cy=form-dialog]').should('not.exist');
159 // Confirm proper vocabulary IDs were saved on the backend.
160 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
161 .its('body').as('collection')
163 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
165 // Confirm the property is displayed on the UI.
166 cy.get('[data-cy=collection-info-panel')
167 .should('contain', this.testCollection.name)
168 .and('contain', 'Color: Magenta');
172 it('uses the editor (from details panel) with vocabulary terms', function () {
173 cy.createCollection(adminUser.token, {
174 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
175 owner_uuid: activeUser.user.uuid,
176 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
178 .as('testCollection').then(function () {
179 cy.loginAs(activeUser);
180 cy.goToPath(`/collections/${this.testCollection.uuid}`);
182 cy.get('[data-cy=collection-info-panel')
183 .should('contain', this.testCollection.name)
184 .and('not.contain', 'Color: Magenta')
185 .and('not.contain', 'Size: S');
186 cy.get('[data-cy=additional-info-icon]').click();
188 cy.get('[data-cy=details-panel]').within(() => {
189 cy.get('[data-cy=details-panel-edit-btn]').click();
191 cy.get('[data-cy=form-dialog').contains('Edit Collection');
193 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
194 cy.get('[data-cy=resource-properties-form]').within(() => {
195 cy.get('[data-cy=property-field-key]').within(() => {
196 cy.get('input').type('Color');
198 cy.get('[data-cy=property-field-value]').within(() => {
199 cy.get('input').type('Magenta');
203 // Confirm proper vocabulary labels are displayed on the UI.
204 cy.get('[data-cy=form-dialog]')
205 .should('contain', 'Color: Magenta');
207 // Case-insensitive on-blur auto-selection test
208 // Key: Size (IDTAGSIZES) - Value: Small (IDVALSIZES2)
209 cy.get('[data-cy=resource-properties-form]').within(() => {
210 cy.get('[data-cy=property-field-key]').within(() => {
211 cy.get('input').type('sIzE');
213 cy.get('[data-cy=property-field-value]').within(() => {
214 cy.get('input').type('sMaLL');
216 // Cannot "type()" TAB on Cypress so let's click another field
217 // to trigger the onBlur event.
218 cy.get('[data-cy=property-field-key]').click();
221 // Confirm proper vocabulary labels are displayed on the UI.
222 cy.get('[data-cy=form-dialog]')
223 .should('contain', 'Size: S');
225 cy.get('[data-cy=form-dialog]').contains('Save').click();
226 cy.get('[data-cy=form-dialog]').should('not.exist');
228 // Confirm proper vocabulary IDs were saved on the backend.
229 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
230 .its('body').as('collection')
232 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
233 expect(this.collection.properties.IDTAGSIZES).to.equal('IDVALSIZES2');
236 // Confirm properties display on the UI.
237 cy.get('[data-cy=collection-info-panel')
238 .should('contain', this.testCollection.name)
239 .and('contain', 'Color: Magenta')
240 .and('contain', 'Size: S');
244 it('shows collection by URL', function () {
245 cy.loginAs(activeUser);
246 [true, false].map(function (isWritable) {
247 // Using different file names to avoid test flakyness: the second iteration
248 // on this loop may pass an assertion from the first iteration by looking
249 // for the same file name.
250 const fileName = isWritable ? 'bar' : 'foo';
251 const subDirName = 'subdir';
252 cy.createGroup(adminUser.token, {
253 name: 'Shared project',
254 group_class: 'project',
255 }).as('sharedGroup').then(function () {
256 // Creates the collection using the admin token so we can set up
257 // a bogus manifest text without block signatures.
258 cy.doRequest('GET', '/arvados/v1/config', null, null)
259 .its('body').should((clusterConfig) => {
260 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", true);
261 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
262 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
263 const inlineUrl = clusterConfig.Services.WebDAV.ExternalURL !== ""
264 ? clusterConfig.Services.WebDAV.ExternalURL
265 : clusterConfig.Services.WebDAVDownload.ExternalURL;
266 expect(inlineUrl).to.not.contain("*");
268 .createCollection(adminUser.token, {
269 name: 'Test collection',
270 owner_uuid: this.sharedGroup.uuid,
271 properties: { someKey: 'someValue' },
272 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
274 .as('testCollection').then(function () {
275 // Share the group with active user.
276 cy.createLink(adminUser.token, {
277 name: isWritable ? 'can_write' : 'can_read',
278 link_class: 'permission',
279 head_uuid: this.sharedGroup.uuid,
280 tail_uuid: activeUser.user.uuid
282 cy.goToPath(`/collections/${this.testCollection.uuid}`);
284 // Check that name & uuid are correct.
285 cy.get('[data-cy=collection-info-panel]')
286 .should('contain', this.testCollection.name)
287 .and('contain', this.testCollection.uuid)
288 .and('not.contain', 'This is an old version');
289 // Check for the read-only icon
290 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
291 // Check that both read and write operations are available on
292 // the 'More options' menu.
293 cy.get('[data-cy=collection-panel-options-btn]')
295 cy.get('[data-cy=context-menu]')
296 .should('contain', 'Add to favorites')
297 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
298 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
299 cy.get('[data-cy=collection-info-panel]')
300 .should('contain', 'someKey: someValue')
301 .and('not.contain', 'anotherKey: anotherValue');
302 // Check that the file listing show both read & write operations
303 cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
304 cy.get('[data-cy=collection-files-right-panel]', { timeout: 5000 })
305 .should('contain', fileName);
307 cy.get('[data-cy=upload-button]')
308 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
311 // Test context menus
312 cy.get('[data-cy=collection-files-panel]')
313 .contains(fileName).rightclick();
314 cy.get('[data-cy=context-menu]')
315 .should('contain', 'Download')
316 .and('contain', 'Open in new tab')
317 .and('contain', 'Copy to clipboard')
318 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
319 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
320 cy.get('body').click(); // Collapse the menu
321 cy.get('[data-cy=collection-files-panel]')
322 .contains(subDirName).rightclick();
323 cy.get('[data-cy=context-menu]')
324 .should('not.contain', 'Download')
325 .and('contain', 'Open in new tab')
326 .and('contain', 'Copy to clipboard')
327 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
328 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
329 cy.get('body').click(); // Collapse the menu
330 // File/dir item 'more options' button
331 cy.get('[data-cy=file-item-options-btn')
334 cy.get('[data-cy=context-menu]')
335 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove');
336 cy.get('body').click(); // Collapse the menu
337 // Hamburger 'more options' menu button
338 cy.get('[data-cy=collection-files-panel-options-btn]')
340 cy.get('[data-cy=context-menu]')
341 .should('contain', 'Select all')
343 cy.get('[data-cy=collection-files-panel-options-btn]')
345 cy.get('[data-cy=context-menu]')
346 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
347 cy.get('body').click(); // Collapse the menu
353 it('renames a file using valid names', function () {
354 function eachPair(lst, func){
355 for(var i=0; i < lst.length - 1; i++){
356 func(lst[i], lst[i + 1])
359 // Creates the collection using the admin token so we can set up
360 // a bogus manifest text without block signatures.
361 cy.createCollection(adminUser.token, {
362 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
363 owner_uuid: activeUser.user.uuid,
364 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
366 .as('testCollection').then(function () {
367 cy.loginAs(activeUser);
368 cy.goToPath(`/collections/${this.testCollection.uuid}`);
371 'bar', // initial name already set
378 'some name with whitespaces',
380 'is this name legal? I hope it is',
388 "G%C3%BCnter's%20file.pdf",
390 'bar' // make sure we can go back to the original name as a last step
392 cy.intercept({method: 'PUT', url: '**/arvados/v1/collections/*'}).as('renameRequest');
393 eachPair(names, (from, to) => {
394 cy.waitForDom().get('[data-cy=collection-files-panel]')
395 .contains(`${from}`).rightclick();
396 cy.get('[data-cy=context-menu]')
399 cy.get('[data-cy=form-dialog]')
400 .should('contain', 'Rename')
403 .type('{selectall}{backspace}')
404 .type(to, { parseSpecialCharSequences: false });
406 cy.get('[data-cy=form-submit-btn]').click();
407 cy.wait('@renameRequest');
408 cy.get('[data-cy=collection-files-panel]')
409 .should('not.contain', `${from}`)
410 .and('contain', `${to}`);
415 it('renames a file to a different directory', 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 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
428 cy.waitForDom().get('[data-cy=collection-files-panel]')
429 .contains('bar').rightclick();
430 cy.get('[data-cy=context-menu]')
433 cy.get('[data-cy=form-dialog]')
434 .should('contain', 'Rename')
436 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
438 cy.get('[data-cy=form-submit-btn]').click();
439 cy.get('[data-cy=collection-files-panel]')
440 .should('not.contain', 'bar')
441 .and('contain', subdir);
442 cy.get('[data-cy=collection-files-panel]').contains(subdir).click();
444 // Rename 'subdir/foo' to 'bar'
446 cy.get('[data-cy=collection-files-panel]')
447 .contains('foo').rightclick();
448 cy.get('[data-cy=context-menu]')
451 cy.get('[data-cy=form-dialog]')
452 .should('contain', 'Rename')
455 .should('have.value', `${subdir}/foo`)
456 .type(`{selectall}{backspace}bar`);
458 cy.get('[data-cy=form-submit-btn]').click();
460 // need to wait for dialog to dismiss
461 cy.get('[data-cy=form-dialog]').should('not.exist');
463 cy.waitForDom().get('[data-cy=collection-files-panel]')
468 cy.get('[data-cy=collection-files-panel]')
469 .should('contain', subdir) // empty dir kept
470 .and('contain', 'bar');
472 cy.get('[data-cy=collection-files-panel]')
473 .contains(subdir).rightclick();
474 cy.get('[data-cy=context-menu]')
477 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
478 cy.get('[data-cy=form-dialog]').should('not.exist');
483 it('shows collection owner', () => {
484 cy.createCollection(adminUser.token, {
485 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
486 owner_uuid: activeUser.user.uuid,
487 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
489 .as('testCollection').then((testCollection) => {
490 cy.loginAs(activeUser);
491 cy.goToPath(`/collections/${testCollection.uuid}`);
493 cy.get('[data-cy=collection-info-panel]').contains(`Collection User`);
497 it('tries to rename a file with illegal names', function () {
498 // Creates the collection using the admin token so we can set up
499 // a bogus manifest text without block signatures.
500 cy.createCollection(adminUser.token, {
501 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
502 owner_uuid: activeUser.user.uuid,
503 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
505 .as('testCollection').then(function () {
506 cy.loginAs(activeUser);
507 cy.goToPath(`/collections/${this.testCollection.uuid}`);
509 const illegalNamesFromUI = [
510 ['.', "Name cannot be '.' or '..'"],
511 ['..', "Name cannot be '.' or '..'"],
512 ['', 'This field is required'],
513 [' ', 'Leading/trailing whitespaces not allowed'],
514 [' foo', 'Leading/trailing whitespaces not allowed'],
515 ['foo ', 'Leading/trailing whitespaces not allowed'],
516 ['//foo', 'Empty dir name not allowed']
518 illegalNamesFromUI.forEach(([name, errMsg]) => {
519 cy.get('[data-cy=collection-files-panel]')
520 .contains('bar').rightclick();
521 cy.get('[data-cy=context-menu]')
524 cy.get('[data-cy=form-dialog]')
525 .should('contain', 'Rename')
527 cy.get('input').type(`{selectall}{backspace}${name}`);
529 cy.get('[data-cy=form-dialog]')
530 .should('contain', 'Rename')
532 cy.contains(`${errMsg}`);
534 cy.get('[data-cy=form-cancel-btn]').click();
539 it('can correctly display old versions', function () {
540 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
542 let oldVersionUuid = '';
543 // Make sure no other collections with this name exist
544 cy.doRequest('GET', '/arvados/v1/collections', null, {
545 filters: `[["name", "=", "${colName}"]]`,
546 include_old_versions: true
548 .its('body.items').as('collections')
550 expect(this.collections).to.be.empty;
552 // Creates the collection using the admin token so we can set up
553 // a bogus manifest text without block signatures.
554 cy.createCollection(adminUser.token, {
556 owner_uuid: activeUser.user.uuid,
557 preserve_version: true,
558 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
560 .as('originalVersion').then(function () {
561 // Change the file name to create a new version.
562 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
563 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
565 colUuid = this.originalVersion.uuid;
567 // Confirm that there are 2 versions of the collection
568 cy.doRequest('GET', '/arvados/v1/collections', null, {
569 filters: `[["name", "=", "${colName}"]]`,
570 include_old_versions: true
572 .its('body.items').as('collections')
574 expect(this.collections).to.have.lengthOf(2);
575 this.collections.map(function (aCollection) {
576 expect(aCollection.current_version_uuid).to.equal(colUuid);
577 if (aCollection.uuid !== aCollection.current_version_uuid) {
578 oldVersionUuid = aCollection.uuid;
581 // Check the old version displays as what it is.
582 cy.loginAs(activeUser)
583 cy.goToPath(`/collections/${oldVersionUuid}`);
585 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
586 cy.get('[data-cy=read-only-icon]').should('exist');
587 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
588 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
592 it('views & edits storage classes data', function () {
593 const colName= `Test Collection ${Math.floor(Math.random() * 999999)}`;
594 cy.createCollection(adminUser.token, {
596 owner_uuid: activeUser.user.uuid,
597 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
598 }).as('collection').then(function () {
599 expect(this.collection.storage_classes_desired).to.deep.equal(['default'])
601 cy.loginAs(activeUser)
602 cy.goToPath(`/collections/${this.collection.uuid}`);
604 // Initial check: it should show the 'default' storage class
605 cy.get('[data-cy=collection-info-panel]')
606 .should('contain', 'Storage classes')
607 .and('contain', 'default')
608 .and('not.contain', 'foo')
609 .and('not.contain', 'bar');
610 // Edit collection: add storage class 'foo'
611 cy.get('[data-cy=collection-panel-options-btn]').click();
612 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
613 cy.get('[data-cy=form-dialog]')
614 .should('contain', 'Edit Collection')
615 .and('contain', 'Storage classes')
616 .and('contain', 'default')
617 .and('contain', 'foo')
618 .and('contain', 'bar')
620 cy.get('[data-cy=checkbox-foo]').click();
622 cy.get('[data-cy=form-submit-btn]').click();
623 cy.get('[data-cy=collection-info-panel]')
624 .should('contain', 'default')
625 .and('contain', 'foo')
626 .and('not.contain', 'bar');
627 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
628 .its('body').as('updatedCollection')
630 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['default', 'foo']);
632 // Edit collection: remove storage class 'default'
633 cy.get('[data-cy=collection-panel-options-btn]').click();
634 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
635 cy.get('[data-cy=form-dialog]')
636 .should('contain', 'Edit Collection')
637 .and('contain', 'Storage classes')
638 .and('contain', 'default')
639 .and('contain', 'foo')
640 .and('contain', 'bar')
642 cy.get('[data-cy=checkbox-default]').click();
644 cy.get('[data-cy=form-submit-btn]').click();
645 cy.get('[data-cy=collection-info-panel]')
646 .should('not.contain', 'default')
647 .and('contain', 'foo')
648 .and('not.contain', 'bar');
649 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
650 .its('body').as('updatedCollection')
652 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['foo']);
657 it('moves a collection to a different project', function () {
658 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
659 const projName = `Test Project ${Math.floor(Math.random() * 999999)}`;
660 const fileName = `Test_File_${Math.floor(Math.random() * 999999)}`;
662 cy.createCollection(adminUser.token, {
664 owner_uuid: activeUser.user.uuid,
665 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
666 }).as('testCollection');
667 cy.createGroup(adminUser.token, {
669 group_class: 'project',
670 owner_uuid: activeUser.user.uuid,
671 }).as('testProject');
673 cy.getAll('@testCollection', '@testProject')
674 .then(function ([testCollection, testProject]) {
675 cy.loginAs(activeUser);
676 cy.goToPath(`/collections/${testCollection.uuid}`);
677 cy.get('[data-cy=collection-files-panel]').should('contain', fileName);
678 cy.get('[data-cy=collection-info-panel]')
679 .should('not.contain', projName)
680 .and('not.contain', testProject.uuid);
681 cy.get('[data-cy=collection-panel-options-btn]').click();
682 cy.get('[data-cy=context-menu]').contains('Move to').click();
683 cy.get('[data-cy=form-dialog]')
684 .should('contain', 'Move to')
686 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
687 cy.get('[data-cy=projects-tree-home-tree-picker]')
689 .then(el => el.click());
690 cy.get('[data-cy=projects-tree-home-tree-picker]')
694 cy.get('[data-cy=form-submit-btn]').click();
695 cy.get('[data-cy=snackbar]')
696 .contains('Collection has been moved')
697 cy.get('[data-cy=collection-info-panel]')
698 .contains(projName).and('contain', testProject.uuid);
699 // Double check that the collection is in the project
700 cy.goToPath(`/projects/${testProject.uuid}`);
701 cy.waitForDom().get('[data-cy=project-panel]').should('contain', collName);
705 it('automatically updates the collection UI contents without using the Refresh button', function () {
706 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
708 cy.createCollection(adminUser.token, {
710 owner_uuid: activeUser.user.uuid,
711 }).as('testCollection');
713 cy.getAll('@testCollection').then(function ([testCollection]) {
714 cy.loginAs(activeUser);
723 cy.goToPath(`/collections/${testCollection.uuid}`);
724 cy.get('[data-cy=collection-files-panel]').should('contain', 'This collection is empty');
725 cy.get('[data-cy=collection-files-panel]').should('not.contain', files[0]);
726 cy.get('[data-cy=collection-info-panel]').should('contain', collName);
728 files.map((fileName, i, files) => {
729 cy.updateCollection(adminUser.token, testCollection.uuid, {
730 name: `${collName + ' updated'}`,
731 manifest_text: fileName ? `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n` : "",
732 }).as('updatedCollection');
733 cy.getAll('@updatedCollection').then(function ([updatedCollection]) {
734 expect(updatedCollection.name).to.equal(`${collName + ' updated'}`);
735 cy.get('[data-cy=collection-info-panel]').should('contain', updatedCollection.name);
737 ? cy.get('[data-cy=collection-files-panel]').should('contain', fileName)
738 : cy.get('[data-cy=collection-files-panel]').should('not.contain', files[i-1]);;
745 it('makes a copy of an existing collection', function() {
746 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
747 const copyName = `Copy of: ${collName}`;
749 cy.createCollection(adminUser.token, {
751 owner_uuid: activeUser.user.uuid,
752 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
753 }).as('collection').then(function () {
754 cy.loginAs(activeUser)
755 cy.goToPath(`/collections/${this.collection.uuid}`);
756 cy.get('[data-cy=collection-files-panel]')
757 .should('contain', 'some-file');
758 cy.get('[data-cy=collection-panel-options-btn]').click();
759 cy.get('[data-cy=context-menu]').contains('Make a copy').click();
760 cy.get('[data-cy=form-dialog]')
761 .should('contain', 'Make a copy')
763 cy.get('[data-cy=projects-tree-home-tree-picker]')
764 .contains('Projects')
766 cy.get('[data-cy=form-submit-btn]').click();
768 cy.get('[data-cy=snackbar]')
769 .contains('Collection has been copied.')
770 cy.get('[data-cy=snackbar-goto-action]').click();
771 cy.get('[data-cy=project-panel]')
772 .contains(copyName).click();
773 cy.get('[data-cy=collection-files-panel]')
774 .should('contain', 'some-file');
778 it('uses the collection version browser to view a previous version', function () {
779 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
781 // Creates the collection using the admin token so we can set up
782 // a bogus manifest text without block signatures.
783 cy.createCollection(adminUser.token, {
785 owner_uuid: activeUser.user.uuid,
786 preserve_version: true,
787 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
789 .as('collection').then(function () {
790 // Visit collection, check basic information
791 cy.loginAs(activeUser)
792 cy.goToPath(`/collections/${this.collection.uuid}`);
794 cy.get('[data-cy=collection-info-panel]').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', '1');
797 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
798 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
800 // Modify collection, expect version number change
801 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
802 cy.get('[data-cy=context-menu]').contains('Remove').click();
803 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
804 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
805 cy.get('[data-cy=collection-version-number]').should('contain', '2');
806 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
808 // Click on version number, check version browser. Click on past version.
809 cy.get('[data-cy=collection-version-browser]').should('not.exist');
810 cy.get('[data-cy=collection-version-number]').contains('2').click();
811 cy.get('[data-cy=collection-version-browser]')
812 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
814 // Version 1: 6 bytes in size
815 cy.get('[data-cy=collection-version-browser-select-1]')
816 .should('contain', '1')
817 .and('contain', '6 B')
818 .and('contain', adminUser.user.full_name);
819 // Version 2: 3 bytes in size (one file removed)
820 cy.get('[data-cy=collection-version-browser-select-2]')
821 .should('contain', '2')
822 .and('contain', '3 B')
823 .and('contain', activeUser.user.full_name);
824 cy.get('[data-cy=collection-version-browser-select-3]')
825 .should('not.exist');
826 cy.get('[data-cy=collection-version-browser-select-1]')
829 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
830 cy.get('[data-cy=read-only-icon]').should('exist');
831 cy.get('[data-cy=collection-version-number]').should('contain', '1');
832 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
833 cy.get('[data-cy=collection-files-panel]')
834 .should('contain', 'foo').and('contain', 'bar');
836 // Check that only old collection action are available on context menu
837 cy.get('[data-cy=collection-panel-options-btn]').click();
838 cy.get('[data-cy=context-menu]')
839 .should('contain', 'Restore version')
840 .and('not.contain', 'Add to favorites');
841 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
843 // Click on "head version" link, confirm that it's the latest version.
844 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
845 cy.get('[data-cy=collection-info-panel]')
846 .should('not.contain', 'This is an old version');
847 cy.get('[data-cy=read-only-icon]').should('not.exist');
848 cy.get('[data-cy=collection-version-number]').should('contain', '2');
849 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
850 cy.get('[data-cy=collection-files-panel]').
851 should('not.contain', 'foo').and('contain', 'bar');
853 // Check that old collection action isn't available on context menu
854 cy.get('[data-cy=collection-panel-options-btn]').click()
855 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
856 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
858 // Make another change, confirm new version.
859 cy.get('[data-cy=collection-panel-options-btn]').click();
860 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
861 cy.get('[data-cy=form-dialog]')
862 .should('contain', 'Edit Collection')
865 cy.get('input').first().type(' renamed');
867 cy.get('[data-cy=form-submit-btn]').click();
868 cy.get('[data-cy=collection-info-panel]')
869 .should('not.contain', 'This is an old version');
870 cy.get('[data-cy=read-only-icon]').should('not.exist');
871 cy.get('[data-cy=collection-version-number]').should('contain', '3');
872 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
873 cy.get('[data-cy=collection-files-panel]')
874 .should('not.contain', 'foo').and('contain', 'bar');
875 cy.get('[data-cy=collection-version-browser-select-3]')
876 .should('contain', '3').and('contain', '3 B');
878 // Check context menus on version browser
880 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
881 cy.get('[data-cy=context-menu]')
882 .should('contain', 'Add to favorites')
883 .and('contain', 'Make a copy')
884 .and('contain', 'Edit collection');
885 cy.get('body').click();
886 // (and now an old version...)
887 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
888 cy.get('[data-cy=context-menu]')
889 .should('not.contain', 'Add to favorites')
890 .and('contain', 'Make a copy')
891 .and('not.contain', 'Edit collection');
892 cy.get('body').click();
894 // Restore first version
895 cy.get('[data-cy=collection-version-browser]').within(() => {
896 cy.get('[data-cy=collection-version-browser-select-1]').click();
898 cy.get('[data-cy=collection-panel-options-btn]').click()
899 cy.get('[data-cy=context-menu]').contains('Restore version').click();
900 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
901 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
902 cy.get('[data-cy=collection-info-panel]')
903 .should('not.contain', 'This is an old version');
904 cy.get('[data-cy=collection-version-number]').should('contain', '4');
905 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
906 cy.get('[data-cy=collection-files-panel]')
907 .should('contain', 'foo').and('contain', 'bar');
911 it('copies selected files into new collection', () => {
912 cy.createCollection(adminUser.token, {
913 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
914 owner_uuid: activeUser.user.uuid,
915 preserve_version: true,
916 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
918 .as('collection').then(function () {
919 // Visit collection, check basic information
920 cy.loginAs(activeUser)
921 cy.goToPath(`/collections/${this.collection.uuid}`);
923 cy.get('[data-cy=collection-files-panel]').within(() => {
924 cy.get('input[type=checkbox]').first().click();
927 cy.get('[data-cy=collection-files-panel-options-btn]').click();
928 cy.get('[data-cy=context-menu]').contains('Copy selected into new collection').click();
930 cy.get('[data-cy=form-dialog]').contains('Projects').click();
932 cy.get('[data-cy=form-submit-btn]').click();
934 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
936 cy.waitForDom().get('main').contains(`Files extracted from: ${this.collection.name}`).click();
937 cy.get('[data-cy=collection-files-panel]')
938 .and('contain', 'bar');
942 it('copies selected files into existing collection', () => {
943 cy.createCollection(adminUser.token, {
944 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
945 owner_uuid: activeUser.user.uuid,
946 preserve_version: true,
947 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
948 }).as('sourceCollection')
950 cy.createCollection(adminUser.token, {
951 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
952 owner_uuid: activeUser.user.uuid,
953 preserve_version: true,
955 }).as('destinationCollection');
957 cy.getAll('@sourceCollection', '@destinationCollection').then(function ([sourceCollection, destinationCollection]) {
958 // Visit collection, check basic information
959 cy.loginAs(activeUser)
960 cy.goToPath(`/collections/${sourceCollection.uuid}`);
962 cy.get('[data-cy=collection-files-panel]').within(() => {
963 cy.get('input[type=checkbox]').first().click();
966 cy.get('[data-cy=collection-files-panel-options-btn]').click();
967 cy.get('[data-cy=context-menu]').contains('Copy selected into existing collection').click();
969 cy.get('[data-cy=form-dialog]').contains(destinationCollection.name).click();
971 cy.get('[data-cy=form-submit-btn]').click();
974 cy.goToPath(`/collections/${destinationCollection.uuid}`);
976 cy.get('main').contains(destinationCollection.name).should('exist');
977 cy.get('[data-cy=collection-files-panel]')
978 .and('contain', 'bar');
982 it('copies selected files into separate collections', () => {
983 cy.createCollection(adminUser.token, {
984 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
985 owner_uuid: activeUser.user.uuid,
986 preserve_version: true,
987 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
988 }).as('sourceCollection')
990 cy.getAll('@sourceCollection').then(function ([sourceCollection]) {
991 // Visit collection, check basic information
992 cy.loginAs(activeUser)
993 cy.goToPath(`/collections/${sourceCollection.uuid}`);
996 cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
997 cy.get('input[type=checkbox]').first().click();
998 cy.get('input[type=checkbox]').last().click();
1001 // Copy to separate collections
1002 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1003 cy.get('[data-cy=context-menu]').contains('Copy selected into separate collections').click();
1004 cy.get('[data-cy=form-dialog]').contains('Projects').click();
1005 cy.get('[data-cy=form-submit-btn]').click();
1007 // Verify created collections
1008 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
1009 cy.get('main').contains(`File copied from collection ${sourceCollection.name}/foo`).click();
1010 cy.get('[data-cy=collection-files-panel]')
1011 .and('contain', 'foo');
1012 cy.get('.layout-pane-primary').contains('Projects').click();
1013 cy.get('main').contains(`File copied from collection ${sourceCollection.name}/bar`).click();
1014 cy.get('[data-cy=collection-files-panel]')
1015 .and('contain', 'bar');
1017 // Verify separate collection menu items not present when single file selected
1018 // Wait for dom for collection to re-render
1019 cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
1020 cy.get('input[type=checkbox]').first().click();
1022 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1023 cy.get('[data-cy=context-menu]').should('not.contain', 'Copy selected into separate collections');
1024 cy.get('[data-cy=context-menu]').should('not.contain', 'Move selected into separate collections');
1028 it('moves selected files into new collection', () => {
1029 cy.createCollection(adminUser.token, {
1030 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1031 owner_uuid: activeUser.user.uuid,
1032 preserve_version: true,
1033 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
1035 .as('collection').then(function () {
1036 // Visit collection, check basic information
1037 cy.loginAs(activeUser)
1038 cy.goToPath(`/collections/${this.collection.uuid}`);
1040 cy.get('[data-cy=collection-files-panel]').within(() => {
1041 cy.get('input[type=checkbox]').first().click();
1044 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1045 cy.get('[data-cy=context-menu]').contains('Move selected into new collection').click();
1047 cy.get('[data-cy=form-dialog]').contains('Projects').click();
1049 cy.get('[data-cy=form-submit-btn]').click();
1051 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
1053 cy.get('main').contains(`Files moved from: ${this.collection.name}`).click();
1054 cy.get('[data-cy=collection-files-panel]')
1055 .and('contain', 'bar');
1059 it('moves selected files into existing collection', () => {
1060 cy.createCollection(adminUser.token, {
1061 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1062 owner_uuid: activeUser.user.uuid,
1063 preserve_version: true,
1064 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
1065 }).as('sourceCollection')
1067 cy.createCollection(adminUser.token, {
1068 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
1069 owner_uuid: activeUser.user.uuid,
1070 preserve_version: true,
1072 }).as('destinationCollection');
1074 cy.getAll('@sourceCollection', '@destinationCollection').then(function ([sourceCollection, destinationCollection]) {
1075 // Visit collection, check basic information
1076 cy.loginAs(activeUser)
1077 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1079 cy.get('[data-cy=collection-files-panel]').within(() => {
1080 cy.get('input[type=checkbox]').first().click();
1083 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1084 cy.get('[data-cy=context-menu]').contains('Move selected into existing collection').click();
1086 cy.get('[data-cy=form-dialog]').contains(destinationCollection.name).click();
1088 cy.get('[data-cy=form-submit-btn]').click();
1091 cy.goToPath(`/collections/${destinationCollection.uuid}`);
1093 cy.get('main').contains(destinationCollection.name).should('exist');
1094 cy.get('[data-cy=collection-files-panel]')
1095 .and('contain', 'bar');
1099 it('moves selected files into separate collections', () => {
1100 cy.createCollection(adminUser.token, {
1101 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1102 owner_uuid: activeUser.user.uuid,
1103 preserve_version: true,
1104 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
1105 }).as('sourceCollection')
1107 cy.getAll('@sourceCollection').then(function ([sourceCollection]) {
1108 // Visit collection, check basic information
1109 cy.loginAs(activeUser)
1110 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1112 // Select both files
1113 cy.get('[data-cy=collection-files-panel]').within(() => {
1114 cy.get('input[type=checkbox]').first().click();
1115 cy.get('input[type=checkbox]').last().click();
1118 // Copy to separate collections
1119 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1120 cy.get('[data-cy=context-menu]').contains('Move selected into separate collections').click();
1121 cy.get('[data-cy=form-dialog]').contains('Projects').click();
1122 cy.get('[data-cy=form-submit-btn]').click();
1124 // Verify created collections
1125 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
1126 cy.get('main').contains(`File moved from collection ${sourceCollection.name}/foo`).click();
1127 cy.get('[data-cy=collection-files-panel]')
1128 .and('contain', 'foo');
1129 cy.get('.layout-pane-primary').contains('Projects').click();
1130 cy.get('main').contains(`File moved from collection ${sourceCollection.name}/bar`).click();
1131 cy.get('[data-cy=collection-files-panel]')
1132 .and('contain', 'bar');
1136 it('creates new collection with properties on home project', function () {
1137 cy.loginAs(activeUser);
1138 cy.goToPath(`/projects/${activeUser.user.uuid}`);
1139 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
1140 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
1141 // Create new collection
1142 cy.get('[data-cy=side-panel-button]').click();
1143 cy.get('[data-cy=side-panel-new-collection]').click();
1144 // Name between brackets tests bugfix #17582
1145 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
1147 // Select a storage class.
1148 cy.get('[data-cy=form-dialog]')
1149 .should('contain', 'New collection')
1150 .and('contain', 'Storage classes')
1151 .and('contain', 'default')
1152 .and('contain', 'foo')
1153 .and('contain', 'bar')
1155 cy.get('[data-cy=parent-field]').within(() => {
1156 cy.get('input').should('have.value', 'Home project');
1158 cy.get('[data-cy=name-field]').within(() => {
1159 cy.get('input').type(collName);
1161 cy.get('[data-cy=checkbox-foo]').click();
1165 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
1166 cy.get('[data-cy=form-dialog]').should('not.contain', 'Color: Magenta');
1167 cy.get('[data-cy=resource-properties-form]').within(() => {
1168 cy.get('[data-cy=property-field-key]').within(() => {
1169 cy.get('input').type('Color');
1171 cy.get('[data-cy=property-field-value]').within(() => {
1172 cy.get('input').type('Magenta');
1176 // Confirm proper vocabulary labels are displayed on the UI.
1177 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
1179 // Value field should not complain about being required just after
1180 // adding a new property. See #19732
1181 cy.get('[data-cy=form-dialog]').should('not.contain', 'This field is required');
1183 cy.get('[data-cy=form-submit-btn]').click();
1184 // Confirm that the user was taken to the newly created collection
1185 cy.get('[data-cy=form-dialog]').should('not.exist');
1186 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
1187 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
1188 cy.get('[data-cy=collection-info-panel]')
1189 .should('contain', 'default')
1190 .and('contain', 'foo')
1191 .and('contain', 'Color: Magenta')
1192 .and('not.contain', 'bar');
1193 // Confirm that the collection's properties has the real values.
1194 cy.doRequest('GET', '/arvados/v1/collections', null, {
1195 filters: `[["name", "=", "${collName}"]]`,
1197 .its('body.items').as('collections')
1199 expect(this.collections).to.have.lengthOf(1);
1200 expect(this.collections[0].properties).to.have.property(
1201 'IDTAGCOLORS', 'IDVALCOLORS3');
1205 it('shows responsible person for collection if available', () => {
1206 cy.createCollection(adminUser.token, {
1207 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1208 owner_uuid: activeUser.user.uuid,
1209 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
1210 }).as('testCollection1');
1212 cy.createCollection(adminUser.token, {
1213 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1214 owner_uuid: adminUser.user.uuid,
1215 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
1216 }).as('testCollection2').then(function (testCollection2) {
1217 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
1220 cy.getAll('@testCollection1', '@testCollection2')
1221 .then(function ([testCollection1, testCollection2]) {
1222 cy.loginAs(activeUser);
1224 cy.goToPath(`/collections/${testCollection1.uuid}`);
1225 cy.get('[data-cy=responsible-person-wrapper]')
1226 .contains(activeUser.user.uuid);
1228 cy.goToPath(`/collections/${testCollection2.uuid}`);
1229 cy.get('[data-cy=responsible-person-wrapper]')
1230 .contains(adminUser.user.uuid);
1234 describe('file upload', () => {
1236 cy.createCollection(adminUser.token, {
1237 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1238 owner_uuid: activeUser.user.uuid,
1239 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
1240 }).as('testCollection1');
1243 it('uploads a file and checks the collection UI to be fresh', () => {
1244 cy.getAll('@testCollection1')
1245 .then(function([testCollection1]) {
1246 cy.loginAs(activeUser);
1247 cy.goToPath(`/collections/${testCollection1.uuid}`);
1248 cy.get('[data-cy=upload-button]').click();
1249 cy.get('[data-cy=collection-files-panel]')
1250 .contains('5mb_a.bin').should('not.exist');
1251 cy.get('[data-cy=collection-file-count]').should('contain', '2');
1252 cy.fixture('files/5mb.bin', 'base64').then(content => {
1253 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1254 cy.get('[data-cy=form-submit-btn]').click();
1255 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1256 cy.get('[data-cy=collection-files-panel]')
1257 .contains('5mb_a.bin').should('exist');
1258 cy.get('[data-cy=collection-file-count]').should('contain', '3');
1260 cy.get('[data-cy=collection-files-panel]').contains('subdir').click();
1261 cy.get('[data-cy=upload-button]').click();
1262 cy.fixture('files/5mb.bin', 'base64').then(content => {
1263 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1264 cy.get('[data-cy=form-submit-btn]').click();
1265 cy.waitForDom().get('[data-cy=form-submit-btn]').should('not.exist');
1266 // subdir gets unselected, I think this is a bug but
1267 // for the time being let's just make sure the test works.
1268 cy.get('[data-cy=collection-files-panel]').contains('subdir').click();
1269 cy.waitForDom().get('[data-cy=collection-files-right-panel]')
1270 .contains('5mb_b.bin').should('exist');
1276 it('allows to cancel running upload', () => {
1277 cy.getAll('@testCollection1')
1278 .then(function([testCollection1]) {
1279 cy.loginAs(activeUser);
1281 cy.goToPath(`/collections/${testCollection1.uuid}`);
1283 cy.get('[data-cy=upload-button]').click();
1285 cy.fixture('files/5mb.bin', 'base64').then(content => {
1286 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1287 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1289 cy.get('[data-cy=form-submit-btn]').click();
1291 cy.get('button').contains('Cancel').click();
1293 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1298 it('allows to cancel single file from the running upload', () => {
1299 cy.getAll('@testCollection1')
1300 .then(function([testCollection1]) {
1301 cy.loginAs(activeUser);
1303 cy.goToPath(`/collections/${testCollection1.uuid}`);
1305 cy.get('[data-cy=upload-button]').click();
1307 cy.fixture('files/5mb.bin', 'base64').then(content => {
1308 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1309 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1311 cy.get('[data-cy=form-submit-btn]').click();
1313 cy.get('button[aria-label=Remove]').eq(1).click();
1315 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1317 cy.get('[data-cy=collection-files-panel]').contains('5mb_a.bin').should('exist');
1322 it('allows to cancel all files from the running upload', () => {
1323 cy.getAll('@testCollection1')
1324 .then(function([testCollection1]) {
1325 cy.loginAs(activeUser);
1327 cy.goToPath(`/collections/${testCollection1.uuid}`);
1329 // Confirm initial collection state.
1330 cy.get('[data-cy=collection-files-panel]')
1331 .contains('bar').should('exist');
1332 cy.get('[data-cy=collection-files-panel]')
1333 .contains('5mb_a.bin').should('not.exist');
1334 cy.get('[data-cy=collection-files-panel]')
1335 .contains('5mb_b.bin').should('not.exist');
1337 cy.get('[data-cy=upload-button]').click();
1339 cy.fixture('files/5mb.bin', 'base64').then(content => {
1340 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1341 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1343 cy.get('[data-cy=form-submit-btn]').click();
1345 cy.get('button[aria-label=Remove]').should('exist');
1346 cy.get('button[aria-label=Remove]')
1347 .click({ multiple: true, force: true });
1349 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1351 // Confirm final collection state.
1352 cy.get('[data-cy=collection-files-panel]')
1353 .contains('bar').should('exist');
1354 // The following fails, but doesn't seem to happen
1355 // in the real world. Maybe there's a race between
1356 // the PUT request finishing and the 'Remove' button
1357 // dissapearing, because sometimes just one of the 2
1358 // files gets uploaded.
1359 // Maybe this will be needed to simulate a slow network:
1360 // https://docs.cypress.io/api/commands/intercept#Convenience-functions-1
1361 // cy.get('[data-cy=collection-files-panel]')
1362 // .contains('5mb_a.bin').should('not.exist');
1363 // cy.get('[data-cy=collection-files-panel]')
1364 // .contains('5mb_b.bin').should('not.exist');