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.uuid);
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
879 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
880 cy.get('[data-cy=context-menu]')
881 .should('contain', 'Add to favorites')
882 .and('contain', 'Make a copy')
883 .and('contain', 'Edit collection');
884 cy.get('body').click();
885 // (and now an old version...)
886 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
887 cy.get('[data-cy=context-menu]')
888 .should('not.contain', 'Add to favorites')
889 .and('contain', 'Make a copy')
890 .and('not.contain', 'Edit collection');
891 cy.get('body').click();
893 // Restore first version
894 cy.get('[data-cy=collection-version-browser]').within(() => {
895 cy.get('[data-cy=collection-version-browser-select-1]').click();
897 cy.get('[data-cy=collection-panel-options-btn]').click()
898 cy.get('[data-cy=context-menu]').contains('Restore version').click();
899 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
900 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
901 cy.get('[data-cy=collection-info-panel]')
902 .should('not.contain', 'This is an old version');
903 cy.get('[data-cy=collection-version-number]').should('contain', '4');
904 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
905 cy.get('[data-cy=collection-files-panel]')
906 .should('contain', 'foo').and('contain', 'bar');
910 it('copies selected files into new collection', () => {
911 cy.createCollection(adminUser.token, {
912 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
913 owner_uuid: activeUser.user.uuid,
914 preserve_version: true,
915 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
917 .as('collection').then(function () {
918 // Visit collection, check basic information
919 cy.loginAs(activeUser)
920 cy.goToPath(`/collections/${this.collection.uuid}`);
922 cy.get('[data-cy=collection-files-panel]').within(() => {
923 cy.get('input[type=checkbox]').first().click();
926 cy.get('[data-cy=collection-files-panel-options-btn]').click();
927 cy.get('[data-cy=context-menu]').contains('Copy selected into new collection').click();
929 cy.get('[data-cy=form-dialog]').contains('Projects').click();
931 cy.get('[data-cy=form-submit-btn]').click();
933 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
935 cy.get('main').contains(`Files extracted from: ${this.collection.name}`).click();
936 cy.get('[data-cy=collection-files-panel]')
937 .and('contain', 'bar');
941 it('copies selected files into existing collection', () => {
942 cy.createCollection(adminUser.token, {
943 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
944 owner_uuid: activeUser.user.uuid,
945 preserve_version: true,
946 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
947 }).as('sourceCollection')
949 cy.createCollection(adminUser.token, {
950 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
951 owner_uuid: activeUser.user.uuid,
952 preserve_version: true,
954 }).as('destinationCollection');
956 cy.getAll('@sourceCollection', '@destinationCollection').then(function ([sourceCollection, destinationCollection]) {
957 // Visit collection, check basic information
958 cy.loginAs(activeUser)
959 cy.goToPath(`/collections/${sourceCollection.uuid}`);
961 cy.get('[data-cy=collection-files-panel]').within(() => {
962 cy.get('input[type=checkbox]').first().click();
965 cy.get('[data-cy=collection-files-panel-options-btn]').click();
966 cy.get('[data-cy=context-menu]').contains('Copy selected into existing collection').click();
968 cy.get('[data-cy=form-dialog]').contains(destinationCollection.name).click();
970 cy.get('[data-cy=form-submit-btn]').click();
973 cy.goToPath(`/collections/${destinationCollection.uuid}`);
975 cy.get('main').contains(destinationCollection.name).should('exist');
976 cy.get('[data-cy=collection-files-panel]')
977 .and('contain', 'bar');
981 it('copies selected files into separate collections', () => {
982 cy.createCollection(adminUser.token, {
983 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
984 owner_uuid: activeUser.user.uuid,
985 preserve_version: true,
986 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
987 }).as('sourceCollection')
989 cy.getAll('@sourceCollection').then(function ([sourceCollection]) {
990 // Visit collection, check basic information
991 cy.loginAs(activeUser)
992 cy.goToPath(`/collections/${sourceCollection.uuid}`);
995 cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
996 cy.get('input[type=checkbox]').first().click();
997 cy.get('input[type=checkbox]').last().click();
1000 // Copy to separate collections
1001 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1002 cy.get('[data-cy=context-menu]').contains('Copy selected into separate collections').click();
1003 cy.get('[data-cy=form-dialog]').contains('Projects').click();
1004 cy.get('[data-cy=form-submit-btn]').click();
1006 // Verify created collections
1007 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
1008 cy.get('main').contains(`File copied from collection ${sourceCollection.name}/foo`).click();
1009 cy.get('[data-cy=collection-files-panel]')
1010 .and('contain', 'foo');
1011 cy.get('.layout-pane-primary').contains('Projects').click();
1012 cy.get('main').contains(`File copied from collection ${sourceCollection.name}/bar`).click();
1013 cy.get('[data-cy=collection-files-panel]')
1014 .and('contain', 'bar');
1016 // Verify separate collection menu items not present when single file selected
1017 // Wait for dom for collection to re-render
1018 cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
1019 cy.get('input[type=checkbox]').first().click();
1021 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1022 cy.get('[data-cy=context-menu]').should('not.contain', 'Copy selected into separate collections');
1023 cy.get('[data-cy=context-menu]').should('not.contain', 'Move selected into separate collections');
1027 it('moves selected files into new collection', () => {
1028 cy.createCollection(adminUser.token, {
1029 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1030 owner_uuid: activeUser.user.uuid,
1031 preserve_version: true,
1032 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
1034 .as('collection').then(function () {
1035 // Visit collection, check basic information
1036 cy.loginAs(activeUser)
1037 cy.goToPath(`/collections/${this.collection.uuid}`);
1039 cy.get('[data-cy=collection-files-panel]').within(() => {
1040 cy.get('input[type=checkbox]').first().click();
1043 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1044 cy.get('[data-cy=context-menu]').contains('Move selected into new collection').click();
1046 cy.get('[data-cy=form-dialog]').contains('Projects').click();
1048 cy.get('[data-cy=form-submit-btn]').click();
1050 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
1052 cy.get('main').contains(`Files moved from: ${this.collection.name}`).click();
1053 cy.get('[data-cy=collection-files-panel]')
1054 .and('contain', 'bar');
1058 it('moves selected files into existing collection', () => {
1059 cy.createCollection(adminUser.token, {
1060 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1061 owner_uuid: activeUser.user.uuid,
1062 preserve_version: true,
1063 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
1064 }).as('sourceCollection')
1066 cy.createCollection(adminUser.token, {
1067 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
1068 owner_uuid: activeUser.user.uuid,
1069 preserve_version: true,
1071 }).as('destinationCollection');
1073 cy.getAll('@sourceCollection', '@destinationCollection').then(function ([sourceCollection, destinationCollection]) {
1074 // Visit collection, check basic information
1075 cy.loginAs(activeUser)
1076 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1078 cy.get('[data-cy=collection-files-panel]').within(() => {
1079 cy.get('input[type=checkbox]').first().click();
1082 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1083 cy.get('[data-cy=context-menu]').contains('Move selected into existing collection').click();
1085 cy.get('[data-cy=form-dialog]').contains(destinationCollection.name).click();
1087 cy.get('[data-cy=form-submit-btn]').click();
1090 cy.goToPath(`/collections/${destinationCollection.uuid}`);
1092 cy.get('main').contains(destinationCollection.name).should('exist');
1093 cy.get('[data-cy=collection-files-panel]')
1094 .and('contain', 'bar');
1098 it('moves selected files into separate collections', () => {
1099 cy.createCollection(adminUser.token, {
1100 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1101 owner_uuid: activeUser.user.uuid,
1102 preserve_version: true,
1103 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
1104 }).as('sourceCollection')
1106 cy.getAll('@sourceCollection').then(function ([sourceCollection]) {
1107 // Visit collection, check basic information
1108 cy.loginAs(activeUser)
1109 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1111 // Select both files
1112 cy.get('[data-cy=collection-files-panel]').within(() => {
1113 cy.get('input[type=checkbox]').first().click();
1114 cy.get('input[type=checkbox]').last().click();
1117 // Copy to separate collections
1118 cy.get('[data-cy=collection-files-panel-options-btn]').click();
1119 cy.get('[data-cy=context-menu]').contains('Move selected into separate collections').click();
1120 cy.get('[data-cy=form-dialog]').contains('Projects').click();
1121 cy.get('[data-cy=form-submit-btn]').click();
1123 // Verify created collections
1124 cy.waitForDom().get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
1125 cy.get('main').contains(`File moved from collection ${sourceCollection.name}/foo`).click();
1126 cy.get('[data-cy=collection-files-panel]')
1127 .and('contain', 'foo');
1128 cy.get('.layout-pane-primary').contains('Projects').click();
1129 cy.get('main').contains(`File moved from collection ${sourceCollection.name}/bar`).click();
1130 cy.get('[data-cy=collection-files-panel]')
1131 .and('contain', 'bar');
1135 it('creates new collection with properties on home project', function () {
1136 cy.loginAs(activeUser);
1137 cy.goToPath(`/projects/${activeUser.user.uuid}`);
1138 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
1139 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
1140 // Create new collection
1141 cy.get('[data-cy=side-panel-button]').click();
1142 cy.get('[data-cy=side-panel-new-collection]').click();
1143 // Name between brackets tests bugfix #17582
1144 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
1146 // Select a storage class.
1147 cy.get('[data-cy=form-dialog]')
1148 .should('contain', 'New collection')
1149 .and('contain', 'Storage classes')
1150 .and('contain', 'default')
1151 .and('contain', 'foo')
1152 .and('contain', 'bar')
1154 cy.get('[data-cy=parent-field]').within(() => {
1155 cy.get('input').should('have.value', 'Home project');
1157 cy.get('[data-cy=name-field]').within(() => {
1158 cy.get('input').type(collName);
1160 cy.get('[data-cy=checkbox-foo]').click();
1164 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
1165 cy.get('[data-cy=form-dialog]').should('not.contain', 'Color: Magenta');
1166 cy.get('[data-cy=resource-properties-form]').within(() => {
1167 cy.get('[data-cy=property-field-key]').within(() => {
1168 cy.get('input').type('Color');
1170 cy.get('[data-cy=property-field-value]').within(() => {
1171 cy.get('input').type('Magenta');
1175 // Confirm proper vocabulary labels are displayed on the UI.
1176 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
1178 // Value field should not complain about being required just after
1179 // adding a new property. See #19732
1180 cy.get('[data-cy=form-dialog]').should('not.contain', 'This field is required');
1182 cy.get('[data-cy=form-submit-btn]').click();
1183 // Confirm that the user was taken to the newly created collection
1184 cy.get('[data-cy=form-dialog]').should('not.exist');
1185 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
1186 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
1187 cy.get('[data-cy=collection-info-panel]')
1188 .should('contain', 'default')
1189 .and('contain', 'foo')
1190 .and('contain', 'Color: Magenta')
1191 .and('not.contain', 'bar');
1192 // Confirm that the collection's properties has the real values.
1193 cy.doRequest('GET', '/arvados/v1/collections', null, {
1194 filters: `[["name", "=", "${collName}"]]`,
1196 .its('body.items').as('collections')
1198 expect(this.collections).to.have.lengthOf(1);
1199 expect(this.collections[0].properties).to.have.property(
1200 'IDTAGCOLORS', 'IDVALCOLORS3');
1204 it('shows responsible person for collection if available', () => {
1205 cy.createCollection(adminUser.token, {
1206 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1207 owner_uuid: activeUser.user.uuid,
1208 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
1209 }).as('testCollection1');
1211 cy.createCollection(adminUser.token, {
1212 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1213 owner_uuid: adminUser.user.uuid,
1214 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
1215 }).as('testCollection2').then(function (testCollection2) {
1216 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
1219 cy.getAll('@testCollection1', '@testCollection2')
1220 .then(function ([testCollection1, testCollection2]) {
1221 cy.loginAs(activeUser);
1223 cy.goToPath(`/collections/${testCollection1.uuid}`);
1224 cy.get('[data-cy=responsible-person-wrapper]')
1225 .contains(activeUser.user.uuid);
1227 cy.goToPath(`/collections/${testCollection2.uuid}`);
1228 cy.get('[data-cy=responsible-person-wrapper]')
1229 .contains(adminUser.user.uuid);
1233 describe('file upload', () => {
1235 cy.createCollection(adminUser.token, {
1236 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1237 owner_uuid: activeUser.user.uuid,
1238 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
1239 }).as('testCollection1');
1242 it('uploads a file and checks the collection UI to be fresh', () => {
1243 cy.getAll('@testCollection1')
1244 .then(function([testCollection1]) {
1245 cy.loginAs(activeUser);
1246 cy.goToPath(`/collections/${testCollection1.uuid}`);
1247 cy.get('[data-cy=upload-button]').click();
1248 cy.get('[data-cy=collection-files-panel]')
1249 .contains('5mb_a.bin').should('not.exist');
1250 cy.get('[data-cy=collection-file-count]').should('contain', '2');
1251 cy.fixture('files/5mb.bin', 'base64').then(content => {
1252 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1253 cy.get('[data-cy=form-submit-btn]').click();
1254 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1255 cy.get('[data-cy=collection-files-panel]')
1256 .contains('5mb_a.bin').should('exist');
1257 cy.get('[data-cy=collection-file-count]').should('contain', '3');
1259 cy.get('[data-cy=collection-files-panel]').contains('subdir').click();
1260 cy.get('[data-cy=upload-button]').click();
1261 cy.fixture('files/5mb.bin', 'base64').then(content => {
1262 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1263 cy.get('[data-cy=form-submit-btn]').click();
1264 cy.waitForDom().get('[data-cy=form-submit-btn]').should('not.exist');
1265 // subdir gets unselected, I think this is a bug but
1266 // for the time being let's just make sure the test works.
1267 cy.get('[data-cy=collection-files-panel]').contains('subdir').click();
1268 cy.waitForDom().get('[data-cy=collection-files-right-panel]')
1269 .contains('5mb_b.bin').should('exist');
1275 it('allows to cancel running upload', () => {
1276 cy.getAll('@testCollection1')
1277 .then(function([testCollection1]) {
1278 cy.loginAs(activeUser);
1280 cy.goToPath(`/collections/${testCollection1.uuid}`);
1282 cy.get('[data-cy=upload-button]').click();
1284 cy.fixture('files/5mb.bin', 'base64').then(content => {
1285 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1286 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1288 cy.get('[data-cy=form-submit-btn]').click();
1290 cy.get('button').contains('Cancel').click();
1292 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1297 it('allows to cancel single file from the running upload', () => {
1298 cy.getAll('@testCollection1')
1299 .then(function([testCollection1]) {
1300 cy.loginAs(activeUser);
1302 cy.goToPath(`/collections/${testCollection1.uuid}`);
1304 cy.get('[data-cy=upload-button]').click();
1306 cy.fixture('files/5mb.bin', 'base64').then(content => {
1307 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1308 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1310 cy.get('[data-cy=form-submit-btn]').click();
1312 cy.get('button[aria-label=Remove]').eq(1).click();
1314 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1316 cy.get('[data-cy=collection-files-panel]').contains('5mb_a.bin').should('exist');
1321 it('allows to cancel all files from the running upload', () => {
1322 cy.getAll('@testCollection1')
1323 .then(function([testCollection1]) {
1324 cy.loginAs(activeUser);
1326 cy.goToPath(`/collections/${testCollection1.uuid}`);
1328 // Confirm initial collection state.
1329 cy.get('[data-cy=collection-files-panel]')
1330 .contains('bar').should('exist');
1331 cy.get('[data-cy=collection-files-panel]')
1332 .contains('5mb_a.bin').should('not.exist');
1333 cy.get('[data-cy=collection-files-panel]')
1334 .contains('5mb_b.bin').should('not.exist');
1336 cy.get('[data-cy=upload-button]').click();
1338 cy.fixture('files/5mb.bin', 'base64').then(content => {
1339 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
1340 cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
1342 cy.get('[data-cy=form-submit-btn]').click();
1344 cy.get('button[aria-label=Remove]').should('exist');
1345 cy.get('button[aria-label=Remove]')
1346 .click({ multiple: true, force: true });
1348 cy.get('[data-cy=form-submit-btn]').should('not.exist');
1350 // Confirm final collection state.
1351 cy.get('[data-cy=collection-files-panel]')
1352 .contains('bar').should('exist');
1353 // The following fails, but doesn't seem to happen
1354 // in the real world. Maybe there's a race between
1355 // the PUT request finishing and the 'Remove' button
1356 // dissapearing, because sometimes just one of the 2
1357 // files gets uploaded.
1358 // Maybe this will be needed to simulate a slow network:
1359 // https://docs.cypress.io/api/commands/intercept#Convenience-functions-1
1360 // cy.get('[data-cy=collection-files-panel]')
1361 // .contains('5mb_a.bin').should('not.exist');
1362 // cy.get('[data-cy=collection-files-panel]')
1363 // .contains('5mb_b.bin').should('not.exist');