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

Bug: T318403
Change-Id: I7a607edc69d8fcf51a634ce0f536548979eef95b
This commit is contained in:
Emeka Chukwukere 2022-09-21 13:20:58 -05:00 committed by daniel
parent 50c6aa8c01
commit 5b5ed387c9
4 changed files with 60 additions and 2 deletions

View file

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

1
.gitignore vendored
View file

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

View file

@ -4,6 +4,8 @@
"private": true,
"description": "Build tools for the VisualEditor-MediaWiki extension.",
"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",
"test": "grunt test",
"doc": "jsduck",

View file

@ -1,3 +1,53 @@
'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' );
} );
} );