mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Run screenshot tests in series
Use one test context, and store language as a property. Change-Id: I4809c41331c4d70a024eec48f30eef207a09a098
This commit is contained in:
parent
c198ea287d
commit
63d711dd48
|
@ -3,57 +3,60 @@
|
|||
|
||||
( function () {
|
||||
'use strict';
|
||||
var createScreenshotEnvironment = require( './screenshots.js' ).createScreenshotEnvironment,
|
||||
var runScreenshotTest,
|
||||
createScreenshotEnvironment = require( './screenshots.js' ).createScreenshotEnvironment,
|
||||
test = require( 'selenium-webdriver/testing' );
|
||||
|
||||
function runTests( lang ) {
|
||||
var runScreenshotTest = createScreenshotEnvironment( test, lang, function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
runScreenshotTest = createScreenshotEnvironment( test, function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
||||
window.seleniumUtils.runDiffTest = function ( oldHtml, newHtml, done ) {
|
||||
var target = ve.init.target,
|
||||
surface = target.surface;
|
||||
window.seleniumUtils.runDiffTest = function ( oldHtml, newHtml, done ) {
|
||||
var target = ve.init.target,
|
||||
surface = target.surface;
|
||||
|
||||
if ( target.saveDialog ) {
|
||||
target.saveDialog.clearDiff();
|
||||
target.saveDialog.close();
|
||||
while ( surface.getModel().canUndo() ) {
|
||||
surface.getModel().undo();
|
||||
}
|
||||
if ( target.saveDialog ) {
|
||||
target.saveDialog.clearDiff();
|
||||
target.saveDialog.close();
|
||||
while ( surface.getModel().canUndo() ) {
|
||||
surface.getModel().undo();
|
||||
}
|
||||
}
|
||||
|
||||
target.originalDmDoc = target.createModelFromDom( target.parseDocument( oldHtml ), 'visual' );
|
||||
target.originalDmDoc = target.createModelFromDom( target.parseDocument( oldHtml ), 'visual' );
|
||||
|
||||
surface.getModel().getDocument().getStore().merge( target.originalDmDoc.getStore() );
|
||||
surface.getModel().getDocument().getStore().merge( target.originalDmDoc.getStore() );
|
||||
|
||||
surface.getModel().getLinearFragment( new ve.Range( 0 ) ).insertDocument(
|
||||
target.createModelFromDom( target.parseDocument( newHtml ), 'visual' )
|
||||
).collapseToEnd().adjustLinearSelection( 0, 3 ).removeContent();
|
||||
surface.getModel().getLinearFragment( new ve.Range( 0 ) ).insertDocument(
|
||||
target.createModelFromDom( target.parseDocument( newHtml ), 'visual' )
|
||||
).collapseToEnd().adjustLinearSelection( 0, 3 ).removeContent();
|
||||
|
||||
target.once( 'saveReview', function () {
|
||||
setTimeout( function () {
|
||||
var dialog = surface.dialogs.currentWindow;
|
||||
dialog.reviewModeButtonSelect.selectItemByData( 'visual' );
|
||||
target.once( 'saveReview', function () {
|
||||
setTimeout( function () {
|
||||
var dialog = surface.dialogs.currentWindow;
|
||||
dialog.reviewModeButtonSelect.selectItemByData( 'visual' );
|
||||
|
||||
// Fake parsed edit summary
|
||||
dialog.$reviewEditSummary.text( '(Lorem ipsum)' );
|
||||
// Fake parsed edit summary
|
||||
dialog.$reviewEditSummary.text( '(Lorem ipsum)' );
|
||||
|
||||
done(
|
||||
seleniumUtils.getBoundingRect( [
|
||||
dialog.$frame[ 0 ]
|
||||
] )
|
||||
);
|
||||
}, 500 );
|
||||
} );
|
||||
surface.execute( 'mwSaveDialog', 'review' );
|
||||
};
|
||||
done(
|
||||
seleniumUtils.getBoundingRect( [
|
||||
dialog.$frame[ 0 ]
|
||||
] )
|
||||
);
|
||||
}, 500 );
|
||||
} );
|
||||
surface.execute( 'mwSaveDialog', 'review' );
|
||||
};
|
||||
|
||||
done();
|
||||
} );
|
||||
done();
|
||||
} );
|
||||
|
||||
function runTests( lang ) {
|
||||
|
||||
test.describe( 'Screenshots: ' + lang, function () {
|
||||
this.lang = lang;
|
||||
test.it( 'Simple diff', function () {
|
||||
runScreenshotTest( 'VisualEditor_diff_simple',
|
||||
runScreenshotTest( 'VisualEditor_diff_simple', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -67,7 +70,7 @@
|
|||
);
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_diff_move_and_change',
|
||||
runScreenshotTest( 'VisualEditor_diff_move_and_change', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -83,7 +86,7 @@
|
|||
);
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_diff_link_change',
|
||||
runScreenshotTest( 'VisualEditor_diff_link_change', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -97,7 +100,7 @@
|
|||
);
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_diff_list_change',
|
||||
runScreenshotTest( 'VisualEditor_diff_list_change', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
|
|
@ -10,10 +10,12 @@
|
|||
username = process.env.SAUCE_ONDEMAND_USERNAME,
|
||||
webdriver = require( 'selenium-webdriver' );
|
||||
|
||||
function createScreenshotEnvironment( test, lang, beforeEach ) {
|
||||
function createScreenshotEnvironment( test, beforeEach ) {
|
||||
var clientSize, driver;
|
||||
|
||||
test.beforeEach( function () {
|
||||
var lang = this.currentTest.parent.lang || 'en';
|
||||
|
||||
// Use Sauce Labs when running on Jenins
|
||||
if ( process.env.JENKINS_URL ) {
|
||||
driver = new webdriver.Builder().withCapabilities( {
|
||||
|
@ -161,7 +163,7 @@
|
|||
} );
|
||||
}
|
||||
|
||||
function runScreenshotTest( name, clientScript, padding ) {
|
||||
function runScreenshotTest( name, lang, clientScript, padding ) {
|
||||
var filename = './screenshots/' + name + '-' + lang + '.png';
|
||||
|
||||
driver.wait(
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
( function () {
|
||||
'use strict';
|
||||
var createScreenshotEnvironment = require( './screenshots.js' ).createScreenshotEnvironment,
|
||||
test = require( 'selenium-webdriver/testing' );
|
||||
test = require( 'selenium-webdriver/testing' ),
|
||||
runScreenshotTest = createScreenshotEnvironment( test );
|
||||
|
||||
function runTests( lang ) {
|
||||
var runScreenshotTest = createScreenshotEnvironment( test, lang );
|
||||
|
||||
test.describe( 'Screenshots: ' + lang, function () {
|
||||
this.lang = lang;
|
||||
test.it( 'Toolbar & action tools', function () {
|
||||
runScreenshotTest( 'VisualEditor_toolbar',
|
||||
runScreenshotTest( 'VisualEditor_toolbar', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -29,7 +30,7 @@
|
|||
},
|
||||
0
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_toolbar_actions',
|
||||
runScreenshotTest( 'VisualEditor_toolbar_actions', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -43,7 +44,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Citoid inspector', function () {
|
||||
runScreenshotTest( 'VisualEditor_Citoid_Inspector',
|
||||
runScreenshotTest( 'VisualEditor_Citoid_Inspector', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ],
|
||||
|
@ -61,61 +62,61 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Tool groups (headings/text style/indentation/insert/page settings)', function () {
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_Headings',
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_Headings', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_Formatting',
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_Formatting', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_Lists_and_indentation',
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_Lists_and_indentation', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_Insert_Menu',
|
||||
runScreenshotTest( 'VisualEditor_Insert_Menu', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_Media_Insert_Menu',
|
||||
runScreenshotTest( 'VisualEditor_Media_Insert_Menu', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_Template_Insert_Menu',
|
||||
runScreenshotTest( 'VisualEditor_Template_Insert_Menu', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_insert_table',
|
||||
runScreenshotTest( 'VisualEditor_insert_table', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_Formula_Insert_Menu',
|
||||
runScreenshotTest( 'VisualEditor_Formula_Insert_Menu', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_References_List_Insert_Menu',
|
||||
runScreenshotTest( 'VisualEditor_References_List_Insert_Menu', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_More_Settings',
|
||||
runScreenshotTest( 'VisualEditor_More_Settings', lang,
|
||||
// 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,
|
||||
|
@ -123,13 +124,13 @@
|
|||
);
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_page_settings_item',
|
||||
runScreenshotTest( 'VisualEditor_page_settings_item', lang,
|
||||
// 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 );
|
||||
}
|
||||
);
|
||||
runScreenshotTest( 'VisualEditor_category_item',
|
||||
runScreenshotTest( 'VisualEditor_category_item', lang,
|
||||
// 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 );
|
||||
|
@ -137,7 +138,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Save dialog', function () {
|
||||
runScreenshotTest( 'VisualEditor_save_dialog',
|
||||
runScreenshotTest( 'VisualEditor_save_dialog', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -153,7 +154,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Special character inserter', function () {
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_SpecialCharacters',
|
||||
runScreenshotTest( 'VisualEditor_Toolbar_SpecialCharacters', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -170,7 +171,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Math dialog', function () {
|
||||
runScreenshotTest( 'VisualEditor_formula',
|
||||
runScreenshotTest( 'VisualEditor_formula', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ],
|
||||
|
@ -195,7 +196,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Reference list dialog', function () {
|
||||
runScreenshotTest( 'VisualEditor_references_list',
|
||||
runScreenshotTest( 'VisualEditor_references_list', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ],
|
||||
|
@ -219,7 +220,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Cite button', function () {
|
||||
runScreenshotTest( 'VisualEditor_citoid_Cite_button',
|
||||
runScreenshotTest( 'VisualEditor_citoid_Cite_button', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ];
|
||||
|
@ -237,7 +238,7 @@
|
|||
);
|
||||
} );
|
||||
test.it( 'Link inspector', function () {
|
||||
runScreenshotTest( 'VisualEditor-link_tool-search_results',
|
||||
runScreenshotTest( 'VisualEditor-link_tool-search_results', lang,
|
||||
// This function is converted to a string and executed in the browser
|
||||
function () {
|
||||
var done = arguments[ arguments.length - 1 ],
|
||||
|
|
Loading…
Reference in a new issue