0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-08 17:53:55 +08:00
discourse/plugins/chat/spec/system/invite_users_to_channel_spec.rb
2026-03-20 00:39:52 +01:00

60 lines
1.6 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Invite users to channel" do
fab!(:user_1, :user)
fab!(:channel_1, :category_channel)
let(:user_menu) { PageObjects::Components::UserMenu.new }
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
before do
chat_system_bootstrap
channel_1.add(user_1)
sign_in(user_1)
end
context "when user clicks the invitation" do
context "when the invitation is linking to a channel" do
before do
Chat::InviteUsersToChannel.call(
guardian: Guardian.new(Fabricate(:admin)),
params: {
channel_id: channel_1.id,
user_ids: [user_1.id],
},
)
end
it "loads the channel" do
visit("/")
user_menu.open
find("[title='#{I18n.t("js.notifications.titles.chat_invitation")}']").click
expect(chat_drawer_page).to have_open_channel(channel_1)
end
end
context "when the invitation is linking to a message" do
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1) }
before do
Chat::InviteUsersToChannel.call(
guardian: Guardian.new(Fabricate(:admin)),
params: {
channel_id: channel_1.id,
user_ids: [user_1.id],
message_id: message_1.id,
},
)
end
it "loads the channel" do
visit("/")
user_menu.open
find("[title='#{I18n.t("js.notifications.titles.chat_invitation")}']").click
expect(chat_drawer_page).to have_open_channel(channel_1)
end
end
end
end