mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-11 14:46:11 +00:00
6ea3a8c696
Reverses the previous logic which traversed up from a fragment to get the full document's refs. Much other code in VE isn't ready for this behavior, for example we can see list-defined refs but not inline refs defined outside of the fragment. This patch will ensure that we're only looking at refs accessible from the current fragment, and prevents caching on fragments because the cache uses `persistentStorage`, which is shared between fragments and their parent document. Bug: T374068 Change-Id: Ia38098f8b3e5a9d24c2206e11edab37d60209225
35 lines
923 B
JavaScript
35 lines
923 B
JavaScript
'use strict';
|
|
|
|
QUnit.module( 've.ui.MWUseExistingReferenceCommand (Cite)', ve.test.utils.newMwEnvironment() );
|
|
|
|
function getFragmentMock( hasRefs ) {
|
|
const docRefsMock = {
|
|
hasRefs: () => hasRefs
|
|
};
|
|
|
|
return {
|
|
getDocument: () => ( {
|
|
getOriginalDocument: () => undefined,
|
|
getStorage: () => docRefsMock,
|
|
setStorage: () => undefined
|
|
} ),
|
|
getSelection: () => ( {
|
|
getName: () => 'linear'
|
|
} )
|
|
};
|
|
}
|
|
|
|
QUnit.test( 'Constructor', ( assert ) => {
|
|
const command = new ve.ui.MWUseExistingReferenceCommand();
|
|
assert.strictEqual( command.name, 'reference/existing' );
|
|
assert.strictEqual( command.action, 'window' );
|
|
assert.strictEqual( command.method, 'open' );
|
|
} );
|
|
|
|
QUnit.test( 'isExecutable', ( assert ) => {
|
|
const command = new ve.ui.MWUseExistingReferenceCommand();
|
|
|
|
assert.false( command.isExecutable( getFragmentMock( false ) ) );
|
|
assert.true( command.isExecutable( getFragmentMock( true ) ) );
|
|
} );
|