/* global seleniumUtils, langs */ ( function () { 'use strict'; var runScreenshotTest, createScreenshotEnvironment = require( './screenshots.js' ).createScreenshotEnvironment, test = require( 'selenium-webdriver/testing' ); 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; 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(); } ); function runTests( lang ) { test.describe( 'Screenshots: ' + lang, function () { this.lang = lang; test.it( 'Simple diff', function () { runScreenshotTest( 'VisualEditor_diff_simple', lang, // 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', lang, // 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', lang, // 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', lang, // This function is converted to a string and executed in the browser function () { var done = arguments[ arguments.length - 1 ]; seleniumUtils.runDiffTest( '