Merge "Run screenshot tests in series"

This commit is contained in:
jenkins-bot 2017-05-05 15:55:41 +00:00 committed by Gerrit Code Review
commit db73a1419c
3 changed files with 70 additions and 64 deletions

View file

@ -2,57 +2,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 ];
@ -66,7 +69,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 ];
@ -82,7 +85,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 ];
@ -96,7 +99,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 ];

View file

@ -9,10 +9,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( {
@ -160,7 +162,7 @@
} );
}
function runScreenshotTest( name, clientScript, padding ) {
function runScreenshotTest( name, lang, clientScript, padding ) {
var filename = './screenshots/' + name + '-' + lang + '.png';
driver.wait(

View file

@ -3,14 +3,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 ];
@ -28,7 +29,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 ];
@ -42,7 +43,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 ],
@ -60,61 +61,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,
@ -122,13 +123,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 );
@ -136,7 +137,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 ];
@ -152,7 +153,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 ];
@ -169,7 +170,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 ],
@ -194,7 +195,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 ],
@ -218,7 +219,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 ];
@ -236,7 +237,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 ],