High level tests

This commit is contained in:
Jan Cernik 2023-02-07 22:59:28 -03:00
parent 5a6e5a4012
commit 60694e828c
No known key found for this signature in database
2 changed files with 52 additions and 0 deletions

View File

@ -175,6 +175,27 @@ describe Jobs::AutoJoinChannelBatch do
assert_users_follows_channel(channel, [user, another_user])
end
it "doesn't join users with read-only access to the category" do
another_user = Fabricate(:user, last_seen_at: 15.minutes.ago)
non_chatters_group = Fabricate(:group)
readonly_channel = Fabricate(:category_channel, chatable: category, auto_join_users: true)
Fabricate(
:category_group,
category: category,
group: non_chatters_group,
permission_type: CategoryGroup.permission_types[:readonly],
)
non_chatters_group.add(another_user)
subject.execute(
chat_channel_id: readonly_channel.id,
starts_at: another_user.id,
ends_at: another_user.id,
)
assert_user_skipped(readonly_channel, another_user)
end
end
end

View File

@ -93,6 +93,37 @@ RSpec.describe "Visit channel", type: :system, js: true do
end
end
context "when category channel is read-only" do
fab!(:readonly_category_1) { Fabricate(:private_category, group: Fabricate(:group)) }
fab!(:readonly_group_1) { Fabricate(:group, users: [current_user]) }
fab!(:readonly_category_channel_1) do
Fabricate(:private_category_channel, group: readonly_group_1)
end
fab!(:message_1) { Fabricate(:chat_message, chat_channel: readonly_category_channel_1) }
before do
Fabricate(
:category_group,
category: readonly_category_1,
group: readonly_group_1,
permission_type: CategoryGroup.permission_types[:readonly],
)
end
it "doesn't allow user to join it" do
chat.visit_channel(readonly_category_channel_1)
expect(page).not_to have_content(I18n.t("js.chat.channel_settings.join_channel"))
end
it "shows a preview of the channel" do
chat.visit_channel(readonly_category_channel_1)
expect(page).to have_content(readonly_category_channel_1.name)
expect(chat).to have_message(message_1)
end
end
context "when current user is not member of the channel" do
context "when category channel" do
fab!(:message_1) { Fabricate(:chat_message, chat_channel: category_channel_1) }