Skip to content

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

DEV: Fix a flaky chat system test (#32055)

Alan Guo Xiang Tan016c6a689471
diff --git a/plugins/chat/spec/system/chat_new_message_spec.rb b/plugins/chat/spec/system/chat_new_message_spec.rb
index 02f4673da77..1d9fb6c204f 100644
--- a/plugins/chat/spec/system/chat_new_message_spec.rb
+++ b/plugins/chat/spec/system/chat_new_message_spec.rb
@@ -54,9 +54,11 @@ RSpec.describe "Chat New Message from params", type: :system do
end
it "creates a dm channel when none exists" do
- expect { chat_page.visit_new_message([user_1, user_3]) }.to change { Chat::Channel.count }.by(
- 1,
- )
+ original_channel_count = Chat::Channel.count
+
+ chat_page.visit_new_message([user_1, user_3])
+
+ try_until_success { expect(Chat::Channel.count - original_channel_count).to eq(1) }
expect(page).to have_current_path(
%r{/chat/c/#{group_slug([user_1, user_3])}/#{Chat::Channel.last.id}},