2020-04-17 21:55:45 +00:00
|
|
|
/* eslint-disable no-jquery/no-global-selector */
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
toolbar: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ];
|
2020-04-17 21:55:45 +00:00
|
|
|
// HACK: The test page is on the help namespace, so overwrite the
|
|
|
|
// read tab with the nstab-main message.
|
2024-04-30 16:44:25 +00:00
|
|
|
new mw.Api().loadMessagesIfMissing( [ 'nstab-main' ], { amenableparser: true } ).then( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
$( '#ca-nstab-help a' ).text( mw.msg( 'nstab-main' ) );
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.toolbar.$element[ 0 ],
|
2023-07-03 13:12:08 +00:00
|
|
|
$( '#ca-view' )[ 0 ]
|
2020-04-17 21:55:45 +00:00
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
toolbarActions: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ];
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
2023-07-03 13:12:08 +00:00
|
|
|
ve.init.target.toolbar.$after[ 0 ]
|
2020-04-17 21:55:45 +00:00
|
|
|
] )
|
|
|
|
);
|
|
|
|
},
|
|
|
|
citoidInspector: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-04-17 21:55:45 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
ve.init.target.toolbar.tools.citoid.onSelect();
|
2024-04-30 16:44:25 +00:00
|
|
|
setTimeout( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 500 );
|
|
|
|
},
|
|
|
|
citoidInspectorManual: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-04-17 21:55:45 +00:00
|
|
|
surface = ve.init.target.surface;
|
2020-08-25 15:18:04 +00:00
|
|
|
surface.context.inspectors.currentWindow.setModePanel( 'manual' );
|
2024-04-30 16:44:25 +00:00
|
|
|
setTimeout( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
citoidInspectorReuse: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-04-17 21:55:45 +00:00
|
|
|
surface = ve.init.target.surface;
|
2020-08-25 15:18:04 +00:00
|
|
|
surface.context.inspectors.currentWindow.setModePanel( 'reuse' );
|
2024-04-30 16:44:25 +00:00
|
|
|
setTimeout( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
citoidInspectorTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-08-25 15:18:04 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
surface.context.inspectors.currentWindow.close().closed.then( done );
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
toolbarHeadings: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.paragraph );
|
|
|
|
},
|
|
|
|
toolbarFormatting: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.bold, true );
|
|
|
|
},
|
|
|
|
toolbarLists: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.bullet );
|
|
|
|
},
|
|
|
|
toolbarInsert: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.media, true );
|
|
|
|
},
|
|
|
|
toolbarMedia: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.media, false, true );
|
|
|
|
},
|
|
|
|
toolbarTemplate: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.transclusion, false, true );
|
|
|
|
},
|
|
|
|
toolbarTable: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.insertTable, false, true );
|
|
|
|
},
|
|
|
|
toolbarFormula: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.math, true, true );
|
|
|
|
},
|
|
|
|
toolbarReferences: function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.referencesList, true, true );
|
|
|
|
},
|
|
|
|
toolbarSettings: function () {
|
2023-04-27 13:51:35 +00:00
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.advancedSettings, false, false,
|
2020-04-17 21:55:45 +00:00
|
|
|
[ ve.init.target.toolbarSaveButton.$element[ 0 ] ]
|
|
|
|
);
|
|
|
|
},
|
|
|
|
toolbarPageSettings: function () {
|
2023-04-27 13:51:35 +00:00
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.settings, false, true );
|
2020-04-17 21:55:45 +00:00
|
|
|
},
|
|
|
|
toolbarCategory: function () {
|
2023-04-27 13:51:35 +00:00
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.categories, false, true );
|
2020-04-17 21:55:45 +00:00
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
toolbarTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ];
|
2020-08-25 15:18:04 +00:00
|
|
|
seleniumUtils.collapseToolbar();
|
|
|
|
done();
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
save: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-06-25 17:36:21 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.dialogs.once( 'opening', ( win, opening ) => {
|
|
|
|
opening.then( () => {
|
|
|
|
setTimeout( () => {
|
2020-06-25 17:36:21 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.surface.dialogs.currentWindow.$frame[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 500 );
|
|
|
|
} );
|
|
|
|
} );
|
2020-04-17 21:55:45 +00:00
|
|
|
ve.init.target.toolbarSaveButton.onSelect();
|
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
saveTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-08-25 15:18:04 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
surface.dialogs.currentWindow.close().closed.then( done );
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
specialCharacters: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-06-25 17:36:21 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.getToolbarDialogs().once( 'opening', ( win, opening ) => {
|
|
|
|
opening.then( () => {
|
|
|
|
setTimeout( () => {
|
2020-06-25 17:36:21 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.toolbar.tools.specialCharacter.$element[ 0 ],
|
|
|
|
ve.init.target.surface.toolbarDialogs.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 500 );
|
|
|
|
} );
|
|
|
|
} );
|
2020-04-17 21:55:45 +00:00
|
|
|
ve.init.target.toolbar.tools.specialCharacter.onSelect();
|
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
specialCharactersTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-08-25 15:18:04 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
surface.getToolbarDialogs().currentWindow.close().closed.then( done );
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
formula: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-04-17 21:55:45 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.dialogs.once( 'opening', ( win, opening ) => {
|
|
|
|
opening.then( () => {
|
|
|
|
win.previewElement.once( 'render', () => {
|
|
|
|
win.previewElement.$element.find( 'img' ).on( 'load', () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
win.$frame[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
win.input.setValue( 'E = mc^2' ).moveCursorToEnd();
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
surface.executeCommand( 'mathDialog' );
|
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
formulaTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-08-25 15:18:04 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
surface.dialogs.currentWindow.close().closed.then( done );
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
referenceList: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-04-17 21:55:45 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.dialogs.once( 'opening', ( win, opening ) => {
|
|
|
|
opening.then( () => {
|
|
|
|
setTimeout( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
win.$frame[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 500 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
surface.executeCommand( 'referencesList' );
|
|
|
|
// The first command inserts a reference list instantly, so run again to open the window
|
|
|
|
surface.executeCommand( 'referencesList' );
|
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
referenceListTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-08-25 15:18:04 +00:00
|
|
|
surface = ve.init.target.surface;
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.dialogs.currentWindow.close().closed.then( () => {
|
2020-08-25 15:18:04 +00:00
|
|
|
// Remove the reference list
|
|
|
|
surface.getModel().undo();
|
|
|
|
done();
|
|
|
|
} );
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
toolbarCite: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ];
|
2020-04-17 21:55:45 +00:00
|
|
|
|
2020-06-25 17:39:52 +00:00
|
|
|
ve.init.target.toolbar.tools.citoid.$element.css( 'font-size', '250%' );
|
2020-04-17 21:55:45 +00:00
|
|
|
// Wait for re-paint
|
2024-04-30 16:44:25 +00:00
|
|
|
setTimeout( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.toolbar.tools.citoid.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 100 );
|
|
|
|
},
|
2020-08-25 15:18:04 +00:00
|
|
|
toolbarCiteTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ];
|
2020-08-25 15:18:04 +00:00
|
|
|
ve.init.target.toolbar.tools.citoid.$element.css( 'font-size', '' );
|
|
|
|
done();
|
|
|
|
},
|
2020-04-17 21:55:45 +00:00
|
|
|
linkSearchResults: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-04-17 21:55:45 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
|
|
|
surface.getModel().getFragment()
|
|
|
|
// TODO: i18n this message, the linked word, and the API endpoint of the link inspector
|
|
|
|
.insertContent( 'World literature is literature that is read by many people all over' )
|
|
|
|
.collapseToStart().select();
|
|
|
|
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.context.inspectors.once( 'opening', ( win, opening ) => {
|
|
|
|
opening.then( () => {
|
|
|
|
surface.context.inspectors.windows.link.annotationInput.input.requestRequest.then( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
// Wait a while for the images to load using a time guesstimate - as they're background
|
|
|
|
// images it's quite tricky to get load events.
|
2024-04-30 16:44:25 +00:00
|
|
|
setTimeout( () => {
|
2020-04-17 21:55:45 +00:00
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-linkAnnotation' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 2500 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
ve.init.target.surface.executeCommand( 'link' );
|
2020-08-25 15:18:04 +00:00
|
|
|
},
|
|
|
|
linkSearchResultsTeardown: function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const done = arguments[ arguments.length - 1 ],
|
2020-08-25 15:18:04 +00:00
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
2024-04-30 16:44:25 +00:00
|
|
|
surface.context.inspectors.currentWindow.close().closed.then( () => {
|
2020-08-25 15:18:04 +00:00
|
|
|
// Remove content
|
|
|
|
surface.getModel().undo();
|
|
|
|
done();
|
|
|
|
} );
|
2020-04-17 21:55:45 +00:00
|
|
|
}
|
|
|
|
};
|