mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 03:48:23 +00:00
Group channels will allow users to create channels with a name and invite people. It's possible to add people even after creation of the channel. Removing users is not yet possible but will be added in the near future. Technically a group channel is `direct_message_channel` with a group attribute set to true on its direct message (chatable). This model might evolve in the future but offers much flexibility for now without having to rely on a complex migration. The commit essentially consists of: - a migration to set existing direct message channels with more than 2 users to a group - a new message creator which allows to search, add members, and create groups - a new `AddUsersToChannel` service - a modified `SearchChatable` service
83 lines
2.4 KiB
Ruby
83 lines
2.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Flag message", type: :system do
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
before do
|
|
chat_system_bootstrap
|
|
sign_in(current_user)
|
|
end
|
|
|
|
it "lists preloaded channels by default" do
|
|
channel_1 = Fabricate(:chat_channel)
|
|
channel_1.add(current_user)
|
|
|
|
visit("/")
|
|
chat_page.open_new_message
|
|
|
|
expect(chat_page.message_creator).to be_listing(channel_1)
|
|
end
|
|
|
|
it "can filter channels" do
|
|
channel_1 = Fabricate(:chat_channel)
|
|
channel_2 = Fabricate(:chat_channel)
|
|
channel_1.add(current_user)
|
|
channel_2.add(current_user)
|
|
|
|
visit("/")
|
|
chat_page.open_new_message
|
|
chat_page.message_creator.filter(channel_2.title)
|
|
|
|
expect(chat_page.message_creator).to be_listing(channel_2)
|
|
expect(chat_page.message_creator).to be_not_listing(channel_1)
|
|
end
|
|
|
|
it "can filter users" do
|
|
user_1 = Fabricate(:user)
|
|
user_2 = Fabricate(:user)
|
|
|
|
visit("/")
|
|
chat_page.open_new_message
|
|
chat_page.message_creator.filter(user_2.username)
|
|
|
|
expect(chat_page.message_creator).to be_listing(user_2)
|
|
expect(chat_page.message_creator).to be_not_listing(user_1)
|
|
end
|
|
|
|
it "can filter direct message channels" do
|
|
channel_1 = Fabricate(:direct_message_channel, users: [current_user])
|
|
channel_2 =
|
|
Fabricate(
|
|
:direct_message_channel,
|
|
users: [current_user, Fabricate(:user), Fabricate(:user, username: "user_1")],
|
|
)
|
|
|
|
visit("/")
|
|
chat_page.open_new_message
|
|
chat_page.message_creator.filter("user_1")
|
|
|
|
expect(chat_page.message_creator).to be_listing(channel_2)
|
|
expect(chat_page.message_creator).to be_not_listing(channel_1)
|
|
end
|
|
|
|
it "can create a new group message" do
|
|
user_1 = Fabricate(:user)
|
|
user_2 = Fabricate(:user)
|
|
|
|
visit("/")
|
|
chat_page.prefers_full_page
|
|
chat_page.open_new_message
|
|
chat_page.find("#new-group-chat").click
|
|
chat_page.find(".chat-message-creator__new-group-header__input").fill_in(with: "cats")
|
|
chat_page.find(".chat-message-creator__members-input").fill_in(with: user_1.username)
|
|
chat_page.message_creator.click_row(user_1)
|
|
chat_page.find(".chat-message-creator__members-input").fill_in(with: user_2.username)
|
|
chat_page.message_creator.click_row(user_2)
|
|
page.find(".create-chat-group").click
|
|
|
|
expect(page).to have_current_path(%r{/chat/c/cats/\d+})
|
|
end
|
|
end
|