Update VE core submodule to master (a8e0eef6d)

New changes:
a8e0eef6d Simplify usage of dummy target

Local changes:
Simplify usage of dummy target, ceating an MWDummyTarget, extending
DummyTarget instead of mw.ArticleTarget.

Depends-On: I01a6860387087db8149c73793e9bd4294d33aea8
Change-Id: I227486159fe416c219e2c37a1d054201084fe285
This commit is contained in:
Ed Sanders 2018-04-30 18:53:50 +01:00 committed by James D. Forrester
parent 1bd430c9d1
commit 3dd3073bd2
2 changed files with 85 additions and 98 deletions

2
lib/ve

@ -1 +1 @@
Subproject commit 099902ddb1f58cc82fc0f4045fb4ce8d19343588 Subproject commit a8e0eef6dfbb5b0de5556a8dd84dce55e41d90b6

View file

@ -5,40 +5,19 @@
* @license The MIT License (MIT); see LICENSE.txt * @license The MIT License (MIT); see LICENSE.txt
*/ */
ve.test.utils.createSurfaceFromDocument = function ( doc ) { ( function () {
// eslint-disable-next-line no-unused-vars var getDomElementSummaryCore;
var target, mwTarget, surface;
// Prevent the target from setting up the surface immediately function MWDummyTarget() {
ve.init.platform.initialized = $.Deferred(); MWDummyTarget.super.call( this );
// HACK: MW targets are async and heavy, use a DummyTarget
// but override the global registration
target = new ve.test.utils.DummyTarget();
// HACK: Mock setDefaultMode() because it causes untracked
// ajax requests (T162810)
// HACK: Has to be a subclass instead of assignment to mwTarget
// because it is called in the constructor
function SubMwArticleTarget() {
SubMwArticleTarget.super.call( this );
} }
OO.inheritClass( SubMwArticleTarget, ve.init.mw.ArticleTarget ); OO.inheritClass( MWDummyTarget, ve.test.utils.DummyTarget );
SubMwArticleTarget.prototype.setDefaultMode = function () {}; MWDummyTarget.prototype.setDefaultMode = function () {};
MWDummyTarget.prototype.parseWikitextFragment = function () {
mwTarget = new SubMwArticleTarget(); // Ensure a mock server is used (e.g. as in ve.ui.MWWikitextStringTransferHandler)
return new mw.Api().post();
$( '#qunit-fixture' ).append( target.$element );
target.addSurface( doc );
ve.init.platform.initialized.resolve();
mwTarget = null;
surface = target.addSurface( doc );
// HACK HACK HACK: The target fuckery above results in the surface not being attached to the DOM.
// I'm not debugging that, screw it. Let's add another hack on top, surely that won't be a problem.
$( '#qunit-fixture' ).append( surface.$element );
return surface;
}; };
ve.test.utils.MWDummyTarget = MWDummyTarget;
// Unregister MW override nodes. // Unregister MW override nodes.
// They are temporarily registered in setup/teardown. // They are temporarily registered in setup/teardown.
@ -51,7 +30,7 @@ ve.dm.modelRegistry.register( ve.dm.InlineImageNode );
ve.dm.modelRegistry.register( ve.dm.BlockImageNode ); ve.dm.modelRegistry.register( ve.dm.BlockImageNode );
ve.test.utils.mwEnvironment = ( function () { ve.test.utils.mwEnvironment = ( function () {
var mwPlatform, corePlatform, var mwPlatform, corePlatform, mwTarget, coreTarget,
overrides = [ overrides = [
ve.dm.MWHeadingNode, ve.dm.MWHeadingNode,
ve.dm.MWPreformattedNode, ve.dm.MWPreformattedNode,
@ -64,12 +43,17 @@ ve.test.utils.mwEnvironment = ( function () {
]; ];
corePlatform = ve.init.platform; corePlatform = ve.init.platform;
coreTarget = ve.init.target;
mwPlatform = new ve.init.mw.Platform(); mwPlatform = new ve.init.mw.Platform();
// Disable some API requests from platform // Disable some API requests from platform
mwPlatform.imageInfoCache = null; mwPlatform.imageInfoCache = null;
// Unregister mwPlatform // Unregister mwPlatform
ve.init.platform = corePlatform; ve.init.platform = corePlatform;
mwTarget = new ve.test.utils.MWDummyTarget();
// Unregister mwTarget
ve.init.target = coreTarget;
function setupOverrides() { function setupOverrides() {
var i; var i;
for ( i = 0; i < overrides.length; i++ ) { for ( i = 0; i < overrides.length; i++ ) {
@ -79,6 +63,9 @@ ve.test.utils.mwEnvironment = ( function () {
ve.dm.modelRegistry.unregister( overridden[ i ] ); ve.dm.modelRegistry.unregister( overridden[ i ] );
} }
ve.init.platform = mwPlatform; ve.init.platform = mwPlatform;
ve.init.target = mwTarget;
// Ensure the current target is appended to the current fixture
$( '#qunit-fixture' ).append( ve.init.target.$element );
} }
function teardownOverrides() { function teardownOverrides() {
@ -90,6 +77,7 @@ ve.test.utils.mwEnvironment = ( function () {
ve.dm.modelRegistry.register( overridden[ i ] ); ve.dm.modelRegistry.register( overridden[ i ] );
} }
ve.init.platform = corePlatform; ve.init.platform = corePlatform;
ve.init.target = coreTarget;
} }
// On load, teardown overrides so the first core tests run correctly // On load, teardown overrides so the first core tests run correctly
@ -101,8 +89,7 @@ ve.test.utils.mwEnvironment = ( function () {
}; };
}() ); }() );
( function () { getDomElementSummaryCore = ve.getDomElementSummary;
var getDomElementSummaryCore = ve.getDomElementSummary;
/** /**
* Override getDomElementSummary to extract HTML from data-mw/body.html * Override getDomElementSummary to extract HTML from data-mw/body.html