diff --git a/assets/src/bundles/vault/vault-create-tasks.js b/assets/src/bundles/vault/vault-create-tasks.js --- a/assets/src/bundles/vault/vault-create-tasks.js +++ b/assets/src/bundles/vault/vault-create-tasks.js @@ -71,7 +71,7 @@ cookingUrl = Urls.api_1_vault_cook_git_bare(cookingTask.swhid); } if (cookingTask.email) { - cookingUrl += '?email=' + cookingTask.email; + cookingUrl += '?email=' + encodeURIComponent(cookingTask.email); } try { diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js --- a/cypress/integration/vault.spec.js +++ b/cypress/integration/vault.spec.js @@ -407,6 +407,45 @@ .should('contain', 'Archive cooking request successfully submitted.'); }); + it('should create a directory cooking task with an email address', function() { + + // Browse a directory + cy.visit(this.directoryUrl); + + // Stub responses when checking vault task status + const checkVaulResponses = [ + {'exception': 'NotFoundExc'}, + this.genVaultDirCookingResponse('new'), + this.genVaultDirCookingResponse('pending', 'Processing...'), + this.genVaultDirCookingResponse('done') + ]; + + // trick to override the response of an intercepted request + // https://github.com/cypress-io/cypress/issues/9302 + cy.intercept('GET', this.vaultDirectoryUrl, req => req.reply(checkVaulResponses.shift())) + .as('checkVaultCookingTask'); + + // Stub responses when requesting the vault API to simulate + // a task has been created + cy.intercept('POST', this.vaultDirectoryUrl + '?email=foo%2Bbar@example.org', { + body: this.genVaultDirCookingResponse('new') + }).as('createVaultCookingTask'); + + cy.contains('button', 'Download') + .click(); + + cy.window().then(win => { + // Create a vault cooking task through the GUI + cy.get('.modal-dialog #swh-vault-revision-email') + .type('foo+bar@example.org', {force: true}); + cy.get('.modal-dialog') + .contains('button:visible', 'Ok') + .click(); + + cy.wait('@createVaultCookingTask'); + }); + }); + it('should offer to recook an archive if no longer available for download', function() { updateVaultItemList(this.vaultItems);