mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 19:33:41 +08:00
c0808b2537
In previous changes we prevented creating a channel to also make users follow the channel. We were forcing recipients to follow the channel on message sent but this was not including the creator of the message itself. This commit fixes it and also write an end-to-end system spec to cover these cases. The message creator service is currently being rewritten and should correctly test and ensure this logic is present. This commit also makes changes on the frontend to instantly follow a DM when you open it, this change prevents a green dot to appear for a split second when you send a message in a channel you were previously not following. Only recipients will see the green dot.
116 lines
3.1 KiB
Ruby
116 lines
3.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Send message", type: :system do
|
|
fab!(:user_1) { Fabricate(:admin) }
|
|
fab!(:user_2) { Fabricate(:admin) }
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
before do
|
|
# simpler user search without having to worry about user search data
|
|
SiteSetting.enable_names = false
|
|
|
|
chat_system_bootstrap
|
|
end
|
|
|
|
context "with direct message channels" do
|
|
context "when users are not following the channel" do
|
|
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [user_1, user_2]) }
|
|
|
|
before do
|
|
channel_1.remove(user_1)
|
|
channel_1.remove(user_2)
|
|
end
|
|
|
|
it "shows correct state" do
|
|
using_session(:user_1) do
|
|
sign_in(user_1)
|
|
visit("/")
|
|
|
|
expect(chat_page.sidebar).to have_no_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_2) do
|
|
sign_in(user_2)
|
|
visit("/")
|
|
|
|
expect(chat_page.sidebar).to have_no_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_1) do
|
|
chat_page.open_new_message
|
|
chat_page.message_creator.filter(user_2.username)
|
|
chat_page.message_creator.click_row(user_2)
|
|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_2) do
|
|
expect(chat_page.sidebar).to have_no_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_1) do |session|
|
|
channel_page.send_message
|
|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
|
|
session.quit
|
|
end
|
|
|
|
using_session(:user_2) do |session|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1, mention: true)
|
|
|
|
session.quit
|
|
end
|
|
end
|
|
end
|
|
|
|
context "when users are following the channel" do
|
|
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [user_1, user_2]) }
|
|
|
|
it "shows correct state" do
|
|
using_session(:user_1) do
|
|
sign_in(user_1)
|
|
visit("/")
|
|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_2) do
|
|
sign_in(user_2)
|
|
visit("/")
|
|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_1) do
|
|
chat_page.open_new_message
|
|
chat_page.message_creator.filter(user_2.username)
|
|
chat_page.message_creator.click_row(user_2)
|
|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_2) do
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
end
|
|
|
|
using_session(:user_1) do |session|
|
|
channel_page.send_message
|
|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
|
|
|
|
session.quit
|
|
end
|
|
|
|
using_session(:user_2) do |session|
|
|
expect(chat_page.sidebar).to have_direct_message_channel(channel_1, mention: true)
|
|
|
|
session.quit
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|