discourse/plugins/chat/spec/system/shortcuts/sidebar_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

51 lines
1.4 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Shortcuts | sidebar", type: :system do
fab!(:current_user) { Fabricate(:admin) }
let(:chat) { PageObjects::Pages::Chat.new }
before do
SiteSetting.navigation_menu = "sidebar"
chat_system_bootstrap
sign_in(current_user)
end
context "when using Up/Down arrows" do
fab!(:channel_1) { Fabricate(:chat_channel) }
fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user]) }
before { channel_1.add(current_user) }
context "when on homepage" do
it "does nothing" do
visit("/")
find("body").send_keys(%i[alt arrow_down])
expect(page).to have_no_selector(".channel-#{channel_1.id}.active")
expect(page).to have_no_selector(".channel-#{dm_channel_1.id}.active")
end
end
context "when on chat page" do
it "navigates through the channels" do
chat.visit_channel(channel_1)
expect(page).to have_selector(".channel-#{channel_1.id}.active")
find("body").send_keys(%i[alt arrow_down])
expect(page).to have_selector(".channel-#{dm_channel_1.id}.active")
find("body").send_keys(%i[alt arrow_down])
expect(page).to have_selector(".channel-#{channel_1.id}.active")
find("body").send_keys(%i[alt arrow_up])
expect(page).to have_selector(".channel-#{dm_channel_1.id}.active")
end
end
end
end