2023-04-06 07:29:54 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
RSpec.describe "User presence", type: :system do
|
2023-04-06 07:29:54 +08:00
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
|
2023-07-06 03:01:23 +08:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
2023-04-06 07:29:54 +08:00
|
|
|
let(:channel) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap
|
|
|
|
channel_1.add(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows presence indicator" do
|
|
|
|
sign_in(current_user)
|
2023-07-06 03:01:23 +08:00
|
|
|
chat_page.visit_channel(channel_1)
|
2023-04-06 07:29:54 +08:00
|
|
|
channel.send_message("Am I present?")
|
|
|
|
|
2023-07-06 03:01:23 +08:00
|
|
|
expect(page).to have_css(".chat-message .chat-user-avatar.is-online")
|
2023-04-06 07:29:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when user hides presence" do
|
|
|
|
it "hides the presence indicator" do
|
|
|
|
current_user.user_option.update!(hide_profile_and_presence: true)
|
|
|
|
sign_in(current_user)
|
2023-07-06 03:01:23 +08:00
|
|
|
chat_page.visit_channel(channel_1)
|
2023-04-06 07:29:54 +08:00
|
|
|
channel.send_message("Am I present?")
|
|
|
|
|
2023-07-06 03:01:23 +08:00
|
|
|
expect(page).to have_no_css(".chat-user-avatar.is-online")
|
2023-04-06 07:29:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|