2 * Creates role with given permissions.
4 * @param {object} settings
6 * @param {array} settings.permissions
7 * The list of roles granted for the user.
8 * @param {string} [settings.name=null]
10 * @param {function} callback
11 * A callback which will be called, when creating the role is finished.
13 * The drupalCreateRole command.
15 exports.command = function drupalCreateRole(
16 { permissions, name = null },
27 this.drupalLoginAsAdmin(() => {
28 this.drupalRelativeURL('/admin/people/roles/add')
29 .setValue('input[name="label"]', roleName)
30 // Wait for the machine name to appear so that it can be used later to
31 // select the permissions from the permission page.
32 .expect.element('.user-role-form .machine-name-value')
33 .to.be.visible.before(2000);
35 this.perform(done => {
36 this.getText('.user-role-form .machine-name-value', element => {
37 machineName = element.value;
41 .submitForm('#user-role-form')
42 .drupalRelativeURL('/admin/people/permissions')
43 .perform((client, done) => {
47 new Promise(resolve => {
49 `input[name="${machineName}[${permission}]"]`,
60 .submitForm('#user-admin-permissions');
62 if (typeof callback === 'function') {
63 callback.call(self, machineName);