discourse/plugins/chat/spec/system/user_profile_spec.rb
David Battersby d5b944f1de
FEATURE: add chat direct message button to user profile (#26135)
This change adds the chat direct message button to user profiles, similarly to how we use it within the user card.
2024-03-18 11:17:37 +08:00

52 lines
1.1 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "User profile", type: :system do
fab!(:current_user) { Fabricate(:user) }
fab!(:user)
before { chat_system_bootstrap }
shared_examples "not showing chat button" do
it "has no chat button" do
expect(page).to have_no_css(".chat-direct-message-btn")
end
end
shared_examples "showing chat button" do
it "shows the chat button" do
expect(page).to have_css(".chat-direct-message-btn")
end
end
def visit_user_profile
visit("/u/" + user.username + "/summary")
end
context "when user" do
context "with chat disabled" do
before do
SiteSetting.chat_enabled = false
sign_in(current_user)
visit_user_profile
end
include_examples "not showing chat button"
end
context "with chat enabled" do
before do
sign_in(current_user)
visit_user_profile
end
include_examples "showing chat button"
end
end
context "when anonymous" do
before { visit_user_profile }
include_examples "not showing chat button"
end
end