wdio-mediawiki 6.3.3 → 6.5.0

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
@@ -18,7 +18,8 @@ class Api {
18
18
  baseUrl,
19
19
  username,
20
20
  password,
21
- verbose
21
+ verbose,
22
+ cookies
22
23
  } = options;
23
24
 
24
25
  this.session = {
@@ -27,7 +28,7 @@ class Api {
27
28
  createAccountToken: null
28
29
  };
29
30
 
30
- this.cookies = new Cookies();
31
+ this.cookies = new Cookies( cookies );
31
32
  this.httpClient = new MwApiHttpClient( {
32
33
  cookies: this.cookies,
33
34
  options: {
@@ -211,6 +212,7 @@ class Api {
211
212
  * - options.baseUrl - browser.options.baseUrl
212
213
  * - options.username - browser.options.capabilities['mw:user']
213
214
  * - options.password - browser.options.capabilities['mw:pwd']
215
+ * - options.cookies - extra cookies to send with every API request (name -> value map)
214
216
  * - options.verbose set to true logs every response from MediaWiki
215
217
  *
216
218
  * @param {Object} [options={}] Optional api configuration.
@@ -223,7 +225,8 @@ class Api {
223
225
  * baseUrl: 'https://mw.example.org',
224
226
  * username: 'Admin',
225
227
  * password: process.env.MW_PWD,
226
- * verbose: true
228
+ * verbose: true,
229
+ * cookies: { cookie1: 'value1', cookie2: 'value2' }
227
230
  * });
228
231
  */
229
232
  export const createApiClient = async function ( options = {} ) {
@@ -234,6 +237,7 @@ export const createApiClient = async function ( options = {} ) {
234
237
  baseUrl,
235
238
  username,
236
239
  password,
240
+ cookies: options.cookies,
237
241
  verbose: options.verbose ?? false
238
242
  } );
239
243
  await api.loginGetEditToken( username, password );
package/api/Cookies.js CHANGED
@@ -3,8 +3,8 @@
3
3
  */
4
4
  export class Cookies {
5
5
 
6
- constructor() {
7
- this.pairs = {};
6
+ constructor( defaultCookies = {} ) {
7
+ this.pairs = { ...defaultCookies };
8
8
  }
9
9
 
10
10
  /**
@@ -49,7 +49,7 @@ export class MwApiHttpClient {
49
49
  }
50
50
 
51
51
  if ( !response.ok ) {
52
- console.error( `[API] HTTP ${ response.status }: ${ response.statusText }` );
52
+ console.error( `[API] HTTP ${ response.status }: ${ response.statusText }`, text );
53
53
  throw new Error( `HTTP ${ response.status }` );
54
54
  }
55
55
 
package/index.js CHANGED
@@ -1,10 +1,23 @@
1
1
  import { mkdir } from 'fs/promises';
2
+ import { readFileSync } from 'fs';
2
3
  import os from 'node:os';
3
4
  import process from 'node:process';
5
+ import { resolve } from 'path';
4
6
  import { spawn } from 'child_process';
5
7
 
6
8
  const DISPLAY_BASE = 100;
7
9
 
10
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
11
+ export const version = JSON.parse( readFileSync( new URL( './package.json', import.meta.url ), 'utf8' ) ).version;
12
+
13
+ function getPackageVersion( packageName ) {
14
+ try {
15
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
16
+ return JSON.parse( readFileSync( resolve( process.cwd(), 'node_modules', packageName, 'package.json' ), 'utf8' ) ).version;
17
+ } catch {}
18
+ return 'unknown';
19
+ }
20
+
8
21
  /**
9
22
  * @since 1.1.0
10
23
  * @return {string} File name friendly version of ISO 8601 date and time
@@ -160,6 +173,8 @@ export function logSystemInformation() {
160
173
  console.log( `[System information] Memory (host): ${ formatMegabytesAndGigabytes( freeBytes ) } free` );
161
174
  console.log( `[System information] RAM used by NodeJS ${ formatMegabytesAndGigabytes( rss ) }` );
162
175
  console.log( `[System information] CPU: ${ cores } cores` );
176
+ console.log( `[Package information] WebdriverIO: ${ getPackageVersion( 'webdriverio' ) }` );
177
+ console.log( `[Package information] wdio-mediawiki: ${ version }` );
163
178
  }
164
179
 
165
180
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdio-mediawiki",
3
- "version": "6.3.3",
3
+ "version": "6.5.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "description": "WebdriverIO plugin for testing a MediaWiki site.",
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  let ffmpeg;
12
+ import os from 'os';
12
13
  import path from 'path';
13
14
  import { getChromeOptions } from './chromeOptions.js';
14
15
  import { setupProcessHandlers } from './processHandlers.js';
@@ -50,7 +51,7 @@ export const config = {
50
51
  // Define the different browser configurations to use ("capabilities") here.
51
52
  // ============
52
53
 
53
- maxInstances: process.env.CI ? 6 : 1,
54
+ maxInstances: process.env.CI ? Math.floor( os.cpus().length * 0.75 ) : 1,
54
55
  // Make sure wdio do not try to start XVFB (we do that ourselves when needed)
55
56
  autoXvfb: false,
56
57
  capabilities: [ {
@@ -159,6 +160,7 @@ export const config = {
159
160
  onPrepare: function ( wdioConfig, capabilities ) {
160
161
  console.log( `Run test targeting ${ wdioConfig.baseUrl }` );
161
162
  logSystemInformation();
163
+ console.log( `[Configuration] maxInstances ${ wdioConfig.maxInstances } (max tests running in parallel) ` );
162
164
 
163
165
  const { maxInstances, useBrowserHeadless, recordVideo } = wdioConfig;
164
166