| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
{ |
| 8 |
QUnit.module( 've.ui.MWTransclusionDialog', ve.test.utils.newMwEnvironment( { |
| 9 |
config: { |
| 10 |
|
| 11 |
|
| 12 |
wgVisualEditorConfig: ve.extendObject( {}, mw.config.get( 'wgVisualEditorConfig' ), { |
| 13 |
transclusionDialogNewSidebar: true |
| 14 |
} ) |
| 15 |
} |
| 16 |
} ) ); |
| 17 |
|
| 18 |
const createFragmentFromDoc = function ( doc ) { |
| 19 |
|
| 20 |
const surface = new ve.dm.Surface( doc ); |
| 21 |
|
| 22 |
const fragment = surface.getLinearFragment( new ve.Range( 1 ) ); |
| 23 |
|
| 24 |
|
| 25 |
return { fragment: fragment }; |
| 26 |
}; |
| 27 |
|
| 28 |
QUnit.test.skip( 'onReplacePart', ( assert ) => { |
| 29 |
|
| 30 |
const finishTest = assert.async(); |
| 31 |
|
| 32 |
|
| 33 |
const doc = ve.dm.Document.static.newBlankDocument(); |
| 34 |
const fragment = createFragmentFromDoc( doc ); |
| 35 |
|
| 36 |
|
| 37 |
const dialog = new ve.ui.MWTransclusionDialog(); |
| 38 |
const windowManager = new OO.ui.WindowManager(); |
| 39 |
windowManager.addWindows( [ dialog ] ); |
| 40 |
const windowInstance = windowManager.openWindow( dialog, fragment ); |
| 41 |
|
| 42 |
windowInstance.opened.done( () => { |
| 43 |
const transclusion = dialog.transclusionModel; |
| 44 |
|
| 45 |
const templateData = { |
| 46 |
title: 'Template:Test', |
| 47 |
params: { |
| 48 |
Blub: { |
| 49 |
label: 'Blub', |
| 50 |
description: 'blub', |
| 51 |
type: 'string', |
| 52 |
required: true |
| 53 |
}, |
| 54 |
Foo: { |
| 55 |
label: 'Foo', |
| 56 |
description: 'Foo', |
| 57 |
type: 'string', |
| 58 |
required: true |
| 59 |
} |
| 60 |
} |
| 61 |
}; |
| 62 |
transclusion.cacheTemplateDataApiResponse( { pages: [ templateData ] } ); |
| 63 |
|
| 64 |
|
| 65 |
const data = { |
| 66 |
target: { |
| 67 |
title: 'Template:Test', |
| 68 |
wt: 'Test', |
| 69 |
href: 'Template:Test' |
| 70 |
}, |
| 71 |
params: { |
| 72 |
test: { |
| 73 |
} |
| 74 |
}, |
| 75 |
i: 0 |
| 76 |
}; |
| 77 |
const template = ve.dm.MWTemplateModel.newFromData( transclusion, data ); |
| 78 |
|
| 79 |
|
| 80 |
const promise = transclusion.addPart( template ); |
| 81 |
|
| 82 |
promise.done( () => { |
| 83 |
|
| 84 |
|
| 85 |
assert.strictEqual( |
| 86 |
dialog.$element.find( '.ve-ui-mwTransclusionOutlineParameterWidget' ).length, 3 |
| 87 |
); |
| 88 |
dialog.close(); |
| 89 |
} ); |
| 90 |
|
| 91 |
} ).fail( () => { |
| 92 |
assert.true( false ); |
| 93 |
finishTest(); |
| 94 |
} ); |
| 95 |
|
| 96 |
windowInstance.closed.then( () => { |
| 97 |
assert.true( true ); |
| 98 |
finishTest(); |
| 99 |
} ); |
| 100 |
} ); |
| 101 |
} |