Merge "Add basic end-to-end tests for action=visualeditor"

This commit is contained in:
jenkins-bot 2022-09-28 16:48:33 +00:00 committed by Gerrit Code Review
commit d58d1ed036
4 changed files with 60 additions and 2 deletions

View file

@ -2,5 +2,10 @@
"root": true, "root": true,
"extends": [ "extends": [
"wikimedia/server" "wikimedia/server"
] ],
"env": {
"commonjs": true,
"node": true,
"mocha": true
}
} }

1
.gitignore vendored
View file

@ -17,6 +17,7 @@ vendor
screenshots/*.png screenshots/*.png
.eslintcache .eslintcache
tests/selenium/log tests/selenium/log
.api-testing.config.json
# OS # OS
.DS_Store .DS_Store

View file

@ -4,6 +4,8 @@
"private": true, "private": true,
"description": "Build tools for the VisualEditor-MediaWiki extension.", "description": "Build tools for the VisualEditor-MediaWiki extension.",
"scripts": { "scripts": {
"eslint": "eslint --cache --ext .js,.json .",
"eslint-fix": "eslint --cache --ext .js,.json --fix .",
"api-testing": "mocha --timeout 0 --parallel --recursive tests/api-testing", "api-testing": "mocha --timeout 0 --parallel --recursive tests/api-testing",
"test": "grunt test", "test": "grunt test",
"doc": "jsduck", "doc": "jsduck",

View file

@ -1,3 +1,53 @@
'use strict'; 'use strict';
// TBD const { action, assert, utils } = require( 'api-testing' );
describe( 'Visual Editor API', function () {
// const titles = ( list ) => list.map( ( p ) => utils.dbkey( p.title ) );
const title = utils.title( 'VisualEditor' );
let alice;
let pageInfo;
before( async () => {
alice = await action.alice();
const textX = 'Hello World! {{Template Requests}}';
pageInfo = await
alice.edit( title, { text: textX } );
} );
// https://en.wikipedia.org/w/api.php?action=visualeditor&format=json&page=Davido%20Adeleke&paction=metadata
it( 'can load metadata', async () => {
const result = await alice.action( 'visualeditor', { page: title, paction: 'metadata' } );
assert.equal( result.visualeditor.oldid, pageInfo.newrevid );
} );
it( 'able to parse', async () => {
const result = await alice.action( 'visualeditor', { page: title, paction: 'parse' } );
assert.equal( result.visualeditor.result, 'success' );
} );
it( 'able to parsedoc', async () => {
const result = await alice.action( 'visualeditor', { page: title, paction: 'parsedoc', wikitext: 'test' } );
assert.equal( result.visualeditor.result, 'success' );
} );
it( 'able to parsefragment', async () => {
const result = await alice.action( 'visualeditor', { page: title, paction: 'parsefragment', wikitext: 'test' } );
assert.equal( result.visualeditor.result, 'success' );
} );
it( 'templatesUsed', async () => {
const result = await alice.action( 'visualeditor', { page: title, paction: 'templatesused', wikitext: 'test' } );
assert.include( result.visualeditor, 'Template Requests' );
} );
it( 'can load metadata', async () => {
const result = await alice.action( 'visualeditor', { page: title, paction: 'wikitext' } );
assert.equal( result.visualeditor.result, 'success' );
} );
} );