mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWReferenceDialog.test.js
WMDE-Fisch 36d9270c1c Introduce MWReferenceEditPanel to extract editing UI
First step to move the UI parts that are relevant for creating,
editing (and extending) a reference to it's own class.

There remains some duplication because of the sub-referencing in
Citoid currently depending on the static properties to build its
own editing interface.

More patches follow, I just wanted to keep it small for reviewers.

Bug: T369005
Change-Id: I8588cde1a54cd505a57a36ed97fc591653c9fb6f
2024-07-18 14:46:23 +02:00

39 lines
1.2 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.editPanel = {};
dialog.editPanel.referenceGroupInput = new ve.ui.MWReferenceGroupInputWidget( {} );
dialog.editPanel.reuseWarning = new OO.ui.MessageWidget();
dialog.editPanel.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.editPanel.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.editPanel.referenceGroupInput.getValue(), 'g' );
assert.false( dialog.editPanel.referenceGroupInput.isDisabled() );
assert.false( dialog.editPanel.reuseWarning.isVisible() );
} );