screenshots: Add multi-language support

Change-Id: I1da41cffd946a76e5f09097decbc0a25562c9508
This commit is contained in:
Ed Sanders 2016-06-24 17:51:13 +01:00
parent 746321a29f
commit c3fa707adc
3 changed files with 379 additions and 259 deletions

View file

@ -56,10 +56,29 @@ module.exports = function ( grunt ) {
}
},
mochaTest: {
screenshots: {
'screenshots-en': {
options: {
reporter: 'spec',
timeout: 20000
timeout: 20000,
require: [
function () {
/* jshint undef:false */
langs = [ 'en' ];
}
]
},
src: [ 'build/screenshots.js' ]
},
'screenshots-all': {
options: {
reporter: 'spec',
timeout: 20000,
require: [
function () {
/* jshint undef:false */
langs = require( './build/tasks/screenshotLangs.json' ).langs;
}
]
},
src: [ 'build/screenshots.js' ]
}
@ -163,7 +182,8 @@ module.exports = function ( grunt ) {
grunt.registerTask( 'fix', [ 'jscs:fix' ] );
grunt.registerTask( 'test', [ 'build', 'lint' ] );
grunt.registerTask( 'test-ci', [ 'git-status' ] );
grunt.registerTask( 'screenshots', [ 'mochaTest:screenshots' ] );
grunt.registerTask( 'screenshots', [ 'mochaTest:screenshots-en' ] );
grunt.registerTask( 'screenshots-all', [ 'mochaTest:screenshots-all' ] );
grunt.registerTask( 'default', 'test' );
if ( process.env.JENKINS_HOME ) {

View file

@ -1,15 +1,25 @@
/* jshint node: true */
/* global seleniumUtils */
var chrome = require( 'selenium-webdriver/chrome' ),
/* global seleniumUtils, langs */
var i, l,
chrome = require( 'selenium-webdriver/chrome' ),
test = require( 'selenium-webdriver/testing' ),
fs = require( 'fs' ),
Jimp = require( 'jimp' ),
lang = 'en';
Jimp = require( 'jimp' );
test.describe( 'Screenshot', function () {
function runTests( lang ) {
test.describe( 'Screenshots: ' + lang, function () {
var driver;
test.beforeEach( function () {
driver = new chrome.Driver();
driver.manage().timeouts().setScriptTimeout( 20000 );
driver.manage().window().setSize( 1200, 800 );
} );
test.afterEach( function () {
driver.quit();
} );
function runScreenshotTest( name, clientScript, padding ) {
var filename = './screenshots/' + name + '-' + lang + '.png';
driver.get( 'http://en.wikipedia.beta.wmflabs.org/wiki/PageDoesNotExist?veaction=edit&uselang=' + lang );
@ -98,16 +108,6 @@ test.describe( 'Screenshot', function () {
} );
}
test.beforeEach( function () {
driver = new chrome.Driver();
driver.manage().timeouts().setScriptTimeout( 20000 );
driver.manage().window().setSize( 1200, 800 );
} );
test.afterEach( function () {
driver.quit();
} );
test.it( 'Toolbar', function () {
runScreenshotTest( 'VisualEditor_toolbar',
// This function is converted to a string and executed in the browser
@ -264,3 +264,8 @@ test.describe( 'Screenshot', function () {
);
} );
} );
}
for ( i = 0, l = langs.length; i < l; i++ ) {
runTests( langs[ i ] );
}

View file

@ -0,0 +1,95 @@
{
"langs": [
"ar",
"as",
"ast",
"az",
"azb",
"bcl",
"be-tarask",
"bg",
"bn",
"bs",
"ca",
"cdo",
"ceb",
"cs",
"cy",
"da",
"de",
"diq",
"egl",
"el",
"eml",
"en",
"en-gb",
"eo",
"es",
"et",
"eu",
"fa",
"fi",
"fo",
"fr",
"fur",
"fy",
"gl",
"he",
"hi",
"hif",
"hr",
"hu",
"hy",
"id",
"ie",
"ilo",
"it",
"ja",
"jv",
"ka",
"km",
"kn",
"ko",
"lb",
"lt",
"lv",
"mai",
"mg",
"mk",
"ml",
"mr",
"ms",
"nap",
"nb",
"nl",
"om",
"or",
"pa",
"pcd",
"pl",
"ps",
"pt",
"pt-br",
"ro",
"ru",
"sah",
"sco",
"sd",
"sk",
"sl",
"sq",
"sr",
"su",
"sv",
"ta",
"th",
"tl",
"tr",
"tt",
"uk",
"vi",
"xh",
"yi",
"zh"
]
}