/* eslint-env node, es6 */ /* global seleniumUtils, langs */ ( function () { 'use strict'; var 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 ]; 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(); } } target.originalDmDoc = target.createModelFromDom( target.parseDocument( oldHtml ), 'visual' ); 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(); target.once( 'saveReview', function () { setTimeout( function () { var dialog = surface.dialogs.currentWindow; dialog.reviewModeButtonSelect.selectItemByData( 'visual' ); // Fake parsed edit summary dialog.$reviewEditSummary.text( '(Lorem ipsum)' ); done( seleniumUtils.getBoundingRect( [ dialog.$frame[ 0 ] ] ) ); }, 500 ); } ); surface.execute( 'mwSaveDialog', 'review' ); }; done(); } ); test.describe( 'Screenshots: ' + lang, function () { test.it( 'Simple diff', function () { runScreenshotTest( 'VisualEditor_diff_simple', // This function is converted to a string and executed in the browser function () { var done = arguments[ arguments.length - 1 ]; seleniumUtils.runDiffTest( '
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
', done ); } ); runScreenshotTest( 'VisualEditor_diff_move_and_change', // This function is converted to a string and executed in the browser function () { var done = arguments[ arguments.length - 1 ]; seleniumUtils.runDiffTest( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
' + 'Maecenas fringilla turpis et nunc bibendum mattis.
', 'Maecenas fringilla turpis et nunc bibendum mattis.
' + 'Lorem ipsum dolor sit amat, consectetur adipiscing elit.
', done ); } ); runScreenshotTest( 'VisualEditor_diff_link_change', // This function is converted to a string and executed in the browser function () { var done = arguments[ arguments.length - 1 ]; seleniumUtils.runDiffTest( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
', done ); } ); runScreenshotTest( 'VisualEditor_diff_list_change', // This function is converted to a string and executed in the browser function () { var done = arguments[ arguments.length - 1 ]; seleniumUtils.runDiffTest( '