mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Merge "More test cases for more complex template dialog functionality"
This commit is contained in:
commit
fdea0c5357
|
@ -40,3 +40,6 @@ QUnit.test( 'Basic functionality', ( assert ) => {
|
|||
widget.clear();
|
||||
assert.deepEqual( widget.partWidgets, {} );
|
||||
} );
|
||||
|
||||
// TODO: addPartWidget() with different positions.
|
||||
// TODO: onTransclusionModelChange() is complex and fragile and must be tested.
|
||||
|
|
|
@ -1,25 +1,28 @@
|
|||
QUnit.module( 've.ui.MWTransclusionOutlineParameterWidget' );
|
||||
|
||||
QUnit.test( 'interprets param with no attributes', ( assert ) => {
|
||||
const layout = new ve.ui.MWTransclusionOutlineParameterWidget( {} );
|
||||
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( {} );
|
||||
|
||||
assert.strictEqual( layout.checkbox.isDisabled(), false );
|
||||
assert.strictEqual( layout.checkbox.isSelected(), false );
|
||||
assert.strictEqual( layout.checkbox.getTitle(), null );
|
||||
assert.strictEqual( widget.checkbox.isDisabled(), false );
|
||||
assert.strictEqual( widget.checkbox.isSelected(), false );
|
||||
assert.strictEqual( widget.checkbox.getTitle(), null );
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets required param', ( assert ) => {
|
||||
const layout = new ve.ui.MWTransclusionOutlineParameterWidget( { required: true } );
|
||||
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { required: true } );
|
||||
|
||||
assert.strictEqual( layout.checkbox.isDisabled(), true );
|
||||
assert.strictEqual( layout.checkbox.isSelected(), true );
|
||||
assert.notStrictEqual( layout.checkbox.getTitle(), null );
|
||||
assert.strictEqual( widget.checkbox.isDisabled(), true );
|
||||
assert.strictEqual( widget.checkbox.isSelected(), true );
|
||||
assert.strictEqual(
|
||||
widget.checkbox.getTitle(),
|
||||
'visualeditor-dialog-transclusion-required-parameter'
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets selected param', ( assert ) => {
|
||||
const layout = new ve.ui.MWTransclusionOutlineParameterWidget( { selected: true } );
|
||||
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { selected: true } );
|
||||
|
||||
assert.strictEqual( layout.checkbox.isDisabled(), false );
|
||||
assert.strictEqual( layout.checkbox.isSelected(), true );
|
||||
assert.strictEqual( layout.checkbox.getTitle(), null );
|
||||
assert.strictEqual( widget.checkbox.isDisabled(), false );
|
||||
assert.strictEqual( widget.checkbox.isSelected(), true );
|
||||
assert.strictEqual( widget.checkbox.getTitle(), null );
|
||||
} );
|
||||
|
|
|
@ -11,3 +11,59 @@ QUnit.test( 'Constructor', ( assert ) => {
|
|||
'Example'
|
||||
);
|
||||
} );
|
||||
|
||||
// TODO: insertCheckboxAtCanonicalPosition() is complex and fragile and must be tested.
|
||||
|
||||
QUnit.test( 'filterParameters() on an empty template', ( assert ) => {
|
||||
const transclusion = new ve.dm.MWTransclusionModel(),
|
||||
template = new ve.dm.MWTemplateModel( transclusion, {} ),
|
||||
widget = new ve.ui.MWTransclusionOutlineTemplateWidget( template );
|
||||
|
||||
let eventsFired = 0;
|
||||
widget.connect( this, {
|
||||
filterParameters: ( visibility ) => {
|
||||
assert.deepEqual( visibility, {} );
|
||||
eventsFired++;
|
||||
}
|
||||
} );
|
||||
|
||||
widget.filterParameters( '' );
|
||||
assert.strictEqual( widget.infoWidget.isVisible(), true );
|
||||
assert.strictEqual( eventsFired, 1 );
|
||||
} );
|
||||
|
||||
QUnit.test( 'filterParameters() considers everything from the spec', ( assert ) => {
|
||||
const transclusion = new ve.dm.MWTransclusionModel(),
|
||||
template = ve.dm.MWTemplateModel.newFromData( transclusion, {
|
||||
target: {},
|
||||
params: { a: {}, b: {}, c: {}, d: {}, e: {} }
|
||||
} ),
|
||||
widget = new ve.ui.MWTransclusionOutlineTemplateWidget( template );
|
||||
|
||||
template.getSpec().setTemplateData( {
|
||||
params: {
|
||||
c: { label: 'Contains a' },
|
||||
d: { description: 'Contains a' },
|
||||
e: { aliases: [ 'Contains a' ] },
|
||||
f: { label: 'Also contains a, but is not used in the template' }
|
||||
}
|
||||
} );
|
||||
|
||||
let eventsFired = 0;
|
||||
widget.connect( this, {
|
||||
filterParameters: ( visibility ) => {
|
||||
assert.deepEqual( visibility, {
|
||||
'part_0/a': true,
|
||||
'part_0/b': false,
|
||||
'part_0/c': true,
|
||||
'part_0/d': true,
|
||||
'part_0/e': true
|
||||
} );
|
||||
eventsFired++;
|
||||
}
|
||||
} );
|
||||
|
||||
widget.filterParameters( ' A ' );
|
||||
assert.strictEqual( widget.infoWidget.isVisible(), false );
|
||||
assert.strictEqual( eventsFired, 1 );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue