Page MenuHomePhabricator

Testing the REST API in CI
Closed, ResolvedPublic

Description

Currently, in CI, Parsoid/JS spins up a service using mockAPI.js as the MediaWiki API and runs the mocha/api.js suite.

For the purpose of the port, we have a patch which lets a local MediaWiki instance with the installed Parsoid/PHP extension also use mockAPI.js for DataAccess and then we can run the mocha/api.js test suite with a supplied PARSOID_URL (added in T221168).

Moving forward though, we probably want to move to whatever the MediaWiki action API is tested with and do away with mocha altogether.

Event Timeline

Arlolra triaged this task as High priority.Dec 4 2019, 9:46 PM

Change 608495 had a related patch set uploaded (by Arlolra; owner: Arlolra):
[mediawiki/services/parsoid@master] [WIP] Use api-testing to run integration tests

https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/ /608495

Change 608495 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Use api-testing to run integration tests

https://gerrit.wikimedia.org/r/608495

Change 612673 had a related patch set uploaded (by Arlolra; owner: Arlolra):
[integration/config@master] Turn on API integration tests for Parsoid

https://gerrit.wikimedia.org/r/612673

Change 612673 merged by jenkins-bot:
[integration/config@master] Turn on API integration tests for Parsoid

https://gerrit.wikimedia.org/r/612673

Change 612992 had a related patch set uploaded (by Arlolra; owner: Arlolra):
[mediawiki/services/parsoid@master] Add a test for serializing when a revision isn't found

https://gerrit.wikimedia.org/r/612992

Change 612992 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Add a test for serializing when a revision isn't found

https://gerrit.wikimedia.org/r/612992

Change 614872 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/vendor@master] Bump parsoid to 0.13.0-a1

https://gerrit.wikimedia.org/r/614872

Change 614872 merged by jenkins-bot:
[mediawiki/vendor@master] Bump parsoid to 0.13.0-a1

https://gerrit.wikimedia.org/r/614872

Change 637570 had a related patch set uploaded (by Arlolra; owner: Arlolra):
[mediawiki/services/parsoid@master] Setup for parsing oldHTML if none provided

https://gerrit.wikimedia.org/r/637570

Change 637570 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Setup for parsing oldHTML if none provided

https://gerrit.wikimedia.org/r/637570

Currently if you comment check experimental on a gerrit patch it will run npm run api-testing.

@Arlolra says: "the only thing that's missing is that the db needs to be populated with the necessary pages"

When I want to test this locally, I'll put in my LocalSettings.php,

$wgEnableRestAPI = true;
$wgParsoidSettings = [
	'linting' => true,
	'useSelser' => true,
	'debugApi' => "http://localhost:12345/api.php",
	'wt2htmlLimits' => [
		'wikitextSize' => 20000,
	],
	'html2wtLimits' => [
		'htmlSize' => 10000,
	],
];

and then run MOCKPORT=12345 node tests/mockAPI.js

I've got a .api-testing.config.json with values like,

{
	"base_uri": "http://localhost:8080/",
	"main_page": "Main_Page",
	"root_user": {
		"name": "Admin",
		"password": ""
	},
	"secret_key": "XXX"
}

and then I can run npm run api-testing

A properly setup db wouldn't need any of that LocalSettings configuration or mockAPI.js nonsense.

Change 695476 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Fix api test broken in 6849f5f

https://gerrit.wikimedia.org/r/695476

Change 695477 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Fix api test broken in a4b8b38

https://gerrit.wikimedia.org/r/695477

Change 695561 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] Skip variant tests, for now

https://gerrit.wikimedia.org/r/695561

Change 695476 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Fix api test broken in 6849f5f

https://gerrit.wikimedia.org/r/695476

Change 695477 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Fix api test broken in a4b8b38

https://gerrit.wikimedia.org/r/695477

Change 696566 had a related patch set uploaded (by Arlolra; author: Arlolra):

[integration/config@master] Take api testing out of experimental for Parsoid

https://gerrit.wikimedia.org/r/696566

Change 695561 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Skip some api tests, for now

https://gerrit.wikimedia.org/r/695561

Change 696566 merged by jenkins-bot:

[integration/config@master] Take api testing out of experimental for Parsoid

https://gerrit.wikimedia.org/r/696566