From 827df072a6ae2a8e35a294777d408bfbd349baad Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Fri, 10 Feb 2023 11:37:11 -0500 Subject: [PATCH] DEV: Fix a flakey test (#20241) The `Composer - current time` test would sometimes fail due to a 1-second difference. We don't really need per-second fidelity here, the key thing this needs to test is that the shortcut works and adds today's date. I have updated the test to reflect that. --- .../discourse/tests/acceptance/composer-test.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js index 3bcdcfe7b54..678f528f714 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js @@ -1372,6 +1372,7 @@ acceptance("Composer - current time", function (needs) { await fillIn(".d-editor-input", "and the time now is: "); const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform); + const date = moment().format("YYYY-MM-DD"); await triggerKeyEvent(".d-editor-input", "keydown", ".", { shiftKey: true, @@ -1379,12 +1380,10 @@ acceptance("Composer - current time", function (needs) { metaKey: mac, }); - const time = moment().format("HH:mm:ss"); - const date = moment().format("YYYY-MM-DD"); + const inputValue = query("#reply-control .d-editor-input").value.trim(); - assert.strictEqual( - query("#reply-control .d-editor-input").value.trim(), - `and the time now is: [date=${date} time=${time} timezone="Australia/Brisbane"]`, + assert.ok( + inputValue.startsWith(`and the time now is: [date=${date}`), "it adds the current date" ); });