2018-06-19 15:04:08 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MW-specific DiffElement tests.
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
|
2018-06-19 15:04:08 +00:00
|
|
|
*/
|
|
|
|
|
2022-03-04 13:48:14 +00:00
|
|
|
QUnit.module( 've.ui.DiffElement (MW)', ve.test.utils.newMwEnvironment() );
|
2018-06-19 15:04:08 +00:00
|
|
|
|
2021-04-30 09:33:22 +00:00
|
|
|
QUnit.test( 'Diffing', ( assert ) => {
|
2023-01-21 17:00:26 +00:00
|
|
|
const
|
2018-06-19 15:04:08 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
msg: 'Change template param',
|
2023-01-21 17:00:26 +00:00
|
|
|
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
|
|
|
|
),
|
2018-06-19 15:04:08 +00:00
|
|
|
expected:
|
2022-01-24 19:48:46 +00:00
|
|
|
( 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"' ),
|
2018-06-19 15:04:08 +00:00
|
|
|
expectedDescriptions: [
|
|
|
|
'<div>visualeditor-changedesc-mwtransclusion</div>' +
|
2021-01-22 17:35:36 +00:00
|
|
|
'<div><ul><li>visualeditor-changedesc-changed-diff,1,<span>Hello, <del>world</del><ins>globe</ins>!</span></li></ul></div>'
|
2018-06-19 15:04:08 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
msg: 'Changed width of block image',
|
2023-01-21 17:00:26 +00:00
|
|
|
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
|
|
|
|
),
|
2018-06-19 15:04:08 +00:00
|
|
|
expected:
|
2022-01-24 19:48:46 +00:00
|
|
|
ve.dm.mwExample.MWBlockImage.html
|
|
|
|
// FIXME: Use DOM modification instead of string replaces
|
|
|
|
.replace( 'width="1"', 'width="3"' )
|
2023-01-21 17:00:26 +00:00
|
|
|
.replace( 'href="./Foo"', 'href="' + new URL( './Foo', ve.dm.example.baseUri ) + '"' )
|
2022-01-24 19:48:46 +00:00
|
|
|
.replace( 'foobar"', 'foobar" data-diff-action="structural-change" data-diff-id="0"' ),
|
2018-06-19 15:04:08 +00:00
|
|
|
expectedDescriptions: [
|
|
|
|
'<div>visualeditor-changedesc-image-size,' +
|
|
|
|
'<del>1visualeditor-dimensionswidget-times2visualeditor-dimensionswidget-px</del>,' +
|
|
|
|
'<ins>3visualeditor-dimensionswidget-times2visualeditor-dimensionswidget-px</ins></div>'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2021-04-29 14:42:18 +00:00
|
|
|
for ( let i = 0; i < cases.length; i++ ) {
|
2018-06-19 15:04:08 +00:00
|
|
|
ve.test.utils.runDiffElementTest( assert, cases[ i ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
} );
|