mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-24 20:13:08 +00:00
6cbedbf9d2
* Remove need for manual hacking of sub groups via "msg" strings carefully prepended to every assertion. * Improve CI details, by reporting the specific case that failed, and local dev via ability to re-run each case, and reporting names directly in the HTML Reporter and CLI summary. * Reduce need for assert.async() and tracking of callbacks, especially to improve failure details in case of Promise rejection. Current logic was likely to cause a confusing timeout instead of a clear failure if the promise ends up rejected. QUnit propagates these as part of awaiting and asserting the test closure's promise value (as async fn) automatically. This approach also avoids the pitfal of a falsely passing test when an assertion inside a done() handler was never reached. * Use modern for-of where possible to remove need for closures and arrow functions. Thus reducing complexity of test code, where complexity should be kept lowest to avoid false confidence. * Use plain for-in instead of overly complex Object.keys().forEach(). Change-Id: I934a266e75e64371081f104cfb867fb2c282c84a
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
/*!
|
|
* VisualEditor MW-specific DiffElement tests.
|
|
*
|
|
* @copyright See AUTHORS.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ui.DiffElement (MW)', ve.test.utils.newMwEnvironment() );
|
|
|
|
QUnit.test.each( 'Diffing',
|
|
[
|
|
{
|
|
msg: 'Change template param',
|
|
oldDoc: ve.test.utils.addBaseTag(
|
|
ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent,
|
|
ve.dm.example.baseUri
|
|
),
|
|
newDoc: ve.test.utils.addBaseTag(
|
|
ve.dm.mwExample.MWTransclusion.blockOpenModified + ve.dm.mwExample.MWTransclusion.blockContent,
|
|
ve.dm.example.baseUri
|
|
),
|
|
expected:
|
|
( ve.dm.mwExample.MWTransclusion.blockOpenModified + ve.dm.mwExample.MWTransclusion.blockContent )
|
|
// FIXME: Use DOM modification instead of string replaces
|
|
.replace( /#mwt1"/g, '#mwt1" data-diff-action="structural-change" data-diff-id="0"' ),
|
|
expectedDescriptions: [
|
|
ve.dm.example.singleLine`
|
|
<div>visualeditor-changedesc-mwtransclusion</div>
|
|
<div>
|
|
<ul>
|
|
<li>
|
|
visualeditor-changedesc-changed-diff,1,<span>Hello, <del>world</del><ins>globe</ins>!</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
`
|
|
]
|
|
},
|
|
{
|
|
msg: 'Changed width of block image',
|
|
oldDoc: ve.test.utils.addBaseTag(
|
|
ve.dm.mwExample.MWBlockImage.html,
|
|
ve.dm.example.baseUri
|
|
),
|
|
newDoc: ve.test.utils.addBaseTag(
|
|
ve.dm.mwExample.MWBlockImage.html.replace( 'width="1"', 'width="3"' ),
|
|
ve.dm.example.baseUri
|
|
),
|
|
expected:
|
|
ve.dm.mwExample.MWBlockImage.html
|
|
// FIXME: Use DOM modification instead of string replaces
|
|
.replace( 'width="1"', 'width="3"' )
|
|
.replace( 'href="./Foo"', 'href="' + new URL( './Foo', ve.dm.example.baseUri ) + '"' )
|
|
.replace( 'foobar"', 'foobar" data-diff-action="structural-change" data-diff-id="0"' ),
|
|
expectedDescriptions: [
|
|
ve.dm.example.singleLine`
|
|
<div>
|
|
visualeditor-changedesc-image-size,
|
|
<del>1visualeditor-dimensionswidget-times2visualeditor-dimensionswidget-px</del>,
|
|
<ins>3visualeditor-dimensionswidget-times2visualeditor-dimensionswidget-px</ins>
|
|
</div>
|
|
`
|
|
]
|
|
}
|
|
],
|
|
( assert, caseItem ) => {
|
|
ve.test.utils.runDiffElementTest( assert, caseItem );
|
|
}
|
|
);
|