Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve test selection stability in system specs (#38832)

Jarek Radosz2a27c9201376
diff --git a/plugins/discourse-ai/test/javascripts/unit/lib/smooth-streamer-test.js b/plugins/discourse-ai/test/javascripts/unit/lib/smooth-streamer-test.js
index c7cefd720c9..799b8c9ee67 100644
--- a/plugins/discourse-ai/test/javascripts/unit/lib/smooth-streamer-test.js
+++ b/plugins/discourse-ai/test/javascripts/unit/lib/smooth-streamer-test.js
@@ -42,8 +42,7 @@ module("Discourse AI | Unit | Lib | smooth-streamer", function (hooks) {
"Hello",
"Realtime text should be updated immediately"
);
- // eslint-disable-next-line qunit/no-loose-assertions
- assert.ok(
+ assert.true(
streamer.streamedText.length > 0,
"Streamed text should start appearing"
);
diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb
index 48981619f3b..def1c6a120f 100644
--- a/spec/support/system_helpers.rb
+++ b/spec/support/system_helpers.rb
@@ -152,6 +152,8 @@ module SystemHelpers
end
def select_text_range(selector, start = 0, offset = 5)
+ expect(page).to have_selector(selector)
+
js = <<-JS
const node = document.querySelector(arguments[0]).childNodes[0];
const selection = window.getSelection();