Page MenuHomePhabricator

Investigate what's needed to make core webdriver.io tests independent of mwbot to make sure core uses maintained code
Closed, ResolvedPublic5 Estimated Story PointsSpike

Description

mwbot is the library we use in our webdriver.io tests to talk to the MediaWiki API to create users and pages needed for our webdriver.io tests. The library is a third party library that is not maintained anymore, have dependencies that are not maintained (T330443, T401673) and have room for improvement in the error handling (T401653, T393428#11029515).

We want to replace that library with code that lives in core to make it easy for us to fix problems with the functionality.

AC:

  • Document what functions should be ported to core for core tests to work
  • Investigate if it's possible to use built in fetch (nodejs-fetch) and if so, identify what functionality is missing that we need to build ourselves
  • Create follow-up tasks for implementing mwbot functionality in core

Details

Other Assignee
zeljkofilipin

Event Timeline

Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptSep 4 2025, 3:54 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

for the extensions/skins that are supported by quickstart, the patterns i use here could be used to do super quick bulk searches across all quickstart supported extensions/skins:

https://gitlab.wikimedia.org/mhurd/mediawiki-quickstart-utils

could be pretty easily extended to search more than just quickstart's extensions/skins

happy to add to it the ability to report what extensions/skins use mwbot

SDunlap triaged this task as High priority.
SDunlap updated Other Assignee, added: zeljkofilipin.
SDunlap edited projects, added Test Platform (dek tri 13); removed Test Platform.
SDunlap added a subscriber: pwangai.

The functionality used in core for mwbot is:

mwbot.read
mwbot.edit
mwbot.request
mwbot.delete
mwbot.loginGetEditToken
mwbot.getCreateaccountToken

I am quite happy to see an effort to replace mwbot. Have you considered using the MediaWiki itself? Is has JavaScript code for the action API: mw.Api which lets one login and edit a page. It does not seem to have an implementation to delete a page, but that should be easy to add (see API:Delete).

For fetch the flag was removed for 18 but it was still experimental until 21. However I'm thinking we only use a small bit of it so it would probably be fine. I started with a POC to test how it will work and what's actual needed.

Have you considered using the MediaWiki itself? Is has JavaScript code for the action AP

No, isn't that only delivered as JavaScript, so for us to run it, we need to spin up the browser, load a MediaWiki page and then let webdriver.io run the JavaScript needed to do the stuff? Also like if we do it in the backend/NodeJS that will have one session and our tests can use another session. Running in JavaScript we need to have two instances of a browser at the same time?

Investigate if it's possible to use built in fetch (nodejs-fetch) and if so, identify what functionality is missing that we need to build ourselves

If you want cookie-based sessions to work (which you probably need for these tests), you’ll have to add that in, Node fetch doesn’t have cookies by default. Compare m3api’s code.

Thanks @Lucas_Werkmeister_WMDE . I did a small POC just adding cookies and that seems to work.

For extensions/skins that use mwbot there are some different behavior: https://codesearch.wmcloud.org/things/?q=mwbot&files=&excludeFiles=&repos=

Some import mwbot directly in their package.json, some uses the one that is used in core and exposed in API. When we implement the new stuff we need consider what we want to expose and how we can make it easier to upgrade in the future.

Document what functions should be ported to core for core tests to work

mwbot.read
mwbot.edit
mwbot.request
mwbot.delete
mwbot.loginGetEditToken
mwbot.getCreateaccountToken

Investigate if it's possible to use built in fetch (nodejs-fetch) and if so, identify what functionality is missing that we need to build ourselves

I'll made POC where all tests work when I run with quickstart. I plan to use the POC as a start for the implementation The code works, but we need to spend time to clean it up.

Create follow-up tasks for implementing mwbot functionality in core

T404361