Skip to content

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

DEV: Restore and fix five chat specs (#39541)

Jarek Radosz6e96da1a6aef
diff --git a/plugins/chat/lib/chat/channel_archive_service.rb b/plugins/chat/lib/chat/channel_archive_service.rb
index a49a03fab40..56338ef035a 100644
--- a/plugins/chat/lib/chat/channel_archive_service.rb
+++ b/plugins/chat/lib/chat/channel_archive_service.rb
@@ -114,7 +114,7 @@ module Chat
chat_channel
.chat_messages
- .order("created_at ASC")
+ .order("created_at ASC, id ASC")
.find_in_batches(batch_size: ARCHIVED_MESSAGES_PER_POST) do |message_batch|
thread_ids = message_batch.map(&:thread_id).compact.uniq
threads =
@@ -128,7 +128,7 @@ module Chat
.group(:thread_id)
.having("count(*) > 1"),
)
- .order("created_at ASC")
+ .order("created_at ASC, id ASC")
.to_a
full_batch = (buffer + message_batch + threads).uniq { |msg| msg.id }
diff --git a/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb b/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb
index 9378935c54a..5f2482c14dc 100644
--- a/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb
+++ b/plugins/chat/spec/lib/chat/channel_archive_service_spec.rb
@@ -149,7 +149,7 @@ describe Chat::ChannelArchiveService do
expect(@channel_archive.chat_channel.chat_messages.count).to eq(0)
end
- xit "creates the correct posts for a channel with messages and threads" do
+ it "creates the correct posts for a channel with messages and threads" do
channel.update!(threading_enabled: true)
create_messages(2)
diff --git a/plugins/chat/spec/lib/chat/transcript_service_spec.rb b/plugins/chat/spec/lib/chat/transcript_service_spec.rb
index 8293db1411b..ba73ff77934 100644
--- a/plugins/chat/spec/lib/chat/transcript_service_spec.rb
+++ b/plugins/chat/spec/lib/chat/transcript_service_spec.rb
@@ -519,7 +519,7 @@ describe Chat::TranscriptService do
MARKDOWN
end
- xit "generates the correct markdown for multiple threads" do
+ it "generates the correct markdown for multiple threads" do
channel_message_1 =
Fabricate(:chat_message, user: user1, chat_channel: channel, message: "I need ideas")
thread_1 = Fabricate(:chat_thread, channel: channel)
diff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rb
index a86945695b8..174c4061036 100644
--- a/plugins/chat/spec/system/chat_channel_spec.rb
+++ b/plugins/chat/spec/system/chat_channel_spec.rb
@@ -161,19 +161,15 @@ RSpec.describe "Chat channel" do
context "when a new message is created" do
before { Fabricate.times(50, :chat_message, chat_channel: channel_1) }
- # this is skipped cause it is not correct
- xit "doesn’t append the message when not at bottom" do
+ it "doesn’t scroll and keeps the scroll-to-bottom arrow when not at bottom" do
visit("/chat/c/-/#{channel_1.id}/#{message_1.id}")
expect(page).to have_css(".chat-scroll-to-bottom__button.visible")
new_message = Fabricate(:chat_message, chat_channel: channel_1, use_service: true)
+ expect(channel_page.messages).to have_message(id: new_message.id)
expect(page).to have_css(".chat-scroll-to-bottom__button.visible")
- # sleep 5 <- this will cause this to consistently fail, cause the message
- # has always actually been unconditionally appended, we don't have logic to
- # prevent that yet
- expect(channel_page.messages).to have_no_message(id: new_message.id)
end
end
diff --git a/plugins/chat/spec/system/create_channel_spec.rb b/plugins/chat/spec/system/create_channel_spec.rb
index cc92540246a..c8ed37abcd8 100644
--- a/plugins/chat/spec/system/create_channel_spec.rb
+++ b/plugins/chat/spec/system/create_channel_spec.rb
@@ -206,12 +206,13 @@ RSpec.describe "Create channel" do
end
it "displays the correct warning" do
+ sorted_names = [group_1.name, group_2.name].sort
expect(dialog).to have_content(
I18n.t(
"js.chat.create_channel.auto_join_users.warning_2_groups",
count: 1,
- group1: "@#{group_1.name}",
- group2: "@#{group_2.name}",
+ group1: "@#{sorted_names.first}",
+ group2: "@#{sorted_names.second}",
),
)
end
@@ -231,8 +232,9 @@ RSpec.describe "Create channel" do
it "displays the correct warning" do
# NOTE: This has to be hardcoded because the I18n module in ruby
# does not support messageFormat.
+ first_group = [group_1.name, group_2.name, group_3.name].sort.first
expect(dialog).to have_content(
- "Automatically add 1 user from @#{group_1.name} and 2 other groups?",
+ "Automatically add 1 user from @#{first_group} and 2 other groups?",
)
end
end
diff --git a/plugins/chat/spec/system/dates_separators_spec.rb b/plugins/chat/spec/system/dates_separators_spec.rb
index 3d204899fa6..540b3ce8335 100644
--- a/plugins/chat/spec/system/dates_separators_spec.rb
+++ b/plugins/chat/spec/system/dates_separators_spec.rb
@@ -15,21 +15,19 @@ RSpec.describe "Dates separators" do
context "when today separator is out of screen" do
before do
- 15.times { Fabricate(:chat_message, chat_channel: channel_1, created_at: 1.day.ago) }
+ 15.times { Fabricate(:chat_message, chat_channel: channel_1, created_at: 2.days.ago) }
30.times { Fabricate(:chat_message, chat_channel: channel_1) }
end
- xit "shows it as a sticky date" do
+ it "shows it as a sticky date" do
chat_page.visit_channel(channel_1)
expect(page.find(".chat-message-separator__text-container.is-pinned")).to have_content(
I18n.t("js.chat.chat_message_separator.today"),
)
expect(page).to have_css(
- ".chat-message-separator__text-container:not(.is-pinned)",
- visible: :hidden,
- text:
- "#{I18n.t("js.chat.chat_message_separator.yesterday")} - #{I18n.t("js.chat.last_visit")}",
+ ".chat-message-separator-date.with-last-visit .chat-message-separator__text-container:not(.is-pinned)",
+ text: I18n.t("js.chat.last_visit"),
)
end
end