Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6125618
api.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
api.js
View Options
// Example code for Selenium/How-to/Use MediaWiki API
// https://www.mediawiki.org/wiki/Selenium/How-to/Use_MediaWiki_API
import
assert
from
'assert'
;
import
{
createApiClient
}
from
'wdio-mediawiki/Api.js'
;
// baseUrl is required for our continuous integration.
// If you don't have MW_SERVER and MW_SCRIPT_PATH environment variables set
// you can probably hardcode it to something like this:
// const baseUrl = 'http://localhost:8080/';
const
baseUrl
=
`
${
process
.
env
.
MW_SERVER
}${
process
.
env
.
MW_SCRIPT_PATH
}
`
;
const
apiClient
=
await
createApiClient
(
{
baseUrl
}
);
describe
(
'API'
,
()
=>
{
it
(
'Main Page should exist'
,
async
()
=>
{
const
response
=
await
apiClient
.
read
(
'Main Page'
);
// console.log( response );
// { batchcomplete: '' (...) query: { pages: { '3': [Object] } } }
// console.log( response.query );
// { pages: { '3': { pageid: 3, ns: 0, title: 'Main Page', revisions: [Array] } } }
assert
.
strictEqual
(
Object
.
values
(
response
.
query
.
pages
)[
0
].
pageid
>
0
,
true
);
}
);
it
(
'Missing Page should not exist'
,
async
()
=>
{
const
response
=
await
apiClient
.
read
(
'Missing Page'
);
// console.log( response );
// { batchcomplete: '', query: { pages: { '-1': [Object] } } }
// console.log( response.query );
// { pages: { '-1': { ns: 0, title: 'Missing Page', missing: '' } } }
assert
.
strictEqual
(
response
.
query
.
pages
[
'-1'
].
missing
,
''
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Oct 7 2026, 09:05 (6 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bc/74/b4c8b5421533607092115654f929
Default Alt Text
api.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment