From c8c78987d8fcd6f4fa20f90b97a5628983c51e75 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 8 Feb 2021 07:56:11 +0000 Subject: [PATCH] wait for test to not fail --- src/tests/frontend/specs/ordered_list.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/tests/frontend/specs/ordered_list.js b/src/tests/frontend/specs/ordered_list.js index 534899a35..af922cb72 100644 --- a/src/tests/frontend/specs/ordered_list.js +++ b/src/tests/frontend/specs/ordered_list.js @@ -39,14 +39,15 @@ describe('ordered_list.js', function () { triggerCtrlShiftShortcut('N'); try { // The HTML should not change. Briefly wait for it to change and fail if it does change. - await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML, 500); + await helper.waitForPromise( + () => helper.padInner$('body').html() !== originalHTML, 500); } catch (err) { // We want the test to pass if the above wait timed out. (If it timed out that // means the HTML never changed, which is a good thing.) // TODO: Re-throw non-"condition never became true" errors to avoid false positives. } // This will fail if the above `waitForPromise()` succeeded. - assert.equal(helper.padInner$('body').html(), originalHTML); + helper.waitForPromise(() => helper.padInner$('body').html() === originalHTML); }); it('does not insert unordered list', function (done) { @@ -81,7 +82,17 @@ describe('ordered_list.js', function () { const originalHTML = helper.padInner$('body').html(); makeSureShortcutIsDisabled('cmdShift1'); triggerCtrlShiftShortcut('1'); - await helper.waitForPromise(() => helper.padInner$('body').html() === originalHTML); + try { + // The HTML should not change. Briefly wait for it to change and fail if it does change. + await helper.waitForPromise( + () => helper.padInner$('body').html() !== originalHTML, 500); + } catch (err) { + // We want the test to pass if the above wait timed out. (If it timed out that + // means the HTML never changed, which is a good thing.) + // TODO: Re-throw non-"condition never became true" errors to avoid false positives. + } + // This will fail if the above `waitForPromise()` succeeded. + helper.waitForPromise(() => helper.padInner$('body').html() === originalHTML); }); it('does not insert unordered list', function (done) {