mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWReferenceDialog.test.js
mareikeheuer 2ffbf1fa66 Display extends warning message when editing a reference
MVP implementation for adding a warning when editing a reference
that's the extension of another. In the current approach we're
just using the elements .text() like we do when you create an
extended reference.

Bug: T247922
Change-Id: I2fc574152059937b4aa3fc25ee486d363cc809d5
2024-07-03 07:18:35 +02:00

38 lines
1.1 KiB
JavaScript

'use strict';
QUnit.module( 've.ui.MWReferenceDialog (Cite)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'setReferenceForEditing', ( assert ) => {
const dialog = new ve.ui.MWReferenceDialog();
dialog.referenceGroupInput = new ve.ui.MWReferenceGroupInputWidget( {} );
dialog.reuseWarning = new OO.ui.MessageWidget();
dialog.extendsWarning = new OO.ui.MessageWidget();
// XXX: This is a regression test with a fragile setup. Please feel free to delete this test
// when you feel like it doesn't make sense to update it.
dialog.referenceTarget = {
setDocument: () => null
};
dialog.fragment = {
getDocument: () => ( {
getInternalList: () => ( {
getNodeGroup: () => null
} )
} )
};
const parentDoc = {
cloneWithData: () => null
};
const ref = new ve.dm.MWReferenceModel( parentDoc );
ref.setGroup( 'g' );
dialog.setReferenceForEditing( ref );
assert.strictEqual( dialog.referenceModel, ref );
assert.strictEqual( dialog.originalGroup, 'g' );
assert.strictEqual( dialog.referenceGroupInput.getValue(), 'g' );
assert.false( dialog.referenceGroupInput.isDisabled() );
assert.false( dialog.reuseWarning.isVisible() );
} );