discourse/plugins/chat/spec/system/channel_selector_modal_spec.rb
Alan Guo Xiang Tan 41f8bff2c3
DEV: Remove superfluous js: true metadata (#21960)
Why this change?

It is very unlikely that we need to ever JS for system tests considering
that we rely on a JS framework on the frontend.
2023-06-07 09:26:58 +08:00

81 lines
2.5 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 "Channel selector modal", type: :system do
fab!(:current_user) { Fabricate(:user) }
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:key_modifier) { RUBY_PLATFORM =~ /darwin/i ? :meta : :control }
before do
chat_system_bootstrap
sign_in(current_user)
visit("/")
end
context "when used with public channel" do
fab!(:channel_1) { Fabricate(:category_channel) }
it "works" do
find("body").send_keys([key_modifier, "k"])
find("#chat-channel-selector-input").fill_in(with: channel_1.title)
find(".chat-channel-selection-row[data-id='#{channel_1.id}']").click
channel_page.send_message("Hello world")
expect(channel_page).to have_message(text: "Hello world")
end
end
context "when used with user" do
fab!(:user_1) { Fabricate(:user) }
it "works" do
find("body").send_keys([key_modifier, "k"])
find("#chat-channel-selector-input").fill_in(with: user_1.username)
find(".chat-channel-selection-row[data-id='#{user_1.id}']").click
channel_page.send_message("Hello world")
expect(channel_page).to have_message(text: "Hello world")
end
end
context "when used with dm channel" do
fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user]) }
it "works" do
find("body").send_keys([key_modifier, "k"])
find("#chat-channel-selector-input").fill_in(with: current_user.username)
find(".chat-channel-selection-row[data-id='#{dm_channel_1.id}']").click
channel_page.send_message("Hello world")
expect(channel_page).to have_message(text: "Hello world")
end
end
context "when on a channel" do
fab!(:channel_1) { Fabricate(:category_channel) }
it "it doesnt include current channel" do
chat_page.visit_channel(channel_1)
find("body").send_keys([key_modifier, "k"])
find("#chat-channel-selector-input").click
expect(page).to have_no_css(".chat-channel-selection-row[data-id='#{channel_1.id}']")
end
end
context "with limited access channels" do
fab!(:group_1) { Fabricate(:group) }
fab!(:channel_1) { Fabricate(:private_category_channel, group: group_1) }
it "it doesnt include limited access channel" do
find("body").send_keys([key_modifier, "k"])
find("#chat-channel-selector-input").fill_in(with: channel_1.title)
expect(page).to have_no_css(".chat-channel-selection-row[data-id='#{channel_1.id}']")
end
end
end