Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Nightwatch / Commands / drupalLogout.js
1 import { execSync } from 'child_process';
2 import { URL } from 'url';
3
4 /**
5  * Logs out from a Drupal site.
6  *
7  * @param {object} [settings={}]
8  *   The settings object.
9  * @param {boolean} [settings.silent=false]
10  *   If the command should be run silently.
11  * @param {function} callback
12  *   A callback which will be called, when the logout is finished.
13  * @return {object}
14  *   The drupalLogout command.
15  */
16 exports.command = function drupalLogout({ silent = false } = {}, callback) {
17   const self = this;
18
19   this.drupalRelativeURL('/user/logout');
20
21   this.drupalUserIsLoggedIn(sessionExists => {
22     if (silent) {
23       if (sessionExists) {
24         throw new Error('Logging out failed.');
25       }
26     } else {
27       this.assert.equal(sessionExists, false, 'The user was logged out.');
28     }
29   });
30
31   if (typeof callback === 'function') {
32     callback.call(self);
33   }
34
35   return this;
36 };