Merge branch '17582-square-brackets-on-names-fix'
[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                     '[between brackets]', // JSON-like strings (#17582)
243                     '{between braces}', // JSON-like strings (#17582)
244                     '&',
245                     'foo',
246                     '&amp;',
247                     'I ❤️ ⛵️',
248                     '...',
249                     '#..',
250                     'some name with whitespaces',
251                     'some name with #2',
252                     'is this name legal? I hope it is',
253                     'some_file.pdf#',
254                     'some_file.pdf?',
255                     '?some_file.pdf',
256                     'some%file.pdf',
257                     'some%2Ffile.pdf',
258                     'some%22file.pdf',
259                     'some%20file.pdf',
260                     "G%C3%BCnter's%20file.pdf",
261                     'table%&?*2',
262                     'bar' // make sure we can go back to the original name as a last step
263                 ];
264                 eachPair(names, (from, to) => {
265                     cy.get('[data-cy=collection-files-panel]')
266                         .contains(`${from}`).rightclick();
267                     cy.get('[data-cy=context-menu]')
268                         .contains('Rename')
269                         .click();
270                     cy.get('[data-cy=form-dialog]')
271                         .should('contain', 'Rename')
272                         .within(() => {
273                             cy.get('input')
274                                 .type('{selectall}{backspace}')
275                                 .type(to, { parseSpecialCharSequences: false });
276                         });
277                     cy.get('[data-cy=form-submit-btn]').click();
278                     cy.get('[data-cy=collection-files-panel]')
279                         .should('not.contain', `${from}`)
280                         .and('contain', `${to}`);
281                 })
282             });
283     });
284
285     it('renames a file to a different directory', function () {
286         // Creates the collection using the admin token so we can set up
287         // a bogus manifest text without block signatures.
288         cy.createCollection(adminUser.token, {
289             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
290             owner_uuid: activeUser.user.uuid,
291             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
292         })
293             .as('testCollection').then(function () {
294                 cy.loginAs(activeUser);
295                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
296
297                 ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
298                     cy.get('[data-cy=collection-files-panel]')
299                         .contains('bar').rightclick({force: true});
300                     cy.get('[data-cy=context-menu]')
301                         .contains('Rename')
302                         .click();
303                     cy.get('[data-cy=form-dialog]')
304                         .should('contain', 'Rename')
305                         .within(() => {
306                             cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
307                         });
308                     cy.get('[data-cy=form-submit-btn]').click();
309                     cy.get('[data-cy=collection-files-panel]')
310                         .should('not.contain', 'bar')
311                         .and('contain', subdir);
312                     // Look for the "arrow icon" and expand the "subdir" directory.
313                     cy.get('[data-cy=virtual-file-tree] > div > i').click();
314                     // Rename 'subdir/foo' to 'foo'
315                     cy.get('[data-cy=collection-files-panel]')
316                         .contains('foo').rightclick();
317                     cy.get('[data-cy=context-menu]')
318                         .contains('Rename')
319                         .click();
320                     cy.get('[data-cy=form-dialog]')
321                         .should('contain', 'Rename')
322                         .within(() => {
323                             cy.get('input')
324                                 .should('have.value', `${subdir}/foo`)
325                                 .type(`{selectall}{backspace}bar`);
326                         });
327                     cy.get('[data-cy=form-submit-btn]').click();
328                     cy.get('[data-cy=collection-files-panel]')
329                         .should('contain', subdir) // empty dir kept
330                         .and('contain', 'bar');
331
332                     cy.get('[data-cy=collection-files-panel]')
333                         .contains(subdir).rightclick();
334                     cy.get('[data-cy=context-menu]')
335                         .contains('Remove')
336                         .click();
337                     cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
338                 });
339             });
340     });
341
342     it('tries to rename a file with illegal names', function () {
343         // Creates the collection using the admin token so we can set up
344         // a bogus manifest text without block signatures.
345         cy.createCollection(adminUser.token, {
346             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
347             owner_uuid: activeUser.user.uuid,
348             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
349         })
350             .as('testCollection').then(function () {
351                 cy.loginAs(activeUser);
352                 cy.goToPath(`/collections/${this.testCollection.uuid}`);
353
354                 const illegalNamesFromUI = [
355                     ['.', "Name cannot be '.' or '..'"],
356                     ['..', "Name cannot be '.' or '..'"],
357                     ['', 'This field is required'],
358                     [' ', 'Leading/trailing whitespaces not allowed'],
359                     [' foo', 'Leading/trailing whitespaces not allowed'],
360                     ['foo ', 'Leading/trailing whitespaces not allowed'],
361                     ['//foo', 'Empty dir name not allowed']
362                 ]
363                 illegalNamesFromUI.forEach(([name, errMsg]) => {
364                     cy.get('[data-cy=collection-files-panel]')
365                         .contains('bar').rightclick();
366                     cy.get('[data-cy=context-menu]')
367                         .contains('Rename')
368                         .click();
369                     cy.get('[data-cy=form-dialog]')
370                         .should('contain', 'Rename')
371                         .within(() => {
372                             cy.get('input').type(`{selectall}{backspace}${name}`);
373                         });
374                     cy.get('[data-cy=form-dialog]')
375                         .should('contain', 'Rename')
376                         .within(() => {
377                             cy.contains(`${errMsg}`);
378                         });
379                     cy.get('[data-cy=form-cancel-btn]').click();
380                 })
381             });
382     });
383
384     it('can correctly display old versions', function () {
385         const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
386         let colUuid = '';
387         let oldVersionUuid = '';
388         // Make sure no other collections with this name exist
389         cy.doRequest('GET', '/arvados/v1/collections', null, {
390             filters: `[["name", "=", "${colName}"]]`,
391             include_old_versions: true
392         })
393             .its('body.items').as('collections')
394             .then(function () {
395                 expect(this.collections).to.be.empty;
396             });
397         // Creates the collection using the admin token so we can set up
398         // a bogus manifest text without block signatures.
399         cy.createCollection(adminUser.token, {
400             name: colName,
401             owner_uuid: activeUser.user.uuid,
402             preserve_version: true,
403             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
404         })
405             .as('originalVersion').then(function () {
406                 // Change the file name to create a new version.
407                 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
408                     manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
409                 })
410                 colUuid = this.originalVersion.uuid;
411             });
412         // Confirm that there are 2 versions of the collection
413         cy.doRequest('GET', '/arvados/v1/collections', null, {
414             filters: `[["name", "=", "${colName}"]]`,
415             include_old_versions: true
416         })
417             .its('body.items').as('collections')
418             .then(function () {
419                 expect(this.collections).to.have.lengthOf(2);
420                 this.collections.map(function (aCollection) {
421                     expect(aCollection.current_version_uuid).to.equal(colUuid);
422                     if (aCollection.uuid !== aCollection.current_version_uuid) {
423                         oldVersionUuid = aCollection.uuid;
424                     }
425                 });
426                 // Check the old version displays as what it is.
427                 cy.loginAs(activeUser)
428                 cy.goToPath(`/collections/${oldVersionUuid}`);
429
430                 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
431                 cy.get('[data-cy=read-only-icon]').should('exist');
432                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
433                 cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
434             });
435     });
436
437     it('uses the collection version browser to view a previous version', function () {
438         const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
439
440         // Creates the collection using the admin token so we can set up
441         // a bogus manifest text without block signatures.
442         cy.createCollection(adminUser.token, {
443             name: colName,
444             owner_uuid: activeUser.user.uuid,
445             preserve_version: true,
446             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n"
447         })
448             .as('collection').then(function () {
449                 // Visit collection, check basic information
450                 cy.loginAs(activeUser)
451                 cy.goToPath(`/collections/${this.collection.uuid}`);
452
453                 cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
454                 cy.get('[data-cy=read-only-icon]').should('not.exist');
455                 cy.get('[data-cy=collection-version-number]').should('contain', '1');
456                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
457                 cy.get('[data-cy=collection-files-panel]').should('contain', 'foo').and('contain', 'bar');
458
459                 // Modify collection, expect version number change
460                 cy.get('[data-cy=collection-files-panel]').contains('foo').rightclick();
461                 cy.get('[data-cy=context-menu]').contains('Remove').click();
462                 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Removing file');
463                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
464                 cy.get('[data-cy=collection-version-number]').should('contain', '2');
465                 cy.get('[data-cy=collection-files-panel]').should('not.contain', 'foo').and('contain', 'bar');
466
467                 // Click on version number, check version browser. Click on past version.
468                 cy.get('[data-cy=collection-version-browser]').should('not.exist');
469                 cy.get('[data-cy=collection-version-number]').contains('2').click();
470                 cy.get('[data-cy=collection-version-browser]')
471                     .should('contain', 'Nr').and('contain', 'Size').and('contain', 'Date')
472                     .within(() => {
473                         // Version 1: 6 bytes in size
474                         cy.get('[data-cy=collection-version-browser-select-1]')
475                             .should('contain', '1').and('contain', '6 B');
476                         // Version 2: 3 bytes in size (one file removed)
477                         cy.get('[data-cy=collection-version-browser-select-2]')
478                             .should('contain', '2').and('contain', '3 B');
479                         cy.get('[data-cy=collection-version-browser-select-3]')
480                             .should('not.exist');
481                         cy.get('[data-cy=collection-version-browser-select-1]')
482                             .click();
483                     });
484                 cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
485                 cy.get('[data-cy=read-only-icon]').should('exist');
486                 cy.get('[data-cy=collection-version-number]').should('contain', '1');
487                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
488                 cy.get('[data-cy=collection-files-panel]')
489                     .should('contain', 'foo').and('contain', 'bar');
490
491                 // Check that only old collection action are available on context menu
492                 cy.get('[data-cy=collection-panel-options-btn]').click();
493                 cy.get('[data-cy=context-menu]')
494                     .should('contain', 'Restore version')
495                     .and('not.contain', 'Add to favorites');
496                 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
497
498                 // Click on "head version" link, confirm that it's the latest version.
499                 cy.get('[data-cy=collection-info-panel]').contains('head version').click();
500                 cy.get('[data-cy=collection-info-panel]')
501                     .should('not.contain', 'This is an old version');
502                 cy.get('[data-cy=read-only-icon]').should('not.exist');
503                 cy.get('[data-cy=collection-version-number]').should('contain', '2');
504                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
505                 cy.get('[data-cy=collection-files-panel]').
506                     should('not.contain', 'foo').and('contain', 'bar');
507
508                 // Check that old collection action isn't available on context menu
509                 cy.get('[data-cy=collection-panel-options-btn]').click()
510                 cy.get('[data-cy=context-menu]').should('not.contain', 'Restore version')
511                 cy.get('body').click(); // Collapse the menu avoiding details panel expansion
512
513                 // Make another change, confirm new version.
514                 cy.get('[data-cy=collection-panel-options-btn]').click();
515                 cy.get('[data-cy=context-menu]').contains('Edit collection').click();
516                 cy.get('[data-cy=form-dialog]')
517                     .should('contain', 'Edit Collection')
518                     .within(() => {
519                         // appends some text
520                         cy.get('input').first().type(' renamed');
521                     });
522                 cy.get('[data-cy=form-submit-btn]').click();
523                 cy.get('[data-cy=collection-info-panel]')
524                     .should('not.contain', 'This is an old version');
525                 cy.get('[data-cy=read-only-icon]').should('not.exist');
526                 cy.get('[data-cy=collection-version-number]').should('contain', '3');
527                 cy.get('[data-cy=collection-info-panel]').should('contain', colName + ' renamed');
528                 cy.get('[data-cy=collection-files-panel]')
529                     .should('not.contain', 'foo').and('contain', 'bar');
530                 cy.get('[data-cy=collection-version-browser-select-3]')
531                     .should('contain', '3').and('contain', '3 B');
532
533                 // Check context menus on version browser
534                 cy.get('[data-cy=collection-version-browser-select-3]').rightclick()
535                 cy.get('[data-cy=context-menu]')
536                     .should('contain', 'Add to favorites')
537                     .and('contain', 'Make a copy')
538                     .and('contain', 'Edit collection');
539                 cy.get('body').click();
540                 // (and now an old version...)
541                 cy.get('[data-cy=collection-version-browser-select-1]').rightclick()
542                 cy.get('[data-cy=context-menu]')
543                     .should('not.contain', 'Add to favorites')
544                     .and('contain', 'Make a copy')
545                     .and('not.contain', 'Edit collection');
546                 cy.get('body').click();
547
548                 // Restore first version
549                 cy.get('[data-cy=collection-version-browser]').within(() => {
550                     cy.get('[data-cy=collection-version-browser-select-1]').click();
551                 });
552                 cy.get('[data-cy=collection-panel-options-btn]').click()
553                 cy.get('[data-cy=context-menu]').contains('Restore version').click();
554                 cy.get('[data-cy=confirmation-dialog]').should('contain', 'Restore version');
555                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
556                 cy.get('[data-cy=collection-info-panel]')
557                     .should('not.contain', 'This is an old version');
558                 cy.get('[data-cy=collection-version-number]').should('contain', '4');
559                 cy.get('[data-cy=collection-info-panel]').should('contain', colName);
560                 cy.get('[data-cy=collection-files-panel]')
561                     .should('contain', 'foo').and('contain', 'bar');
562             });
563     });
564
565     it('creates new collection on home project', function () {
566         cy.loginAs(activeUser);
567         cy.goToPath(`/projects/${activeUser.user.uuid}`);
568         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
569         cy.get('[data-cy=breadcrumb-last]').should('not.exist');
570         // Create new collection
571         cy.get('[data-cy=side-panel-button]').click();
572         cy.get('[data-cy=side-panel-new-collection]').click();
573         const collName = `Test collection (${Math.floor(999999 * Math.random())})`;
574         cy.get('[data-cy=form-dialog]')
575             .should('contain', 'New collection')
576             .within(() => {
577                 cy.get('[data-cy=parent-field]').within(() => {
578                     cy.get('input').should('have.value', 'Home project');
579                 })
580                 cy.get('[data-cy=name-field]').within(() => {
581                     cy.get('input').type(collName);
582                 })
583             })
584         cy.get('[data-cy=form-submit-btn]').click();
585         // Confirm that the user was taken to the newly created thing
586         cy.get('[data-cy=form-dialog]').should('not.exist');
587         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
588         cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
589     });
590 })