discourse/plugins/chat/spec/system/user_card_spec.rb
Joffrey JAFFEUX 8270d76f16
DEV: makes user-card-chat-button uses glimmer (#22496)
This commit also namespaces the component to now be: `<Chat::UserCardButton />`
2023-07-10 14:04:26 +02:00

77 lines
1.9 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
RSpec.describe "User card", type: :system do
fab!(:current_user) { Fabricate(:user) }
fab!(:topic_1) { Fabricate(:topic) }
let(:chat) { PageObjects::Pages::Chat.new }
before { chat_system_bootstrap }
shared_examples "not showing chat button" do
it "doesnt show the chat buttton" do
expect(page).to have_no_css(".chat-user-card-btn")
end
end
shared_examples "showing chat button" do
it "shows the chat buttton" do
expect(page).to have_css(".chat-user-card-btn")
end
end
context "when user" do
context "when chat disabled" do
before do
SiteSetting.chat_enabled = false
sign_in(current_user)
end
context "when showing user card" do
before do
visit("/")
find("[data-user-card='#{topic_1.user.username}'").click
end
include_examples "not showing chat button"
end
end
context "when chat enabled" do
before { sign_in(current_user) }
context "when showing user card" do
before do
visit("/")
find("[data-user-card='#{topic_1.user.username}'").click
end
include_examples "showing chat button"
context "when clicking chat button" do
before { find(".chat-user-card-btn").click }
it "opens correct channel" do
# at this point the ChatChannel is not created yet
expect(page).to have_css(".chat-drawer.is-expanded")
expect(page).to have_css(
".chat-drawer.is-expanded[data-chat-channel-id='#{Chat::Channel.last.id}']",
)
end
end
end
end
end
context "when anonymous" do
context "when showing user card" do
before do
visit("/")
find("[data-user-card='#{topic_1.user.username}'").click
end
include_examples "not showing chat button"
end
end
end