diff --git a/commands.js b/commands.js index eba0041671d815f167cbe56314da90287838c735..8485bede5610e7c2e931e95c6ab6e999e482ee71 100644 --- a/commands.js +++ b/commands.js @@ -26,11 +26,18 @@ Cypress.Commands.add('login', (options) => { cy.get('#user-login-form').submit() }) -Cypress.Commands.add('createAndLogin', (username, role) => { +Cypress.Commands.add('createUser', (username, roles) => { cy.rememberLatestTaxonomyTerm(); let password = 'random-password-' + Cypress._.random(0, 1e6); cy.drush('user:create ' + username + ' --password=' + password); - cy.drush('user:role:add ' + role + ' ' + username); + roles.split(',').forEach(role => { + cy.drush('user:role:add ' + role + ' ' + username); + }); + return password; +}) + +Cypress.Commands.add('createAndLogin', (username, role) => { + let password = cy.createUser(username, role); cy.login({ path: 'user/login', username: username, @@ -39,10 +46,7 @@ Cypress.Commands.add('createAndLogin', (username, role) => { }) Cypress.Commands.add('createAndLoginDrush', (username, role) => { - cy.rememberLatestTaxonomyTerm(); - let password = 'random-password-' + Cypress._.random(0, 1e6); - cy.drush('user:create ' + username + ' --password=' + password); - cy.drush('user:role:add ' + role + ' ' + username); + cy.createUser(username, role); cy.drush('uli --uri ' + Cypress.config('baseUrl') + ' --name ' + username).then((result) => { cy.visit(result.stdout); })