From 7616f5124f36b873c5eaabd7c338def17e225881 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 3 Jul 2023 13:57:57 +0100 Subject: [PATCH] screenshots: Fix environment setup * Use global.langs instead of just langs * Wait for new welcomeDialogPromise Change-Id: I7c4d48bca47eb4ce1a699f9160a0176dc77faa4b --- Gruntfile.js | 6 ++---- build/screenshots-client/utils.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 63fe96c784..782fa8f446 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,8 +15,7 @@ module.exports = function ( grunt ) { timeout: 5 * 60 * 1000, require: [ function () { - // eslint-disable-next-line no-undef - langs = [ grunt.option( 'lang' ) || 'en' ]; + global.langs = [ grunt.option( 'lang' ) || 'en' ]; } ] }, @@ -27,8 +26,7 @@ module.exports = function ( grunt ) { timeout: 5 * 60 * 1000, require: [ function () { - // eslint-disable-next-line no-undef - langs = require( './build/tasks/screenshotLangs.json' ).langs; + global.langs = require( './build/tasks/screenshotLangs.json' ).langs; } ] }; diff --git a/build/screenshots-client/utils.js b/build/screenshots-client/utils.js index 79e6d42294..9d5d501533 100644 --- a/build/screenshots-client/utils.js +++ b/build/screenshots-client/utils.js @@ -101,12 +101,16 @@ module.exports = function () { mw.hook( 've.activationComplete' ).add( function () { var target = ve.init.target, surfaceView = target.getSurface().getView(); - // Modify the document to make the save button blue - // Wait for focus - surfaceView.once( 'focus', function () { - target.surface.getModel().getFragment().insertContent( ' ' ).collapseToStart().select(); + + // eslint-disable-next-line no-jquery/no-deferred + var welcomeDialogPromise = target.welcomeDialogPromise || $.Deferred().resolve().promise(); + + welcomeDialogPromise.then( function () { // Hide edit notices target.toolbar.tools.notices.getPopup().toggle( false ); + surfaceView.focus(); + // Modify the document to make the save button blue + target.surface.getModel().getFragment().insertContent( ' ' ).collapseToStart().select(); // Wait for save button fade setTimeout( function () { veDone( { width: window.innerWidth, height: window.innerHeight } );