1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 const path = require('path');
7 describe('Collection panel tests', function () {
13 // Only set up common users once. These aren't set up as aliases because
14 // aliases are cleaned up after every test. Also it doesn't make sense
15 // to set the same users on beforeEach() over and over again, so we
16 // separate a little from Cypress' 'Best Practices' here.
17 cy.getUser('admin', 'Admin', 'User', true, true)
18 .as('adminUser').then(function () {
19 adminUser = this.adminUser;
22 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
23 .as('activeUser').then(function () {
24 activeUser = this.activeUser;
27 downloadsFolder = Cypress.config('downloadsFolder');
30 beforeEach(function () {
32 cy.clearLocalStorage();
35 it('allows to download mountain duck config for a collection', () => {
36 cy.createCollection(adminUser.token, {
37 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
38 owner_uuid: activeUser.user.uuid,
39 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
41 .as('testCollection').then(function (testCollection) {
42 cy.loginAs(activeUser);
43 cy.goToPath(`/collections/${testCollection.uuid}`);
45 cy.get('[data-cy=collection-panel-options-btn]').click();
46 cy.get('[data-cy=context-menu]').contains('Open with 3rd party client').click();
47 cy.get('[data-cy=download-button').click();
49 const filename = path.join(downloadsFolder, `${testCollection.name}.duck`);
51 cy.readFile(filename, { timeout: 15000 })
53 const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find('dict')[0].children);
57 for (i=0; i < childrenCollection.length; i += j) {
58 map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
61 cy.get('#simple-tabpanel-0').find('a')
63 const [host, port] = a.text().split('@')[1].split('/')[0].split(':');
64 expect(map['Protocol']).to.equal('davs');
65 expect(map['UUID']).to.equal(testCollection.uuid);
66 expect(map['Username']).to.equal(activeUser.user.username);
67 expect(map['Port']).to.equal(port);
68 expect(map['Hostname']).to.equal(host);
70 expect(map['Path']).to.equal(`/c=${testCollection.uuid}`);
74 .then(() => cy.task('clearDownload', { filename }));
78 it('uses the property editor with vocabulary terms', function () {
79 cy.createCollection(adminUser.token, {
80 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
81 owner_uuid: activeUser.user.uuid,
82 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
84 .as('testCollection').then(function () {
85 cy.loginAs(activeUser);
86 cy.goToPath(`/collections/${this.testCollection.uuid}`);
88 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
89 cy.get('[data-cy=resource-properties-form]').within(() => {
90 cy.get('[data-cy=property-field-key]').within(() => {
91 cy.get('input').type('Color');
93 cy.get('[data-cy=property-field-value]').within(() => {
94 cy.get('input').type('Magenta');
98 // Confirm proper vocabulary labels are displayed on the UI.
99 cy.get('[data-cy=collection-properties-panel]')
100 .should('contain', 'Color')
101 .and('contain', 'Magenta');
102 // Confirm proper vocabulary IDs were saved on the backend.
103 cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
104 .its('body').as('collection')
106 expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
111 it('shows collection by URL', function () {
112 cy.loginAs(activeUser);
113 [true, false].map(function (isWritable) {
114 // Using different file names to avoid test flakyness: the second iteration
115 // on this loop may pass an assertion from the first iteration by looking
116 // for the same file name.
117 const fileName = isWritable ? 'bar' : 'foo';
118 const subDirName = 'subdir';
119 cy.createGroup(adminUser.token, {
120 name: 'Shared project',
121 group_class: 'project',
122 }).as('sharedGroup').then(function () {
123 // Creates the collection using the admin token so we can set up
124 // a bogus manifest text without block signatures.
125 cy.createCollection(adminUser.token, {
126 name: 'Test collection',
127 owner_uuid: this.sharedGroup.uuid,
128 properties: { someKey: 'someValue' },
129 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
131 .as('testCollection').then(function () {
132 // Share the group with active user.
133 cy.createLink(adminUser.token, {
134 name: isWritable ? 'can_write' : 'can_read',
135 link_class: 'permission',
136 head_uuid: this.sharedGroup.uuid,
137 tail_uuid: activeUser.user.uuid
139 cy.goToPath(`/collections/${this.testCollection.uuid}`);
141 // Check that name & uuid are correct.
142 cy.get('[data-cy=collection-info-panel]')
143 .should('contain', this.testCollection.name)
144 .and('contain', this.testCollection.uuid)
145 .and('not.contain', 'This is an old version');
146 // Check for the read-only icon
147 cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
148 // Check that both read and write operations are available on
149 // the 'More options' menu.
150 cy.get('[data-cy=collection-panel-options-btn]')
152 cy.get('[data-cy=context-menu]')
153 .should('contain', 'Add to favorites')
154 .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
155 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
156 cy.get('[data-cy=collection-properties-panel]')
157 .should('contain', 'someKey')
158 .and('contain', 'someValue')
159 .and('not.contain', 'anotherKey')
160 .and('not.contain', 'anotherValue')
161 if (isWritable === true) {
162 // Check that properties can be added.
163 cy.get('[data-cy=resource-properties-form]').within(() => {
164 cy.get('[data-cy=property-field-key]').within(() => {
165 cy.get('input').type('anotherKey');
167 cy.get('[data-cy=property-field-value]').within(() => {
168 cy.get('input').type('anotherValue');
172 cy.get('[data-cy=collection-properties-panel]')
173 .should('contain', 'anotherKey')
174 .and('contain', 'anotherValue')
176 // Properties form shouldn't be displayed.
177 cy.get('[data-cy=resource-properties-form]').should('not.exist');
179 // Check that the file listing show both read & write operations
180 cy.get('[data-cy=collection-files-panel]').within(() => {
181 cy.root().should('contain', fileName);
183 cy.get('[data-cy=upload-button]')
184 .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
187 // Test context menus
188 cy.get('[data-cy=collection-files-panel]')
189 .contains(fileName).rightclick({ force: true });
190 cy.get('[data-cy=context-menu]')
191 .should('contain', 'Download')
192 .and('contain', 'Copy to clipboard')
193 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
194 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
195 cy.get('body').click(); // Collapse the menu
196 cy.get('[data-cy=collection-files-panel]')
197 .contains(subDirName).rightclick({ force: true });
198 cy.get('[data-cy=context-menu]')
199 .should('not.contain', 'Download')
200 .and('contain', 'Copy to clipboard')
201 .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
202 .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
203 cy.get('body').click(); // Collapse the menu
204 // Hamburger 'more options' menu button
205 cy.get('[data-cy=collection-files-panel-options-btn]')
207 cy.get('[data-cy=context-menu]')
208 .should('contain', 'Select all')
210 cy.get('[data-cy=collection-files-panel-options-btn]')
212 cy.get('[data-cy=context-menu]')
213 .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
214 cy.get('body').click(); // Collapse the menu
220 it('renames a file using valid names', function () {
221 function eachPair(lst, func){
222 for(var i=0; i < lst.length - 1; i++){
223 func(lst[i], lst[i + 1])
226 // Creates the collection using the admin token so we can set up
227 // a bogus manifest text without block signatures.
228 cy.createCollection(adminUser.token, {
229 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
230 owner_uuid: activeUser.user.uuid,
231 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
233 .as('testCollection').then(function () {
234 cy.loginAs(activeUser);
235 cy.goToPath(`/collections/${this.testCollection.uuid}`);
238 'bar', // initial name already set
245 'some name with whitespaces',
247 'is this name legal? I hope it is',
255 "G%C3%BCnter's%20file.pdf",
257 'bar' // make sure we can go back to the original name as a last step
259 eachPair(names, (from, to) => {
260 cy.get('[data-cy=collection-files-panel]')
261 .contains(`${from}`).rightclick();
262 cy.get('[data-cy=context-menu]')
265 cy.get('[data-cy=form-dialog]')
266 .should('contain', 'Rename')
269 .type('{selectall}{backspace}')
270 .type(to, { parseSpecialCharSequences: false });
272 cy.get('[data-cy=form-submit-btn]').click();
273 cy.get('[data-cy=collection-files-panel]')
274 .should('not.contain', `${from}`)
275 .and('contain', `${to}`);
280 it('renames a file to a different directory', function () {
281 // Creates the collection using the admin token so we can set up
282 // a bogus manifest text without block signatures.
283 cy.createCollection(adminUser.token, {
284 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
285 owner_uuid: activeUser.user.uuid,
286 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
288 .as('testCollection').then(function () {
289 cy.loginAs(activeUser);
290 cy.goToPath(`/collections/${this.testCollection.uuid}`);
292 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
293 cy.get('[data-cy=collection-files-panel]')
294 .contains('bar').rightclick({force: true});
295 cy.get('[data-cy=context-menu]')
298 cy.get('[data-cy=form-dialog]')
299 .should('contain', 'Rename')
301 cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
303 cy.get('[data-cy=form-submit-btn]').click();
304 cy.get('[data-cy=collection-files-panel]')
305 .should('not.contain', 'bar')
306 .and('contain', subdir);
307 // Look for the "arrow icon" and expand the "subdir" directory.
308 cy.get('[data-cy=virtual-file-tree] > div > i').click();
309 // Rename 'subdir/foo' to 'foo'
310 cy.get('[data-cy=collection-files-panel]')
311 .contains('foo').rightclick();
312 cy.get('[data-cy=context-menu]')
315 cy.get('[data-cy=form-dialog]')
316 .should('contain', 'Rename')
319 .should('have.value', `${subdir}/foo`)
320 .type(`{selectall}{backspace}bar`);
322 cy.get('[data-cy=form-submit-btn]').click();
323 cy.get('[data-cy=collection-files-panel]')
324 .should('contain', subdir) // empty dir kept
325 .and('contain', 'bar');
327 cy.get('[data-cy=collection-files-panel]')
328 .contains(subdir).rightclick();
329 cy.get('[data-cy=context-menu]')
332 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
337 it('tries to rename a file with illegal names', function () {
338 // Creates the collection using the admin token so we can set up
339 // a bogus manifest text without block signatures.
340 cy.createCollection(adminUser.token, {
341 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
342 owner_uuid: activeUser.user.uuid,
343 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
345 .as('testCollection').then(function () {
346 cy.loginAs(activeUser);
347 cy.goToPath(`/collections/${this.testCollection.uuid}`);
349 const illegalNamesFromUI = [
350 ['.', "Name cannot be '.' or '..'"],
351 ['..', "Name cannot be '.' or '..'"],
352 ['', 'This field is required'],
353 [' ', 'Leading/trailing whitespaces not allowed'],
354 [' foo', 'Leading/trailing whitespaces not allowed'],
355 ['foo ', 'Leading/trailing whitespaces not allowed'],
356 ['//foo', 'Empty dir name not allowed']
358 illegalNamesFromUI.forEach(([name, errMsg]) => {
359 cy.get('[data-cy=collection-files-panel]')
360 .contains('bar').rightclick();
361 cy.get('[data-cy=context-menu]')
364 cy.get('[data-cy=form-dialog]')
365 .should('contain', 'Rename')
367 cy.get('input').type(`{selectall}{backspace}${name}`);
369 cy.get('[data-cy=form-dialog]')
370 .should('contain', 'Rename')
372 cy.contains(`${errMsg}`);
374 cy.get('[data-cy=form-cancel-btn]').click();
379 it('can correctly display old versions', function () {
380 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
382 let oldVersionUuid = '';
383 // Make sure no other collections with this name exist
384 cy.doRequest('GET', '/arvados/v1/collections', null, {
385 filters: `[["name", "=", "${colName}"]]`,
386 include_old_versions: true
388 .its('body.items').as('collections')
390 expect(this.collections).to.be.empty;
392 // Creates the collection using the admin token so we can set up
393 // a bogus manifest text without block signatures.
394 cy.createCollection(adminUser.token, {
396 owner_uuid: activeUser.user.uuid,
397 preserve_version: true,
398 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
400 .as('originalVersion').then(function () {
401 // Change the file name to create a new version.
402 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
403 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
405 colUuid = this.originalVersion.uuid;
407 // Confirm that there are 2 versions of the collection
408 cy.doRequest('GET', '/arvados/v1/collections', null, {
409 filters: `[["name", "=", "${colName}"]]`,
410 include_old_versions: true
412 .its('body.items').as('collections')
414 expect(this.collections).to.have.lengthOf(2);
415 this.collections.map(function (aCollection) {
416 expect(aCollection.current_version_uuid).to.equal(colUuid);
417 if (aCollection.uuid !== aCollection.current_version_uuid) {
418 oldVersionUuid = aCollection.uuid;
421 // Check the old version displays as what it is.
422 cy.loginAs(activeUser)
423 cy.goToPath(`/collections/${oldVersionUuid}`);
425 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
426 cy.get('[data-cy=read-only-icon]').should('exist');
427 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
428 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
432 it('views & edits storage classes data', function () {
433 const colName= `Test Collection ${Math.floor(Math.random() * 999999)}`;
434 cy.createCollection(adminUser.token, {
436 owner_uuid: activeUser.user.uuid,
437 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
438 }).as('collection').then(function () {
439 expect(this.collection.storage_classes_desired).to.deep.equal(['default'])
441 cy.loginAs(activeUser)
442 cy.goToPath(`/collections/${this.collection.uuid}`);
444 // Initial check: it should show the 'default' storage class
445 cy.get('[data-cy=collection-info-panel]')
446 .should('contain', 'Storage classes')
447 .and('contain', 'default')
448 .and('not.contain', 'foo')
449 .and('not.contain', 'bar');
450 // Edit collection: add storage class 'foo'
451 cy.get('[data-cy=collection-panel-options-btn]').click();
452 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
453 cy.get('[data-cy=form-dialog]')
454 .should('contain', 'Edit Collection')
455 .and('contain', 'Storage classes')
456 .and('contain', 'default')
457 .and('contain', 'foo')
458 .and('contain', 'bar')
460 cy.get('[data-cy=checkbox-foo]').click();
462 cy.get('[data-cy=form-submit-btn]').click();
463 cy.get('[data-cy=collection-info-panel]')
464 .should('contain', 'default')
465 .and('contain', 'foo')
466 .and('not.contain', 'bar');
467 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
468 .its('body').as('updatedCollection')
470 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['default', 'foo']);
472 // Edit collection: remove storage class 'default'
473 cy.get('[data-cy=collection-panel-options-btn]').click();
474 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
475 cy.get('[data-cy=form-dialog]')
476 .should('contain', 'Edit Collection')
477 .and('contain', 'Storage classes')
478 .and('contain', 'default')
479 .and('contain', 'foo')
480 .and('contain', 'bar')
482 cy.get('[data-cy=checkbox-default]').click();
484 cy.get('[data-cy=form-submit-btn]').click();
485 cy.get('[data-cy=collection-info-panel]')
486 .should('not.contain', 'default')
487 .and('contain', 'foo')
488 .and('not.contain', 'bar');
489 cy.doRequest('GET', `/arvados/v1/collections/${this.collection.uuid}`)
490 .its('body').as('updatedCollection')
492 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(['foo']);
497 it('uses the collection version browser to view a previous version', function () {
498 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
500 // Creates the collection using the admin token so we can set up
501 // a bogus manifest text without block signatures.
502 cy.createCollection(adminUser.token, {
504 owner_uuid: activeUser.user.uuid,
505 preserve_version: true,
506 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
508 .as('collection').then(function () {
509 // Visit collection, check basic information
510 cy.loginAs(activeUser)
511 cy.goToPath(`/collections/${this.collection.uuid}`);
513 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
514 cy.get('[data-cy=read-only-icon]').should('not.exist');
515 cy.get('[data-cy=collection-version-number]').should('contain', '1');
516 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
517 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
519 // Modify collection, expect version number change
520 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
521 cy.get('[data-cy=context-menu]').contains('Remove').click();
522 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
523 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
524 cy.get('[data-cy=collection-version-number]').should('contain', '2');
525 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
527 // Click on version number, check version browser. Click on past version.
528 cy.get('[data-cy=collection-version-browser]').should('not.exist');
529 cy.get('[data-cy=collection-version-number]').contains('2').click();
530 cy.get('[data-cy=collection-version-browser]')
531 .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
533 // Version 1: 6 bytes in size
534 cy.get('[data-cy=collection-version-browser-select-1]')
535 .should('contain', '1')
536 .and('contain', '6 B')
537 .and('contain', adminUser.user.uuid);
538 // Version 2: 3 bytes in size (one file removed)
539 cy.get('[data-cy=collection-version-browser-select-2]')
540 .should('contain', '2')
541 .and('contain', '3 B')
542 .and('contain', activeUser.user.full_name);
543 cy.get('[data-cy=collection-version-browser-select-3]')
544 .should('not.exist');
545 cy.get('[data-cy=collection-version-browser-select-1]')
548 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
549 cy.get('[data-cy=read-only-icon]').should('exist');
550 cy.get('[data-cy=collection-version-number]').should('contain', '1');
551 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
552 cy.get('[data-cy=collection-files-panel]')
553 .should('contain', 'foo').and('contain', 'bar');
555 // Check that only old collection action are available on context menu
556 cy.get('[data-cy=collection-panel-options-btn]').click();
557 cy.get('[data-cy=context-menu]')
558 .should('contain', 'Restore version')
559 .and('not.contain', 'Add to favorites');
560 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
562 // Click on "head version" link, confirm that it's the latest version.
563 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
564 cy.get('[data-cy=collection-info-panel]')
565 .should('not.contain', 'This is an old version');
566 cy.get('[data-cy=read-only-icon]').should('not.exist');
567 cy.get('[data-cy=collection-version-number]').should('contain', '2');
568 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
569 cy.get('[data-cy=collection-files-panel]').
570 should('not.contain', 'foo').and('contain', 'bar');
572 // Check that old collection action isn't available on context menu
573 cy.get('[data-cy=collection-panel-options-btn]').click()
574 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
575 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
577 // Make another change, confirm new version.
578 cy.get('[data-cy=collection-panel-options-btn]').click();
579 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
580 cy.get('[data-cy=form-dialog]')
581 .should('contain', 'Edit Collection')
584 cy.get('input').first().type(' renamed');
586 cy.get('[data-cy=form-submit-btn]').click();
587 cy.get('[data-cy=collection-info-panel]')
588 .should('not.contain', 'This is an old version');
589 cy.get('[data-cy=read-only-icon]').should('not.exist');
590 cy.get('[data-cy=collection-version-number]').should('contain', '3');
591 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
592 cy.get('[data-cy=collection-files-panel]')
593 .should('not.contain', 'foo').and('contain', 'bar');
594 cy.get('[data-cy=collection-version-browser-select-3]')
595 .should('contain', '3').and('contain', '3 B');
597 // Check context menus on version browser
598 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
599 cy.get('[data-cy=context-menu]')
600 .should('contain', 'Add to favorites')
601 .and('contain', 'Make a copy')
602 .and('contain', 'Edit collection');
603 cy.get('body').click();
604 // (and now an old version...)
605 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
606 cy.get('[data-cy=context-menu]')
607 .should('not.contain', 'Add to favorites')
608 .and('contain', 'Make a copy')
609 .and('not.contain', 'Edit collection');
610 cy.get('body').click();
612 // Restore first version
613 cy.get('[data-cy=collection-version-browser]').within(() => {
614 cy.get('[data-cy=collection-version-browser-select-1]').click();
616 cy.get('[data-cy=collection-panel-options-btn]').click()
617 cy.get('[data-cy=context-menu]').contains('Restore version').click();
618 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
619 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
620 cy.get('[data-cy=collection-info-panel]')
621 .should('not.contain', 'This is an old version');
622 cy.get('[data-cy=collection-version-number]').should('contain', '4');
623 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
624 cy.get('[data-cy=collection-files-panel]')
625 .should('contain', 'foo').and('contain', 'bar');
629 it('creates new collection on home project', function () {
630 cy.loginAs(activeUser);
631 cy.goToPath(`/projects/${activeUser.user.uuid}`);
632 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
633 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
634 // Create new collection
635 cy.get('[data-cy=side-panel-button]').click();
636 cy.get('[data-cy=side-panel-new-collection]').click();
637 // Name between brackets tests bugfix #17582
638 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
639 cy.get('[data-cy=form-dialog]')
640 .should('contain', 'New collection')
641 .and('contain', 'Storage classes')
642 .and('contain', 'default')
643 .and('contain', 'foo')
644 .and('contain', 'bar')
646 cy.get('[data-cy=parent-field]').within(() => {
647 cy.get('input').should('have.value', 'Home project');
649 cy.get('[data-cy=name-field]').within(() => {
650 cy.get('input').type(collName);
652 cy.get('[data-cy=checkbox-foo]').click();
654 cy.get('[data-cy=form-submit-btn]').click();
655 // Confirm that the user was taken to the newly created thing
656 cy.get('[data-cy=form-dialog]').should('not.exist');
657 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
658 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
659 cy.get('[data-cy=collection-info-panel]')
660 .should('contain', 'default')
661 .and('contain', 'foo')
662 .and('not.contain', 'bar');
665 it('shows responsible person for collection if available', () => {
666 cy.createCollection(adminUser.token, {
667 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
668 owner_uuid: activeUser.user.uuid,
669 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
671 .as('testCollection1');
673 cy.createCollection(adminUser.token, {
674 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
675 owner_uuid: adminUser.user.uuid,
676 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
678 .as('testCollection2').then(function (testCollection2) {
679 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
682 cy.getAll('@testCollection1', '@testCollection2')
683 .then(function ([testCollection1, testCollection2]) {
684 cy.loginAs(activeUser);
686 cy.goToPath(`/collections/${testCollection1.uuid}`);
687 cy.get('[data-cy=responsible-person-wrapper]')
688 .contains(activeUser.user.uuid);
690 cy.goToPath(`/collections/${testCollection2.uuid}`);
691 cy.get('[data-cy=responsible-person-wrapper]')
692 .contains(adminUser.user.uuid);