16647: Added key search from config and tests
[arvados-workbench2.git] / cypress / integration / collection.spec.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 const path = require('path');
6
7 describe('Collection panel tests', function () {
8     let activeUser;
9     let adminUser;
10     let downloadsFolder;
11
12     before(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;
20             }
21             );
22         cy.getUser('collectionuser1', 'Collection', 'User', false, true)
23             .as('activeUser').then(function () {
24                 activeUser = this.activeUser;
25             }
26             );
27         downloadsFolder = Cypress.config('downloadsFolder');
28     });
29
30     beforeEach(function () {
31         cy.clearCookies();
32         cy.clearLocalStorage();
33     });
34
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"
40         })
41         .as('testCollection').then(function (testCollection) {
42             cy.loginAs(activeUser);
43             cy.goToPath(`/collections/${testCollection.uuid}`);
44
45             cy.get('[data-cy=collection-panel-options-btn]').click();
46             cy.get('[data-cy=context-menu]').contains('Open as network folder or S3 bucket').click();
47             cy.get('[data-cy=download-button').click();
48
49             const filename = path.join(downloadsFolder, `${testCollection.name}.duck`);
50
51             cy.readFile(filename, { timeout: 15000 })
52                 .then((body) => {
53                     const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find('dict')[0].children);
54                     const map = {};
55                     let i, j = 2;
56
57                     for (i=0; i < childrenCollection.length; i += j) {
58                       map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
59                     }
60
61                     cy.get('#simple-tabpanel-0').find('a')
62                         .then((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);
69                             if (map['Path']) {
70                                 expect(map['Path']).to.equal(`/c=${testCollection.uuid}`);
71                             }
72                         });
73                 })
74                 .then(() => cy.task('clearDownload', { filename }));
75         });
76     });
77
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"
83         })
84             .as('testCollection').then(function () {
85                 cy.loginAs(activeUser);
86                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
87
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');
92                     });
93                     cy.get('[data-cy=property-field-value]').within(() => {
94                         cy.get('input').type('Magenta');
95                     });
96                     cy.root().submit();
97                 });
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')
105                     .then(function () {
106                         expect(this.collection.properties.IDTAGCOLORS).to.equal('IDVALCOLORS3');
107                     });
108             });
109     });
110
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`
130                 })
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
138                         })
139                         cy.goToPath(`/collections/${this.testCollection.uuid}`);
140
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]')
151                             .click()
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');
166                                 });
167                                 cy.get('[data-cy=property-field-value]').within(() => {
168                                     cy.get('input').type('anotherValue');
169                                 });
170                                 cy.root().submit();
171                             })
172                             cy.get('[data-cy=collection-properties-panel]')
173                                 .should('contain', 'anotherKey')
174                                 .and('contain', 'anotherValue')
175                         } else {
176                             // Properties form shouldn't be displayed.
177                             cy.get('[data-cy=resource-properties-form]').should('not.exist');
178                         }
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);
182                             if (isWritable) {
183                                 cy.get('[data-cy=upload-button]')
184                                     .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
185                             }
186                         });
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', 'Open in new tab')
193                             .and('contain', 'Copy to clipboard')
194                             .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
195                             .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
196                         cy.get('body').click(); // Collapse the menu
197                         cy.get('[data-cy=collection-files-panel]')
198                             .contains(subDirName).rightclick({ force: true });
199                         cy.get('[data-cy=context-menu]')
200                             .should('not.contain', 'Download')
201                             .and('contain', 'Open in new tab')
202                             .and('contain', 'Copy to clipboard')
203                             .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
204                             .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
205                         cy.get('body').click(); // Collapse the menu
206                         // Hamburger 'more options' menu button
207                         cy.get('[data-cy=collection-files-panel-options-btn]')
208                             .click()
209                         cy.get('[data-cy=context-menu]')
210                             .should('contain', 'Select all')
211                             .click()
212                         cy.get('[data-cy=collection-files-panel-options-btn]')
213                             .click()
214                         cy.get('[data-cy=context-menu]')
215                             .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
216                         cy.get('body').click(); // Collapse the menu
217                     })
218             })
219         })
220     })
221
222     it('renames a file using valid names', function () {
223         function eachPair(lst, func){
224             for(var i=0; i < lst.length - 1; i++){
225                 func(lst[i], lst[i + 1])
226             }
227         }
228         // Creates the collection using the admin token so we can set up
229         // a bogus manifest text without block signatures.
230         cy.createCollection(adminUser.token, {
231             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
232             owner_uuid: activeUser.user.uuid,
233             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
234         })
235             .as('testCollection').then(function () {
236                 cy.loginAs(activeUser);
237                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
238
239                 const names = [
240                     'bar', // initial name already set
241                     '&',
242                     'foo',
243                     '&amp;',
244                     'I ❤️ ⛵️',
245                     '...',
246                     '#..',
247                     'some name with whitespaces',
248                     'some name with #2',
249                     'is this name legal? I hope it is',
250                     'some_file.pdf#',
251                     'some_file.pdf?',
252                     '?some_file.pdf',
253                     'some%file.pdf',
254                     'some%2Ffile.pdf',
255                     'some%22file.pdf',
256                     'some%20file.pdf',
257                     "G%C3%BCnter's%20file.pdf",
258                     'table%&?*2',
259                     'bar' // make sure we can go back to the original name as a last step
260                 ];
261                 eachPair(names, (from, to) => {
262                     cy.get('[data-cy=collection-files-panel]')
263                         .contains(`${from}`).rightclick();
264                     cy.get('[data-cy=context-menu]')
265                         .contains('Rename')
266                         .click();
267                     cy.get('[data-cy=form-dialog]')
268                         .should('contain', 'Rename')
269                         .within(() => {
270                             cy.get('input').type(`{selectall}{backspace}${to}`);
271                         });
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}`);
276                 })
277             });
278     });
279
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"
287         })
288             .as('testCollection').then(function () {
289                 cy.loginAs(activeUser);
290                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
291
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]')
296                         .contains('Rename')
297                         .click();
298                     cy.get('[data-cy=form-dialog]')
299                         .should('contain', 'Rename')
300                         .within(() => {
301                             cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
302                         });
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]')
313                         .contains('Rename')
314                         .click();
315                     cy.get('[data-cy=form-dialog]')
316                         .should('contain', 'Rename')
317                         .within(() => {
318                             cy.get('input')
319                                 .should('have.value', `${subdir}/foo`)
320                                 .type(`{selectall}{backspace}bar`);
321                         });
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');
326
327                     cy.get('[data-cy=collection-files-panel]')
328                         .contains(subdir).rightclick();
329                     cy.get('[data-cy=context-menu]')
330                         .contains('Remove')
331                         .click();
332                     cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
333                 });
334             });
335     });
336
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"
344         })
345             .as('testCollection').then(function () {
346                 cy.loginAs(activeUser);
347                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
348
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']
357                 ]
358                 illegalNamesFromUI.forEach(([name, errMsg]) => {
359                     cy.get('[data-cy=collection-files-panel]')
360                         .contains('bar').rightclick();
361                     cy.get('[data-cy=context-menu]')
362                         .contains('Rename')
363                         .click();
364                     cy.get('[data-cy=form-dialog]')
365                         .should('contain', 'Rename')
366                         .within(() => {
367                             cy.get('input').type(`{selectall}{backspace}${name}`);
368                         });
369                     cy.get('[data-cy=form-dialog]')
370                         .should('contain', 'Rename')
371                         .within(() => {
372                             cy.contains(`${errMsg}`);
373                         });
374                     cy.get('[data-cy=form-cancel-btn]').click();
375                 })
376             });
377     });
378
379     it('can correctly display old versions', function () {
380         const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
381         let colUuid = '';
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
387         })
388             .its('body.items').as('collections')
389             .then(function () {
390                 expect(this.collections).to.be.empty;
391             });
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, {
395             name: colName,
396             owner_uuid: activeUser.user.uuid,
397             preserve_version: true,
398             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
399         })
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"
404                 })
405                 colUuid = this.originalVersion.uuid;
406             });
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
411         })
412             .its('body.items').as('collections')
413             .then(function () {
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;
419                     }
420                 });
421                 // Check the old version displays as what it is.
422                 cy.loginAs(activeUser)
423                 cy.goToPath(`/collections/${oldVersionUuid}`);
424
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');
429             });
430     });
431
432     it('uses the collection version browser to view a previous version', function () {
433         const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
434
435         // Creates the collection using the admin token so we can set up
436         // a bogus manifest text without block signatures.
437         cy.createCollection(adminUser.token, {
438             name: colName,
439             owner_uuid: activeUser.user.uuid,
440             preserve_version: true,
441             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
442         })
443             .as('collection').then(function () {
444                 // Visit collection, check basic information
445                 cy.loginAs(activeUser)
446                 cy.goToPath(`/collections/${this.collection.uuid}`);
447
448                 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
449                 cy.get('[data-cy=read-only-icon]').should('not.exist');
450                 cy.get('[data-cy=collection-version-number]').should('contain', '1');
451                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
452                 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
453
454                 // Modify collection, expect version number change
455                 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
456                 cy.get('[data-cy=context-menu]').contains('Remove').click();
457                 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
458                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
459                 cy.get('[data-cy=collection-version-number]').should('contain', '2');
460                 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
461
462                 // Click on version number, check version browser. Click on past version.
463                 cy.get('[data-cy=collection-version-browser]').should('not.exist');
464                 cy.get('[data-cy=collection-version-number]').contains('2').click();
465                 cy.get('[data-cy=collection-version-browser]')
466                     .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
467                     .within(() => {
468                         // Version 1: 6 bytes in size
469                         cy.get('[data-cy=collection-version-browser-select-1]')
470                             .should('contain', '1').and('contain', '6 B');
471                         // Version 2: 3 bytes in size (one file removed)
472                         cy.get('[data-cy=collection-version-browser-select-2]')
473                             .should('contain', '2').and('contain', '3 B');
474                         cy.get('[data-cy=collection-version-browser-select-3]')
475                             .should('not.exist');
476                         cy.get('[data-cy=collection-version-browser-select-1]')
477                             .click();
478                     });
479                 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
480                 cy.get('[data-cy=read-only-icon]').should('exist');
481                 cy.get('[data-cy=collection-version-number]').should('contain', '1');
482                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
483                 cy.get('[data-cy=collection-files-panel]')
484                     .should('contain', 'foo').and('contain', 'bar');
485
486                 // Check that only old collection action are available on context menu
487                 cy.get('[data-cy=collection-panel-options-btn]').click();
488                 cy.get('[data-cy=context-menu]')
489                     .should('contain', 'Restore version')
490                     .and('not.contain', 'Add to favorites');
491                 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
492
493                 // Click on "head version" link, confirm that it's the latest version.
494                 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
495                 cy.get('[data-cy=collection-info-panel]')
496                     .should('not.contain', 'This is an old version');
497                 cy.get('[data-cy=read-only-icon]').should('not.exist');
498                 cy.get('[data-cy=collection-version-number]').should('contain', '2');
499                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
500                 cy.get('[data-cy=collection-files-panel]').
501                     should('not.contain', 'foo').and('contain', 'bar');
502
503                 // Check that old collection action isn't available on context menu
504                 cy.get('[data-cy=collection-panel-options-btn]').click()
505                 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
506                 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
507
508                 // Make another change, confirm new version.
509                 cy.get('[data-cy=collection-panel-options-btn]').click();
510                 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
511                 cy.get('[data-cy=form-dialog]')
512                     .should('contain', 'Edit Collection')
513                     .within(() => {
514                         // appends some text
515                         cy.get('input').first().type(' renamed');
516                     });
517                 cy.get('[data-cy=form-submit-btn]').click();
518                 cy.get('[data-cy=collection-info-panel]')
519                     .should('not.contain', 'This is an old version');
520                 cy.get('[data-cy=read-only-icon]').should('not.exist');
521                 cy.get('[data-cy=collection-version-number]').should('contain', '3');
522                 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
523                 cy.get('[data-cy=collection-files-panel]')
524                     .should('not.contain', 'foo').and('contain', 'bar');
525                 cy.get('[data-cy=collection-version-browser-select-3]')
526                     .should('contain', '3').and('contain', '3 B');
527
528                 // Check context menus on version browser
529                 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
530                 cy.get('[data-cy=context-menu]')
531                     .should('contain', 'Add to favorites')
532                     .and('contain', 'Make a copy')
533                     .and('contain', 'Edit collection');
534                 cy.get('body').click();
535                 // (and now an old version...)
536                 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
537                 cy.get('[data-cy=context-menu]')
538                     .should('not.contain', 'Add to favorites')
539                     .and('contain', 'Make a copy')
540                     .and('not.contain', 'Edit collection');
541                 cy.get('body').click();
542
543                 // Restore first version
544                 cy.get('[data-cy=collection-version-browser]').within(() => {
545                     cy.get('[data-cy=collection-version-browser-select-1]').click();
546                 });
547                 cy.get('[data-cy=collection-panel-options-btn]').click()
548                 cy.get('[data-cy=context-menu]').contains('Restore version').click();
549                 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
550                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
551                 cy.get('[data-cy=collection-info-panel]')
552                     .should('not.contain', 'This is an old version');
553                 cy.get('[data-cy=collection-version-number]').should('contain', '4');
554                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
555                 cy.get('[data-cy=collection-files-panel]')
556                     .should('contain', 'foo').and('contain', 'bar');
557             });
558     });
559
560     it('creates new collection on home project', function () {
561         cy.loginAs(activeUser);
562         cy.goToPath(`/projects/${activeUser.user.uuid}`);
563         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
564         cy.get('[data-cy=breadcrumb-last]').should('not.exist');
565         // Create new collection
566         cy.get('[data-cy=side-panel-button]').click();
567         cy.get('[data-cy=side-panel-new-collection]').click();
568         const collName = `Test collection (${Math.floor(999999 * Math.random())})`;
569         cy.get('[data-cy=form-dialog]')
570             .should('contain', 'New collection')
571             .within(() => {
572                 cy.get('[data-cy=parent-field]').within(() => {
573                     cy.get('input').should('have.value', 'Home project');
574                 })
575                 cy.get('[data-cy=name-field]').within(() => {
576                     cy.get('input').type(collName);
577                 })
578             })
579         cy.get('[data-cy=form-submit-btn]').click();
580         // Confirm that the user was taken to the newly created thing
581         cy.get('[data-cy=form-dialog]').should('not.exist');
582         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
583         cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
584     });
585
586     it.only('shows responsible person for collection if available', () => {
587         cy.createCollection(adminUser.token, {
588             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
589             owner_uuid: activeUser.user.uuid,
590             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
591         })
592             .as('testCollection1');
593
594         cy.createCollection(adminUser.token, {
595             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
596             owner_uuid: adminUser.user.uuid,
597             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
598         })
599             .as('testCollection2').then(function (testCollection2) {
600                 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
601             });
602
603         cy.getAll('@testCollection1', '@testCollection2')
604             .then(function ([testCollection1, testCollection2]) {
605                 cy.loginAs(activeUser);
606
607                 cy.goToPath(`/collections/${testCollection1.uuid}`);
608                 cy.get('[data-cy=responsible-person-wrapper]')
609                     .contains(activeUser.user.uuid);
610
611                 cy.goToPath(`/collections/${testCollection2.uuid}`);
612                 cy.get('[data-cy=responsible-person-wrapper]')
613                     .contains(adminUser.user.uuid);
614             });
615     });
616 })