2022-12-05 16:49:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "Receiving message", type: :system, js: true do
|
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
|
|
fab!(:user_2) { Fabricate(:user) }
|
|
|
|
fab!(:user_3) { Fabricate(:user) }
|
|
|
|
fab!(:direct_message_channel_1) do
|
|
|
|
Fabricate(:direct_message_channel, users: [current_user, user_2])
|
|
|
|
end
|
|
|
|
fab!(:direct_message_channel_2) do
|
|
|
|
Fabricate(:direct_message_channel, users: [current_user, user_2, user_3])
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap(current_user, [direct_message_channel_1, direct_message_channel_2])
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when core sidebar is enabled" do
|
|
|
|
before do
|
2022-12-07 20:44:29 -05:00
|
|
|
SiteSetting.navigation_menu = "sidebar"
|
2022-12-05 16:49:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when receiving a direct message" do
|
|
|
|
it "reorders the direct messages sidebar section links ordering by last message received" do
|
|
|
|
visit("/")
|
|
|
|
|
|
|
|
expect(
|
|
|
|
page.find(
|
|
|
|
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(2) .sidebar-row",
|
|
|
|
),
|
|
|
|
).to have_content(direct_message_channel_2.name)
|
|
|
|
|
|
|
|
creator =
|
|
|
|
Chat::ChatMessageCreator.create(
|
|
|
|
chat_channel: direct_message_channel_2,
|
|
|
|
user: user_2,
|
|
|
|
content: "this is good",
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(
|
|
|
|
page.find(
|
|
|
|
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(1) .sidebar-row",
|
|
|
|
),
|
|
|
|
).to have_content(direct_message_channel_2.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|