From 174e68d46855a3737fe241a9690a18ac26020105 Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 29 May 2020 20:07:27 +0100 Subject: [PATCH] tests: remove more edge settimeout issues (#4060) --- .../specs/select_formatting_buttons.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/frontend/specs/select_formatting_buttons.js b/tests/frontend/specs/select_formatting_buttons.js index 57285895..55181bdf 100644 --- a/tests/frontend/specs/select_formatting_buttons.js +++ b/tests/frontend/specs/select_formatting_buttons.js @@ -63,18 +63,22 @@ describe("select formatting buttons when selection has style applied", function( } var applyStyleOnLineOnFullLineAndRemoveSelection = function(line, style, selectTarget, cb) { + // see if line html has changed + var inner$ = helper.padInner$; + var oldLineHTML = inner$.find("div")[line]; applyStyleOnLine(style, line); - // we have to give some time to Etherpad detects the selection changed - setTimeout(function() { + helper.waitFor(function(){ + var lineHTML = inner$.find("div")[line]; + return lineHTML !== oldLineHTML; + }); // remove selection from previous line - selectLine(line + 1); - setTimeout(function() { - // select the text or place the caret on a position that - // has the formatting text applied previously - selectTarget(line); - cb(); - }, 1000); + selectLine(line + 1); + setTimeout(function() { + // select the text or place the caret on a position that + // has the formatting text applied previously + selectTarget(line); + cb(); }, 1000); }