2017-03-28 17:15:25 +00:00
|
|
|
/* global seleniumUtils, langs */
|
2019-02-20 20:23:43 +00:00
|
|
|
/* eslint-disable no-jquery/no-global-selector */
|
2017-03-28 17:15:25 +00:00
|
|
|
|
|
|
|
( function () {
|
|
|
|
'use strict';
|
|
|
|
var createScreenshotEnvironment = require( './screenshots.js' ).createScreenshotEnvironment,
|
2017-04-28 15:01:22 +00:00
|
|
|
test = require( 'selenium-webdriver/testing' ),
|
|
|
|
runScreenshotTest = createScreenshotEnvironment( test );
|
2017-03-28 17:15:25 +00:00
|
|
|
|
|
|
|
function runTests( lang ) {
|
|
|
|
|
|
|
|
test.describe( 'Screenshots: ' + lang, function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
this.lang = lang;
|
2017-03-28 17:15:25 +00:00
|
|
|
test.it( 'Toolbar & action tools', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_toolbar', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ];
|
2017-04-19 11:48:59 +00:00
|
|
|
// HACK: The test page is on the help namespace, so overwrite the
|
|
|
|
// read tab with the nstab-main message.
|
|
|
|
new mw.Api().loadMessagesIfMissing( [ 'nstab-main' ], { amenableparser: true } ).then( function () {
|
|
|
|
$( '#ca-nstab-help a' ).text( mw.msg( 'nstab-main' ) );
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.toolbar.$element[ 0 ],
|
|
|
|
$( '#p-namespaces' )[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
2017-03-28 17:15:25 +00:00
|
|
|
},
|
|
|
|
0
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_toolbar_actions', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ];
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.toolbar.$actions[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
},
|
|
|
|
0
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Citoid inspector', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Citoid_Inspector', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ],
|
|
|
|
surface = ve.init.target.surface;
|
2019-04-02 21:04:08 +00:00
|
|
|
// citefromid is being renamed (T219512)
|
|
|
|
( ve.init.target.toolbar.tools.citoid || ve.init.target.toolbar.tools.citefromid ).onSelect();
|
2017-03-28 17:15:25 +00:00
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 500 );
|
|
|
|
}
|
|
|
|
);
|
2017-11-13 17:39:47 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Citoid_Inspector_Manual', lang,
|
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ],
|
|
|
|
surface = ve.init.target.surface;
|
|
|
|
ve.init.target.surface.context.inspectors.currentWindow.setModePanel( 'manual' );
|
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
runScreenshotTest( 'VisualEditor_Citoid_Inspector_Reuse', lang,
|
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ],
|
|
|
|
surface = ve.init.target.surface;
|
|
|
|
ve.init.target.surface.context.inspectors.currentWindow.setModePanel( 'reuse' );
|
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-mwReferenceNode' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
);
|
2017-03-28 17:15:25 +00:00
|
|
|
} );
|
|
|
|
test.it( 'Tool groups (headings/text style/indentation/insert/page settings)', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Toolbar_Headings', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.paragraph );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Toolbar_Formatting', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.bold, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Toolbar_Lists_and_indentation', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.bullet );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Insert_Menu', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.media, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Media_Insert_Menu', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.media, false, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Template_Insert_Menu', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.transclusion, false, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_insert_table', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.insertTable, false, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Formula_Insert_Menu', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.math, true, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_References_List_Insert_Menu', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.toolbar.tools.referencesList, true, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_More_Settings', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.actionsToolbar.tools.advancedSettings, false, false,
|
|
|
|
[ ve.init.target.toolbarSaveButton.$element[ 0 ] ]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_page_settings_item', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.actionsToolbar.tools.settings, false, true );
|
|
|
|
}
|
|
|
|
);
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_category_item', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
seleniumUtils.runMenuTask( arguments[ arguments.length - 1 ], ve.init.target.actionsToolbar.tools.categories, false, true );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Save dialog', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_save_dialog', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ];
|
2019-04-15 22:39:56 +00:00
|
|
|
ve.init.target.toolbarSaveButton.onSelect();
|
2017-03-28 17:15:25 +00:00
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.surface.dialogs.currentWindow.$frame[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 500 );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Special character inserter', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_Toolbar_SpecialCharacters', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ];
|
|
|
|
ve.init.target.toolbar.tools.specialCharacter.onSelect();
|
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
ve.init.target.toolbar.tools.specialCharacter.$element[ 0 ],
|
|
|
|
ve.init.target.surface.toolbarDialogs.$element[ 0 ]
|
2017-07-18 11:55:33 +00:00
|
|
|
] )
|
|
|
|
);
|
2017-03-28 17:15:25 +00:00
|
|
|
}, 1000 );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Math dialog', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_formula', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ],
|
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
|
|
|
surface.dialogs.once( 'opening', function ( win, opening ) {
|
|
|
|
opening.then( function () {
|
|
|
|
win.previewElement.once( 'render', function () {
|
|
|
|
win.previewElement.$element.find( 'img' ).on( 'load', function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
win.$frame[ 0 ]
|
2017-07-18 11:55:33 +00:00
|
|
|
] )
|
|
|
|
);
|
2017-03-28 17:15:25 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
win.input.setValue( 'E = mc^2' ).moveCursorToEnd();
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
surface.executeCommand( 'mathDialog' );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Reference list dialog', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_references_list', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ],
|
|
|
|
surface = ve.init.target.surface;
|
|
|
|
|
|
|
|
surface.dialogs.once( 'opening', function ( win, opening ) {
|
|
|
|
opening.then( function () {
|
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
win.$frame[ 0 ]
|
2017-07-18 11:55:33 +00:00
|
|
|
] )
|
|
|
|
);
|
2017-03-28 17:15:25 +00:00
|
|
|
}, 500 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
surface.executeCommand( 'referencesList' );
|
|
|
|
// The first command inserts a reference list instantly, so run again to open the window
|
|
|
|
surface.executeCommand( 'referencesList' );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Cite button', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor_citoid_Cite_button', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ];
|
|
|
|
|
|
|
|
ve.init.target.$element.css( 'font-size', '250%' );
|
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
2019-04-02 21:04:08 +00:00
|
|
|
// citefromid is being renamed (T219512)
|
|
|
|
( ve.init.target.toolbar.tools.citoid || ve.init.target.toolbar.tools.citefromid ).$element[ 0 ]
|
2017-03-28 17:15:25 +00:00
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
0
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
test.it( 'Link inspector', function () {
|
2017-04-28 15:01:22 +00:00
|
|
|
runScreenshotTest( 'VisualEditor-link_tool-search_results', lang,
|
2017-03-28 17:15:25 +00:00
|
|
|
// This function is converted to a string and executed in the browser
|
|
|
|
function () {
|
|
|
|
var done = arguments[ arguments.length - 1 ],
|
|
|
|
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();
|
|
|
|
|
|
|
|
surface.context.inspectors.once( 'opening', function ( win, opening ) {
|
|
|
|
opening.then( function () {
|
|
|
|
surface.context.inspectors.windows.link.annotationInput.input.requestRequest.then( function () {
|
|
|
|
// 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.
|
|
|
|
setTimeout( function () {
|
|
|
|
done(
|
|
|
|
seleniumUtils.getBoundingRect( [
|
|
|
|
surface.$element.find( '.ve-ce-linkAnnotation' )[ 0 ],
|
|
|
|
surface.context.inspectors.currentWindow.$element[ 0 ]
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
}, 2500 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
ve.init.target.surface.executeCommand( 'link' );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( let i = 0, l = langs.length; i < l; i++ ) {
|
|
|
|
runTests( langs[ i ] );
|
|
|
|
}
|
|
|
|
}() );
|