mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-11 05:56:11 +00:00
e1e02fa0d8
New changes: abf8f41 Replace Array#concat with Array#push in converter 02aeb90 Localisation updates from https://translatewiki.net. 902ddda Use safer batchPush in converter 6368191 Use current surface's sequence registry in command help dialog f7ce4b9 Optimize batchPush on small lists fb43a0a ve.batchPush: add unit test to exercise long-array path d6c7d24 Factor out RESTBase ID regular expression ffcbf4b IndentationCommand: Use hasMatchingAncestor d447023 Allow ommission of range from ve.dm.Document cloneFromRange cfbc344 Don't strip empty paragraphs on paste if they are generated 01c918b Localisation updates from https://translatewiki.net. 1467947 Fix documentation of getMetadataIdRegExp Local changes: * Define RESTBase ID pattern in platform and fix slightly * Bring in paste test from core, which requires platform switching. Bug: T147607 Depends-On: Ifc1c15872a50f915e5ef8d561b3a363dc5f4d28f Change-Id: I3eb21e115de92a67afa85b5675fcbca5b111adb6
103 lines
3.1 KiB
JavaScript
103 lines
3.1 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MediaWiki-specific Surface tests.
|
|
*
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ce.Surface (MW)', ve.test.utils.mwEnvironment );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'handleLinearDelete', function ( assert ) {
|
|
var i,
|
|
blocklength = ve.dm.mwExample.MWBlockImage.data.length,
|
|
cases = [
|
|
// This asserts that getRelativeRange (via getRelativeOffset) doesn't try to
|
|
// enter a handleOwnChildren node
|
|
{
|
|
htmlOrDoc:
|
|
ve.dm.mwExample.MWBlockImage.html +
|
|
'<ul><li><p>Foo</p></li><li><p>Bar</p></li></ul>',
|
|
rangeOrSelection: new ve.Range( blocklength + 3 ),
|
|
keys: [ 'BACKSPACE' ],
|
|
expectedData: function ( data ) {
|
|
// remove the first list item, and replace its wrapped paragraph outside
|
|
// the start of the list
|
|
data.splice(
|
|
blocklength, 8,
|
|
{ type: 'paragraph' },
|
|
'F', 'o', 'o',
|
|
{ type: '/paragraph' },
|
|
{ type: 'list', attributes: { style: 'bullet' } }
|
|
);
|
|
},
|
|
expectedRangeOrSelection: new ve.Range( blocklength + 1 ),
|
|
msg: 'Backspace in a list next to a block image doesn\'t merge into the caption'
|
|
},
|
|
{
|
|
htmlOrDoc:
|
|
ve.dm.mwExample.MWBlockImage.html +
|
|
'<ul><li><p></p></li></ul>',
|
|
rangeOrSelection: new ve.Range( blocklength + 3 ),
|
|
keys: [ 'BACKSPACE' ],
|
|
expectedData: function ( data ) {
|
|
data.splice(
|
|
blocklength, 6,
|
|
{ type: 'paragraph' },
|
|
{ type: '/paragraph' }
|
|
);
|
|
},
|
|
expectedRangeOrSelection: new ve.Range( blocklength + 1 ),
|
|
msg: 'Backspace in an empty list next to a block image removes the list'
|
|
}
|
|
];
|
|
|
|
QUnit.expect( cases.length * 2 );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
ve.test.utils.runSurfaceHandleSpecialKeyTest(
|
|
assert, cases[ i ].htmlOrDoc, cases[ i ].rangeOrSelection, cases[ i ].keys,
|
|
cases[ i ].expectedData, cases[ i ].expectedRangeOrSelection, cases[ i ].msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
QUnit.test( 'beforePaste/afterPaste', function ( assert ) {
|
|
var i, expected = 0,
|
|
cases = [
|
|
{
|
|
documentHtml: '<p></p>',
|
|
rangeOrSelection: new ve.Range( 1 ),
|
|
pasteHtml: '<span typeof="mw:Entity" id="mwAB">-</span><span typeof="mw:Entity" id="mw-reference-cite">-</span>',
|
|
fromVe: true,
|
|
expectedRangeOrSelection: new ve.Range( 5 ),
|
|
expectedHtml: '<p><span typeof="mw:Entity">-</span><span typeof="mw:Entity" id="mw-reference-cite">-</span></p>',
|
|
msg: 'RESTBase IDs stripped'
|
|
}
|
|
];
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
if ( cases[ i ].expectedOps ) {
|
|
expected++;
|
|
}
|
|
if ( cases[ i ].expectedRangeOrSelection ) {
|
|
expected++;
|
|
}
|
|
if ( cases[ i ].expectedHtml ) {
|
|
expected++;
|
|
}
|
|
}
|
|
QUnit.expect( expected );
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
|
ve.test.utils.runSurfacePasteTest(
|
|
assert, cases[ i ].documentHtml,
|
|
cases[ i ].pasteHtml, cases[ i ].internalSourceRangeOrSelection, cases[ i ].fromVe, cases[ i ].useClipboardData,
|
|
cases[ i ].pasteTargetHtml, cases[ i ].rangeOrSelection, cases[ i ].pasteSpecial,
|
|
cases[ i ].expectedOps, cases[ i ].expectedRangeOrSelection, cases[ i ].expectedHtml,
|
|
cases[ i ].store, false, cases[ i ].msg
|
|
);
|
|
}
|
|
} );
|