Merge branch '17289-dir-download-action-removal'
[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).to.deep.equal(
107                             { IDTAGCOLORS: 'IDVALCOLORS3' });
108                     });
109             });
110     });
111
112     it('shows collection by URL', function () {
113         cy.loginAs(activeUser);
114         [true, false].map(function (isWritable) {
115             // Using different file names to avoid test flakyness: the second iteration
116             // on this loop may pass an assertion from the first iteration by looking
117             // for the same file name.
118             const fileName = isWritable ? 'bar' : 'foo';
119             const subDirName = 'subdir';
120             cy.createGroup(adminUser.token, {
121                 name: 'Shared project',
122                 group_class: 'project',
123             }).as('sharedGroup').then(function () {
124                 // Creates the collection using the admin token so we can set up
125                 // a bogus manifest text without block signatures.
126                 cy.createCollection(adminUser.token, {
127                     name: 'Test collection',
128                     owner_uuid: this.sharedGroup.uuid,
129                     properties: { someKey: 'someValue' },
130                     manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`
131                 })
132                     .as('testCollection').then(function () {
133                         // Share the group with active user.
134                         cy.createLink(adminUser.token, {
135                             name: isWritable ? 'can_write' : 'can_read',
136                             link_class: 'permission',
137                             head_uuid: this.sharedGroup.uuid,
138                             tail_uuid: activeUser.user.uuid
139                         })
140                         cy.goToPath(`/collections/${this.testCollection.uuid}`);
141
142                         // Check that name & uuid are correct.
143                         cy.get('[data-cy=collection-info-panel]')
144                             .should('contain', this.testCollection.name)
145                             .and('contain', this.testCollection.uuid)
146                             .and('not.contain', 'This is an old version');
147                         // Check for the read-only icon
148                         cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
149                         // Check that both read and write operations are available on
150                         // the 'More options' menu.
151                         cy.get('[data-cy=collection-panel-options-btn]')
152                             .click()
153                         cy.get('[data-cy=context-menu]')
154                             .should('contain', 'Add to favorites')
155                             .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
156                         cy.get('body').click(); // Collapse the menu avoiding details panel expansion
157                         cy.get('[data-cy=collection-properties-panel]')
158                             .should('contain', 'someKey')
159                             .and('contain', 'someValue')
160                             .and('not.contain', 'anotherKey')
161                             .and('not.contain', 'anotherValue')
162                         if (isWritable === true) {
163                             // Check that properties can be added.
164                             cy.get('[data-cy=resource-properties-form]').within(() => {
165                                 cy.get('[data-cy=property-field-key]').within(() => {
166                                     cy.get('input').type('anotherKey');
167                                 });
168                                 cy.get('[data-cy=property-field-value]').within(() => {
169                                     cy.get('input').type('anotherValue');
170                                 });
171                                 cy.root().submit();
172                             })
173                             cy.get('[data-cy=collection-properties-panel]')
174                                 .should('contain', 'anotherKey')
175                                 .and('contain', 'anotherValue')
176                         } else {
177                             // Properties form shouldn't be displayed.
178                             cy.get('[data-cy=resource-properties-form]').should('not.exist');
179                         }
180                         // Check that the file listing show both read & write operations
181                         cy.get('[data-cy=collection-files-panel]').within(() => {
182                             cy.root().should('contain', fileName);
183                             if (isWritable) {
184                                 cy.get('[data-cy=upload-button]')
185                                     .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
186                             }
187                         });
188                         // Test context menus
189                         cy.get('[data-cy=collection-files-panel]')
190                             .contains(fileName).rightclick({ force: true });
191                         cy.get('[data-cy=context-menu]')
192                             .should('contain', 'Download')
193                             .and('contain', 'Open in new tab')
194                             .and('contain', 'Copy to clipboard')
195                             .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
196                             .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
197                         cy.get('body').click(); // Collapse the menu
198                         cy.get('[data-cy=collection-files-panel]')
199                             .contains(subDirName).rightclick({ force: true });
200                         cy.get('[data-cy=context-menu]')
201                             .should('not.contain', 'Download')
202                             .and('contain', 'Open in new tab')
203                             .and('contain', 'Copy to clipboard')
204                             .and(`${isWritable ? '' : 'not.'}contain`, 'Rename')
205                             .and(`${isWritable ? '' : 'not.'}contain`, 'Remove');
206                         cy.get('body').click(); // Collapse the menu
207                         // Hamburger 'more options' menu button
208                         cy.get('[data-cy=collection-files-panel-options-btn]')
209                             .click()
210                         cy.get('[data-cy=context-menu]')
211                             .should('contain', 'Select all')
212                             .click()
213                         cy.get('[data-cy=collection-files-panel-options-btn]')
214                             .click()
215                         cy.get('[data-cy=context-menu]')
216                             .should(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
217                         cy.get('body').click(); // Collapse the menu
218                     })
219             })
220         })
221     })
222
223     it('renames a file using valid names', function () {
224         function eachPair(lst, func){
225             for(var i=0; i < lst.length - 1; i++){
226                 func(lst[i], lst[i + 1])
227             }
228         }
229         // Creates the collection using the admin token so we can set up
230         // a bogus manifest text without block signatures.
231         cy.createCollection(adminUser.token, {
232             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
233             owner_uuid: activeUser.user.uuid,
234             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
235         })
236             .as('testCollection').then(function () {
237                 cy.loginAs(activeUser);
238                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
239
240                 const names = [
241                     'bar', // initial name already set
242                     '&',
243                     'foo',
244                     '&amp;',
245                     'I ❤️ ⛵️',
246                     '...',
247                     '#..',
248                     'some name with whitespaces',
249                     'some name with #2',
250                     'is this name legal? I hope it is',
251                     'some_file.pdf#',
252                     'some_file.pdf?',
253                     '?some_file.pdf',
254                     'some%file.pdf',
255                     'some%2Ffile.pdf',
256                     'some%22file.pdf',
257                     'some%20file.pdf',
258                     "G%C3%BCnter's%20file.pdf",
259                     'table%&?*2',
260                     'bar' // make sure we can go back to the original name as a last step
261                 ];
262                 eachPair(names, (from, to) => {
263                     cy.get('[data-cy=collection-files-panel]')
264                         .contains(`${from}`).rightclick();
265                     cy.get('[data-cy=context-menu]')
266                         .contains('Rename')
267                         .click();
268                     cy.get('[data-cy=form-dialog]')
269                         .should('contain', 'Rename')
270                         .within(() => {
271                             cy.get('input').type(`{selectall}{backspace}${to}`);
272                         });
273                     cy.get('[data-cy=form-submit-btn]').click();
274                     cy.get('[data-cy=collection-files-panel]')
275                         .should('not.contain', `${from}`)
276                         .and('contain', `${to}`);
277                 })
278             });
279     });
280
281     it('renames a file to a different directory', function () {
282         // Creates the collection using the admin token so we can set up
283         // a bogus manifest text without block signatures.
284         cy.createCollection(adminUser.token, {
285             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
286             owner_uuid: activeUser.user.uuid,
287             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
288         })
289             .as('testCollection').then(function () {
290                 cy.loginAs(activeUser);
291                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
292
293                 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
294                     cy.get('[data-cy=collection-files-panel]')
295                         .contains('bar').rightclick({force: true});
296                     cy.get('[data-cy=context-menu]')
297                         .contains('Rename')
298                         .click();
299                     cy.get('[data-cy=form-dialog]')
300                         .should('contain', 'Rename')
301                         .within(() => {
302                             cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
303                         });
304                     cy.get('[data-cy=form-submit-btn]').click();
305                     cy.get('[data-cy=collection-files-panel]')
306                         .should('not.contain', 'bar')
307                         .and('contain', subdir);
308                     // Look for the "arrow icon" and expand the "subdir" directory.
309                     cy.get('[data-cy=virtual-file-tree] > div > i').click();
310                     // Rename 'subdir/foo' to 'foo'
311                     cy.get('[data-cy=collection-files-panel]')
312                         .contains('foo').rightclick();
313                     cy.get('[data-cy=context-menu]')
314                         .contains('Rename')
315                         .click();
316                     cy.get('[data-cy=form-dialog]')
317                         .should('contain', 'Rename')
318                         .within(() => {
319                             cy.get('input')
320                                 .should('have.value', `${subdir}/foo`)
321                                 .type(`{selectall}{backspace}bar`);
322                         });
323                     cy.get('[data-cy=form-submit-btn]').click();
324                     cy.get('[data-cy=collection-files-panel]')
325                         .should('contain', subdir) // empty dir kept
326                         .and('contain', 'bar');
327
328                     cy.get('[data-cy=collection-files-panel]')
329                         .contains(subdir).rightclick();
330                     cy.get('[data-cy=context-menu]')
331                         .contains('Remove')
332                         .click();
333                     cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
334                 });
335             });
336     });
337
338     it('tries to rename a file with illegal names', function () {
339         // Creates the collection using the admin token so we can set up
340         // a bogus manifest text without block signatures.
341         cy.createCollection(adminUser.token, {
342             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
343             owner_uuid: activeUser.user.uuid,
344             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
345         })
346             .as('testCollection').then(function () {
347                 cy.loginAs(activeUser);
348                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
349
350                 const illegalNamesFromUI = [
351                     ['.', "Name cannot be '.' or '..'"],
352                     ['..', "Name cannot be '.' or '..'"],
353                     ['', 'This field is required'],
354                     [' ', 'Leading/trailing whitespaces not allowed'],
355                     [' foo', 'Leading/trailing whitespaces not allowed'],
356                     ['foo ', 'Leading/trailing whitespaces not allowed'],
357                     ['//foo', 'Empty dir name not allowed']
358                 ]
359                 illegalNamesFromUI.forEach(([name, errMsg]) => {
360                     cy.get('[data-cy=collection-files-panel]')
361                         .contains('bar').rightclick();
362                     cy.get('[data-cy=context-menu]')
363                         .contains('Rename')
364                         .click();
365                     cy.get('[data-cy=form-dialog]')
366                         .should('contain', 'Rename')
367                         .within(() => {
368                             cy.get('input').type(`{selectall}{backspace}${name}`);
369                         });
370                     cy.get('[data-cy=form-dialog]')
371                         .should('contain', 'Rename')
372                         .within(() => {
373                             cy.contains(`${errMsg}`);
374                         });
375                     cy.get('[data-cy=form-cancel-btn]').click();
376                 })
377             });
378     });
379
380     it('can correctly display old versions', function () {
381         const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
382         let colUuid = '';
383         let oldVersionUuid = '';
384         // Make sure no other collections with this name exist
385         cy.doRequest('GET', '/arvados/v1/collections', null, {
386             filters: `[["name", "=", "${colName}"]]`,
387             include_old_versions: true
388         })
389             .its('body.items').as('collections')
390             .then(function () {
391                 expect(this.collections).to.be.empty;
392             });
393         // Creates the collection using the admin token so we can set up
394         // a bogus manifest text without block signatures.
395         cy.createCollection(adminUser.token, {
396             name: colName,
397             owner_uuid: activeUser.user.uuid,
398             preserve_version: true,
399             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
400         })
401             .as('originalVersion').then(function () {
402                 // Change the file name to create a new version.
403                 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
404                     manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
405                 })
406                 colUuid = this.originalVersion.uuid;
407             });
408         // Confirm that there are 2 versions of the collection
409         cy.doRequest('GET', '/arvados/v1/collections', null, {
410             filters: `[["name", "=", "${colName}"]]`,
411             include_old_versions: true
412         })
413             .its('body.items').as('collections')
414             .then(function () {
415                 expect(this.collections).to.have.lengthOf(2);
416                 this.collections.map(function (aCollection) {
417                     expect(aCollection.current_version_uuid).to.equal(colUuid);
418                     if (aCollection.uuid !== aCollection.current_version_uuid) {
419                         oldVersionUuid = aCollection.uuid;
420                     }
421                 });
422                 // Check the old version displays as what it is.
423                 cy.loginAs(activeUser)
424                 cy.goToPath(`/collections/${oldVersionUuid}`);
425
426                 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
427                 cy.get('[data-cy=read-only-icon]').should('exist');
428                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
429                 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
430             });
431     });
432
433     it('uses the collection version browser to view a previous version', function () {
434         const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
435
436         // Creates the collection using the admin token so we can set up
437         // a bogus manifest text without block signatures.
438         cy.createCollection(adminUser.token, {
439             name: colName,
440             owner_uuid: activeUser.user.uuid,
441             preserve_version: true,
442             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
443         })
444             .as('collection').then(function () {
445                 // Visit collection, check basic information
446                 cy.loginAs(activeUser)
447                 cy.goToPath(`/collections/${this.collection.uuid}`);
448
449                 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
450                 cy.get('[data-cy=read-only-icon]').should('not.exist');
451                 cy.get('[data-cy=collection-version-number]').should('contain', '1');
452                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
453                 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
454
455                 // Modify collection, expect version number change
456                 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
457                 cy.get('[data-cy=context-menu]').contains('Remove').click();
458                 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
459                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
460                 cy.get('[data-cy=collection-version-number]').should('contain', '2');
461                 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
462
463                 // Click on version number, check version browser. Click on past version.
464                 cy.get('[data-cy=collection-version-browser]').should('not.exist');
465                 cy.get('[data-cy=collection-version-number]').contains('2').click();
466                 cy.get('[data-cy=collection-version-browser]')
467                     .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
468                     .within(() => {
469                         // Version 1: 6 bytes in size
470                         cy.get('[data-cy=collection-version-browser-select-1]')
471                             .should('contain', '1').and('contain', '6 B');
472                         // Version 2: 3 bytes in size (one file removed)
473                         cy.get('[data-cy=collection-version-browser-select-2]')
474                             .should('contain', '2').and('contain', '3 B');
475                         cy.get('[data-cy=collection-version-browser-select-3]')
476                             .should('not.exist');
477                         cy.get('[data-cy=collection-version-browser-select-1]')
478                             .click();
479                     });
480                 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
481                 cy.get('[data-cy=read-only-icon]').should('exist');
482                 cy.get('[data-cy=collection-version-number]').should('contain', '1');
483                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
484                 cy.get('[data-cy=collection-files-panel]')
485                     .should('contain', 'foo').and('contain', 'bar');
486
487                 // Check that only old collection action are available on context menu
488                 cy.get('[data-cy=collection-panel-options-btn]').click();
489                 cy.get('[data-cy=context-menu]')
490                     .should('contain', 'Restore version')
491                     .and('not.contain', 'Add to favorites');
492                 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
493
494                 // Click on "head version" link, confirm that it's the latest version.
495                 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
496                 cy.get('[data-cy=collection-info-panel]')
497                     .should('not.contain', 'This is an old version');
498                 cy.get('[data-cy=read-only-icon]').should('not.exist');
499                 cy.get('[data-cy=collection-version-number]').should('contain', '2');
500                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
501                 cy.get('[data-cy=collection-files-panel]').
502                     should('not.contain', 'foo').and('contain', 'bar');
503
504                 // Check that old collection action isn't available on context menu
505                 cy.get('[data-cy=collection-panel-options-btn]').click()
506                 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
507                 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
508
509                 // Make another change, confirm new version.
510                 cy.get('[data-cy=collection-panel-options-btn]').click();
511                 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
512                 cy.get('[data-cy=form-dialog]')
513                     .should('contain', 'Edit Collection')
514                     .within(() => {
515                         // appends some text
516                         cy.get('input').first().type(' renamed');
517                     });
518                 cy.get('[data-cy=form-submit-btn]').click();
519                 cy.get('[data-cy=collection-info-panel]')
520                     .should('not.contain', 'This is an old version');
521                 cy.get('[data-cy=read-only-icon]').should('not.exist');
522                 cy.get('[data-cy=collection-version-number]').should('contain', '3');
523                 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
524                 cy.get('[data-cy=collection-files-panel]')
525                     .should('not.contain', 'foo').and('contain', 'bar');
526                 cy.get('[data-cy=collection-version-browser-select-3]')
527                     .should('contain', '3').and('contain', '3 B');
528
529                 // Check context menus on version browser
530                 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
531                 cy.get('[data-cy=context-menu]')
532                     .should('contain', 'Add to favorites')
533                     .and('contain', 'Make a copy')
534                     .and('contain', 'Edit collection');
535                 cy.get('body').click();
536                 // (and now an old version...)
537                 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
538                 cy.get('[data-cy=context-menu]')
539                     .should('not.contain', 'Add to favorites')
540                     .and('contain', 'Make a copy')
541                     .and('not.contain', 'Edit collection');
542                 cy.get('body').click();
543
544                 // Restore first version
545                 cy.get('[data-cy=collection-version-browser]').within(() => {
546                     cy.get('[data-cy=collection-version-browser-select-1]').click();
547                 });
548                 cy.get('[data-cy=collection-panel-options-btn]').click()
549                 cy.get('[data-cy=context-menu]').contains('Restore version').click();
550                 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
551                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
552                 cy.get('[data-cy=collection-info-panel]')
553                     .should('not.contain', 'This is an old version');
554                 cy.get('[data-cy=collection-version-number]').should('contain', '4');
555                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
556                 cy.get('[data-cy=collection-files-panel]')
557                     .should('contain', 'foo').and('contain', 'bar');
558             });
559     });
560
561     it('creates new collection on home project', function () {
562         cy.loginAs(activeUser);
563         cy.goToPath(`/projects/${activeUser.user.uuid}`);
564         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
565         cy.get('[data-cy=breadcrumb-last]').should('not.exist');
566         // Create new collection
567         cy.get('[data-cy=side-panel-button]').click();
568         cy.get('[data-cy=side-panel-new-collection]').click();
569         const collName = `Test collection (${Math.floor(999999 * Math.random())})`;
570         cy.get('[data-cy=form-dialog]')
571             .should('contain', 'New collection')
572             .within(() => {
573                 cy.get('[data-cy=parent-field]').within(() => {
574                     cy.get('input').should('have.value', 'Home project');
575                 })
576                 cy.get('[data-cy=name-field]').within(() => {
577                     cy.get('input').type(collName);
578                 })
579             })
580         cy.get('[data-cy=form-submit-btn]').click();
581         // Confirm that the user was taken to the newly created thing
582         cy.get('[data-cy=form-dialog]').should('not.exist');
583         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
584         cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
585     });
586 })