diff --git a/plugins/chat/spec/system/channel_selector_modal_spec.rb b/plugins/chat/spec/system/channel_selector_modal_spec.rb index 2cb9f5713fb..0b133238d94 100644 --- a/plugins/chat/spec/system/channel_selector_modal_spec.rb +++ b/plugins/chat/spec/system/channel_selector_modal_spec.rb @@ -5,6 +5,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do 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 @@ -12,13 +13,11 @@ RSpec.describe "Channel selector modal", type: :system, js: true do visit("/") end - KEY_MODIFIER = RUBY_PLATFORM =~ /darwin/i ? :meta : :control - context "when used with public channel" do fab!(:channel_1) { Fabricate(:category_channel) } it "works" do - find("body").send_keys([KEY_MODIFIER, "k"]) + 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") @@ -31,7 +30,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do fab!(:user_1) { Fabricate(:user) } it "works" do - find("body").send_keys([KEY_MODIFIER, "k"]) + 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") @@ -44,7 +43,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user]) } it "works" do - find("body").send_keys([KEY_MODIFIER, "k"]) + 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") @@ -58,7 +57,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do it "it doesn’t include current channel" do chat_page.visit_channel(channel_1) - find("body").send_keys([KEY_MODIFIER, "k"]) + 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}']") @@ -71,7 +70,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do it "it doesn’t include limited access channel" do chat_page.visit_channel(channel_1) - find("body").send_keys([KEY_MODIFIER, "k"]) + 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}']") diff --git a/plugins/chat/spec/system/shortcuts/chat_composer_spec.rb b/plugins/chat/spec/system/shortcuts/chat_composer_spec.rb index be1d9098994..54a4f8ac83b 100644 --- a/plugins/chat/spec/system/shortcuts/chat_composer_spec.rb +++ b/plugins/chat/spec/system/shortcuts/chat_composer_spec.rb @@ -6,8 +6,7 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do let(:chat) { PageObjects::Pages::Chat.new } let(:channel_page) { PageObjects::Pages::ChatChannel.new } - - KEY_MODIFIER = RUBY_PLATFORM =~ /darwin/i ? :meta : :control + let(:key_modifier) { RUBY_PLATFORM =~ /darwin/i ? :meta : :control } before do chat_system_bootstrap @@ -25,7 +24,7 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do chat.visit_channel(channel_1) within(".chat-composer-input") do |composer| - composer.send_keys([KEY_MODIFIER, "b"]) + composer.send_keys([key_modifier, "b"]) expect(composer.value).to eq("**strong text**") end @@ -37,7 +36,7 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do chat.visit_channel(channel_1) within(".chat-composer-input") do |composer| - composer.send_keys([KEY_MODIFIER, "i"]) + composer.send_keys([key_modifier, "i"]) expect(composer.value).to eq("_emphasized text_") end @@ -49,7 +48,7 @@ RSpec.describe "Shortcuts | chat composer", type: :system, js: true do chat.visit_channel(channel_1) within(".chat-composer-input") do |composer| - composer.send_keys([KEY_MODIFIER, "e"]) + composer.send_keys([key_modifier, "e"]) expect(composer.value).to eq("`indent preformatted text by 4 spaces`") end