wdio-mediawiki 2.4.0 → 2.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 +1 -1
- package/BlankPage.js +3 -1
- package/CreateAccountPage.js +19 -5
- package/LoginPage.js +15 -4
- package/Page.js +1 -2
- package/RunJobs.js +4 -4
- package/index.js +6 -8
- package/package.json +3 -2
- package/wdio-defaults.conf.js +17 -3
package/Api.js
CHANGED
package/BlankPage.js
CHANGED
package/CreateAccountPage.js
CHANGED
|
@@ -3,11 +3,25 @@
|
|
|
3
3
|
const Page = require( './Page' );
|
|
4
4
|
|
|
5
5
|
class CreateAccountPage extends Page {
|
|
6
|
-
get username() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
get
|
|
6
|
+
get username() {
|
|
7
|
+
return $( '#wpName2' );
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get password() {
|
|
11
|
+
return $( '#wpPassword2' );
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get confirmPassword() {
|
|
15
|
+
return $( '#wpRetype' );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get create() {
|
|
19
|
+
return $( '#wpCreateaccount' );
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get heading() {
|
|
23
|
+
return $( '#firstHeading' );
|
|
24
|
+
}
|
|
11
25
|
|
|
12
26
|
open() {
|
|
13
27
|
super.openTitle( 'Special:CreateAccount' );
|
package/LoginPage.js
CHANGED
|
@@ -3,10 +3,21 @@
|
|
|
3
3
|
const Page = require( './Page' );
|
|
4
4
|
|
|
5
5
|
class LoginPage extends Page {
|
|
6
|
-
get username() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
get username() {
|
|
7
|
+
return $( '#wpName1' );
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get password() {
|
|
11
|
+
return $( '#wpPassword1' );
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get loginButton() {
|
|
15
|
+
return $( '#wpLoginAttempt' );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get userPage() {
|
|
19
|
+
return $( '#pt-userpage' );
|
|
20
|
+
}
|
|
10
21
|
|
|
11
22
|
open() {
|
|
12
23
|
super.openTitle( 'Special:UserLogin' );
|
package/Page.js
CHANGED
|
@@ -18,10 +18,9 @@ class Page {
|
|
|
18
18
|
* @return {void} This method runs a browser command.
|
|
19
19
|
*/
|
|
20
20
|
async openTitle( title, query = {}, fragment = '' ) {
|
|
21
|
-
const config = Object.assign( browser.config || {}, browser.options || {} );
|
|
22
21
|
query.title = title;
|
|
23
22
|
await browser.url(
|
|
24
|
-
config.baseUrl + '/index.php?' +
|
|
23
|
+
browser.config.baseUrl + '/index.php?' +
|
|
25
24
|
querystring.stringify( query ) +
|
|
26
25
|
( fragment ? ( '#' + fragment ) : '' )
|
|
27
26
|
);
|
package/RunJobs.js
CHANGED
|
@@ -6,7 +6,7 @@ const MAINPAGE_REQUESTS_MAX_RUNS = 10; // (arbitrary) safe-guard against endless
|
|
|
6
6
|
|
|
7
7
|
function getJobCount() {
|
|
8
8
|
const bot = new MWBot( {
|
|
9
|
-
apiUrl: `${browser.config.baseUrl}/api.php`
|
|
9
|
+
apiUrl: `${ browser.config.baseUrl }/api.php`
|
|
10
10
|
} );
|
|
11
11
|
return bot.request( {
|
|
12
12
|
action: 'query',
|
|
@@ -16,12 +16,12 @@ function getJobCount() {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function log( message ) {
|
|
19
|
-
process.stdout.write( `RunJobs ${message}\n` );
|
|
19
|
+
process.stdout.write( `RunJobs ${ message }\n` );
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function runThroughMainPageRequests( runCount = 1 ) {
|
|
23
23
|
const page = new Page();
|
|
24
|
-
log( `through requests to the main page (run ${runCount}).` );
|
|
24
|
+
log( `through requests to the main page (run ${ runCount }).` );
|
|
25
25
|
|
|
26
26
|
page.openTitle( '' );
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ function runThroughMainPageRequests( runCount = 1 ) {
|
|
|
30
30
|
log( 'found no more queued jobs.' );
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
log( `detected ${jobCount} more queued job(s).` );
|
|
33
|
+
log( `detected ${ jobCount } more queued job(s).` );
|
|
34
34
|
if ( runCount >= MAINPAGE_REQUESTS_MAX_RUNS ) {
|
|
35
35
|
log( 'stopping requests to the main page due to reached limit.' );
|
|
36
36
|
return;
|
package/index.js
CHANGED
|
@@ -23,11 +23,10 @@ function testTitle( title ) {
|
|
|
23
23
|
* @since 1.1.0
|
|
24
24
|
* @param {string} title Test title
|
|
25
25
|
* @param {string} extension png for screenshots, mp4 for videos
|
|
26
|
-
* @param {string} screenshotPath Optional path
|
|
27
26
|
* @return {string} Full path of screenshot/video file
|
|
28
27
|
*/
|
|
29
|
-
function filePath( title, extension
|
|
30
|
-
return `${
|
|
28
|
+
function filePath( title, extension ) {
|
|
29
|
+
return `${ browser.config.screenshotPath }/${ testTitle( title ) }-${ makeFilenameDate() }.${ extension }`;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
/**
|
|
@@ -35,19 +34,18 @@ function filePath( title, extension, screenshotPath = undefined ) {
|
|
|
35
34
|
*
|
|
36
35
|
* @since 1.0.0
|
|
37
36
|
* @param {string} title Description (will be sanitised and used as file name)
|
|
38
|
-
* @param {string} screenshotPath Optional path
|
|
39
37
|
* @return {string} File path
|
|
40
38
|
*/
|
|
41
|
-
async function saveScreenshot( title
|
|
39
|
+
async function saveScreenshot( title ) {
|
|
42
40
|
// Create sensible file name for current test title
|
|
43
|
-
const path = filePath( title, 'png'
|
|
41
|
+
const path = filePath( title, 'png' );
|
|
44
42
|
// Ensure directory exists, based on WebDriverIO#saveScreenshotSync()
|
|
45
43
|
try {
|
|
46
44
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
47
|
-
fs.statSync(
|
|
45
|
+
fs.statSync( browser.config.screenshotPath );
|
|
48
46
|
} catch ( err ) {
|
|
49
47
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
50
|
-
fs.mkdirSync(
|
|
48
|
+
fs.mkdirSync( browser.config.screenshotPath );
|
|
51
49
|
}
|
|
52
50
|
// Create and save screenshot
|
|
53
51
|
await browser.saveScreenshot( path );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdio-mediawiki",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
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",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"specs/"
|
|
14
14
|
],
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=18.17.0",
|
|
17
|
+
"npm": ">=9.6.7"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"mwbot": "2.1.3"
|
package/wdio-defaults.conf.js
CHANGED
|
@@ -15,6 +15,8 @@ const fs = require( 'fs' );
|
|
|
15
15
|
const path = require( 'path' );
|
|
16
16
|
const logPath = process.env.LOG_DIR || path.join( process.cwd(), 'tests/selenium/log' );
|
|
17
17
|
const { makeFilenameDate, saveScreenshot, startVideo, stopVideo } = require( 'wdio-mediawiki' );
|
|
18
|
+
// T355556: remove when T324766 is resolved
|
|
19
|
+
const dns = require( 'dns' );
|
|
18
20
|
|
|
19
21
|
if ( !process.env.MW_SERVER || !process.env.MW_SCRIPT_PATH ) {
|
|
20
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' );
|
|
@@ -105,7 +107,7 @@ exports.config = {
|
|
|
105
107
|
[ 'junit', {
|
|
106
108
|
outputDir: logPath,
|
|
107
109
|
outputFileFormat: function () {
|
|
108
|
-
return `WDIO.xunit-${makeFilenameDate()}.xml`;
|
|
110
|
+
return `WDIO.xunit-${ makeFilenameDate() }.xml`;
|
|
109
111
|
}
|
|
110
112
|
} ]
|
|
111
113
|
],
|
|
@@ -114,13 +116,25 @@ exports.config = {
|
|
|
114
116
|
// Hooks
|
|
115
117
|
// =====
|
|
116
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Gets executed just before initializing the webdriver session and test framework.
|
|
121
|
+
* It allows you to manipulate configurations depending on the capability or spec.
|
|
122
|
+
* @param {Object} config wdio configuration object
|
|
123
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
124
|
+
* @param {Array.<string>} specs List of spec file paths that are to be run
|
|
125
|
+
*/
|
|
126
|
+
// T355556: remove when T324766 is resolved
|
|
127
|
+
beforeSession: function () {
|
|
128
|
+
dns.setDefaultResultOrder( 'ipv4first' );
|
|
129
|
+
},
|
|
130
|
+
|
|
117
131
|
/**
|
|
118
132
|
* Executed before a Mocha test starts.
|
|
119
133
|
*
|
|
120
134
|
* @param {Object} test Mocha Test object
|
|
121
135
|
*/
|
|
122
136
|
beforeTest: function ( test ) {
|
|
123
|
-
ffmpeg = startVideo( ffmpeg, `${test.parent}-${test.title}` );
|
|
137
|
+
ffmpeg = startVideo( ffmpeg, `${ test.parent }-${ test.title }` );
|
|
124
138
|
},
|
|
125
139
|
|
|
126
140
|
/**
|
|
@@ -129,7 +143,7 @@ exports.config = {
|
|
|
129
143
|
* @param {Object} test Mocha Test object
|
|
130
144
|
*/
|
|
131
145
|
afterTest: async function ( test ) {
|
|
132
|
-
await saveScreenshot( `${test.parent}-${test.title}` );
|
|
146
|
+
await saveScreenshot( `${ test.parent }-${ test.title }` );
|
|
133
147
|
stopVideo( ffmpeg );
|
|
134
148
|
}
|
|
135
149
|
};
|