wdio-mediawiki 2.6.0 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Api.js CHANGED
@@ -88,5 +88,43 @@ module.exports = {
88
88
  reason: 'browser test done',
89
89
  token: adminBot.editToken
90
90
  } );
91
+ },
92
+
93
+ /**
94
+ * Assign a new user group to the given username.
95
+ *
96
+ * @since 2.7.0
97
+ * @param {MWBot} adminBot
98
+ * @param {string} username
99
+ * @param {string} groupName
100
+ */
101
+ async addUserToGroup( adminBot, username, groupName ) {
102
+ const userGroupsResponse = await adminBot.request( {
103
+ action: 'query',
104
+ list: 'users',
105
+ usprop: 'groups',
106
+ ususers: username,
107
+ formatversion: 2
108
+ } );
109
+
110
+ if (
111
+ userGroupsResponse.query.users.length &&
112
+ userGroupsResponse.query.users[ 0 ].groups.includes( groupName )
113
+ ) {
114
+ return;
115
+ }
116
+ const tokenResponse = await adminBot.request( {
117
+ action: 'query',
118
+ meta: 'tokens',
119
+ type: 'userrights'
120
+ } );
121
+ await adminBot.request( {
122
+ action: 'userrights',
123
+ user: username,
124
+ token: tokenResponse.query.tokens.userrightstoken,
125
+ add: groupName,
126
+ reason: 'Selenium testing'
127
+ } );
128
+ // If there is an error, the above already throws.
91
129
  }
92
130
  };
package/README.md CHANGED
@@ -26,6 +26,7 @@ which typically come from `MEDIAWIKI_USER` and `MEDIAWIKI_PASSWORD` environment
26
26
  * `createAccount(MWBot bot, string username, string password)`
27
27
  * `blockUser(MWBot bot, [ string username [, string expiry ] ])`
28
28
  * `unblockUser(MWBot bot, [ string username ])`
29
+ * `addUserToGroup(MWBot bot, string username, string groupName)`
29
30
 
30
31
  Example:
31
32
 
package/index.js CHANGED
@@ -34,7 +34,7 @@ function filePath( title, extension ) {
34
34
  *
35
35
  * @since 1.0.0
36
36
  * @param {string} title Description (will be sanitised and used as file name)
37
- * @return {string} File path
37
+ * @return {Promise<string>} File path
38
38
  */
39
39
  async function saveScreenshot( title ) {
40
40
  // Create sensible file name for current test title
@@ -71,6 +71,9 @@ function startVideo( ffmpeg, title ) {
71
71
  '-pix_fmt', 'yuv420p', // QuickTime Player support, "Use -pix_fmt yuv420p for compatibility with outdated media players"
72
72
  videoPath // output file
73
73
  ] );
74
+ ffmpeg.on( 'error', () => {
75
+ console.log( 'Not recording a video because ffmpeg is not available' );
76
+ } );
74
77
  const logBuffer = function ( buffer, prefix ) {
75
78
  const lines = buffer.toString().trim().split( '\n' );
76
79
  lines.forEach( ( line ) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdio-mediawiki",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "WebdriverIO plugin for testing a MediaWiki site.",
5
5
  "homepage": "https://gerrit.wikimedia.org/g/mediawiki/core/+/master/tests/selenium/wdio-mediawiki",
6
6
  "license": "MIT",
@@ -22,6 +22,22 @@ if ( !process.env.MW_SERVER || !process.env.MW_SCRIPT_PATH ) {
22
22
  throw new Error( 'MW_SERVER or MW_SCRIPT_PATH not defined.\nSee https://www.mediawiki.org/wiki/Selenium/How-to/Set_environment_variables\n' );
23
23
  }
24
24
 
25
+ process.on( 'uncaughtException', ( error ) => {
26
+ console.error( 'Caught uncaughtException: ', error );
27
+ // eslint-disable-next-line n/no-process-exit
28
+ process.exit( 1 );
29
+ } );
30
+
31
+ process.on( 'unhandledRejection', ( reason, promise ) => {
32
+ console.log( 'Unhandled Rejection at:', promise, 'reason:', reason );
33
+ } );
34
+
35
+ [ 'SIGINT', 'SIGTERM' ].forEach( ( signal ) => process.on( signal, () => {
36
+ // eslint-disable-next-line no-underscore-dangle
37
+ console.log( `Received ${ signal }. Active handles:`, process._getActiveHandles() );
38
+ } )
39
+ );
40
+
25
41
  /**
26
42
  * For more details documentation and available options:
27
43
  * - https://webdriver.io/docs/configurationfile
@@ -65,8 +81,8 @@ exports.config = {
65
81
  // Dismissed Chrome's `Save password?` popup
66
82
  '--enable-automation',
67
83
  ...( process.env.DISPLAY ? [] : [ '--headless' ] ),
68
- // Chrome sandbox does not work in Docker
69
- ...( fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] ),
84
+ // Chrome sandbox does not work in Docker. Disable GPU to prevent crashes (T389536#10677201)
85
+ ...( fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox', '--disable-gpu' ] : [] ),
70
86
  // Workaround inputs not working consistently post-navigation on Chrome 90
71
87
  // https://issuetracker.google.com/issues/42322798
72
88
  '--allow-pre-commit-input'