A platform for community discussion. Free, open, simple.
FIX: re-enables using_session tests (#19564)
Joffrey JAFFEUXdaff62e3cb39
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-selector-modal-inner.js b/plugins/chat/assets/javascripts/discourse/components/chat-channel-selector-modal-inner.jsindex 1937ff6bdae..86ac4fe5615 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-selector-modal-inner.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-selector-modal-inner.js@@ -192,13 +192,11 @@ export default Component.extend({const trimmedFilter = filter.trim();const lowerCasedFilter = filter.toLowerCase();- const { activeChannel } = this;return sortedChannels.filter((channel) => {if (opts.excludeActiveChannel &&- activeChannel &&- activeChannel.id === channel.id+ this.chat.activeChannel?.id === channel.id) {return false;}diff --git a/plugins/chat/spec/system/channel_members_page_spec.rb b/plugins/chat/spec/system/channel_members_page_spec.rbindex 5643e937f99..a8325694d25 100644--- a/plugins/chat/spec/system/channel_members_page_spec.rb+++ b/plugins/chat/spec/system/channel_members_page_spec.rb@@ -39,6 +39,7 @@ RSpec.describe "Channel - Info - Members page", type: :system, js: true do98.times { channel_1.add(Fabricate(:user)) }channel_1.update!(user_count_stale: true)+ Jobs.run_immediately!Jobs::UpdateChannelUserCount.new.execute(chat_channel_id: channel_1.id)enddiff --git a/plugins/chat/spec/system/channel_selector_modal_spec.rb b/plugins/chat/spec/system/channel_selector_modal_spec.rbindex 255101ea93e..5aa834362b5 100644--- a/plugins/chat/spec/system/channel_selector_modal_spec.rb+++ b/plugins/chat/spec/system/channel_selector_modal_spec.rb@@ -58,7 +58,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true doit "it doesn’t include current channel" dochat_page.visit_channel(channel_1)find("body").send_keys([KEY_MODIFIER, "k"])- find("#chat-channel-selector-input").fill_in(with: channel_1.title)+ find("#chat-channel-selector-input").clickexpect(page).to have_no_css(".chat-channel-selection-row[data-id='#{channel_1.id}']")enddiff --git a/plugins/chat/spec/system/edited_message_spec.rb b/plugins/chat/spec/system/edited_message_spec.rbindex 199eaa6ba5e..550b1ea9f15 100644--- a/plugins/chat/spec/system/edited_message_spec.rb+++ b/plugins/chat/spec/system/edited_message_spec.rb@@ -17,10 +17,10 @@ RSpec.describe "Edited message", type: :system, js: true doendcontext "when editing message" do- xit "shows as edited for all users" do+ it "shows as edited for all users" dochat_page.visit_channel(channel_1)- using_session(editing_user.username) do+ using_session(:user_1) dosign_in(editing_user)chat_page.visit_channel(channel_1)channel_page.edit_message(message_1, "a different message")diff --git a/plugins/chat/spec/system/message_notifications_mobile_spec.rb b/plugins/chat/spec/system/message_notifications_mobile_spec.rbindex d94c43e4968..40a099e25c0 100644--- a/plugins/chat/spec/system/message_notifications_mobile_spec.rb+++ b/plugins/chat/spec/system/message_notifications_mobile_spec.rb@@ -12,12 +12,10 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobileenddef create_message(text: "this is fine", channel:, creator: Fabricate(:user))- using_session(creator.username) do- sign_in(creator)- chat_page.visit_channel(channel)- chat_channel_page.send_message(text)- expect(chat_channel_page).to have_message(text: text)- end+ sign_in(creator)+ chat_page.visit_channel(channel)+ chat_channel_page.send_message(text)+ expect(chat_channel_page).to have_message(text: text)endcontext "as a user" do@@ -33,9 +31,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobilecontext "when not member of the channel" docontext "when a message is created" do- xit "doesn't show anything" do+ it "doesn't show anything" dovisit("/chat")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")expect(page).to have_no_css(@@ -59,9 +57,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile)end- xit "doesn’t show indicator in header" do+ it "doesn’t show indicator in header" dovisit("/chat")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_css(".do-not-disturb-background")expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")@@ -72,9 +70,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobilebefore { channel_1.membership_for(current_user).update!(muted: true) }context "when a message is created" do- xit "doesn't show anything" do+ it "doesn't show anything" dovisit("/chat")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")expect(page).to have_no_css(@@ -85,9 +83,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobileendcontext "when a message is created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/chat")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")expect(page).to have_css(@@ -98,13 +96,15 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobileendcontext "when a message with mentions is created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/chat")- create_message(- channel: channel_1,- creator: user_1,- text: "hello @#{current_user.username} what's up?",- )+ using_session(:user_1) do+ create_message(+ channel: channel_1,+ creator: user_1,+ text: "hello @#{current_user.username} what's up?",+ )+ endexpect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator")expect(page).to have_css(@@ -125,21 +125,21 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobilefab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, user_2]) }context "when a message is created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/chat")- create_message(channel: dm_channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1")expect(page).to have_css(".chat-channel-row[data-chat-channel-id=\"#{dm_channel_1.id}\"] .chat-channel-unread-indicator",)- create_message(channel: dm_channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "2")end- xit "reorders channels" do+ it "reorders channels" dovisit("/chat")expect(page).to have_css(@@ -148,7 +148,8 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobileexpect(page).to have_css(".chat-channel-row:nth-child(2)[data-chat-channel-id=\"#{dm_channel_2.id}\"]",)- create_message(channel: dm_channel_2, creator: user_2)++ using_session(:user_1) { create_message(channel: dm_channel_2, creator: user_2) }expect(page).to have_css(".chat-channel-row:nth-child(1)[data-chat-channel-id=\"#{dm_channel_2.id}\"]",@@ -172,16 +173,16 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobileendcontext "when messages are created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/chat")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")expect(page).to have_css(".chat-channel-row[data-chat-channel-id=\"#{channel_1.id}\"] .chat-channel-unread-indicator",)- create_message(channel: dm_channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }expect(page).to have_css(".chat-channel-row[data-chat-channel-id=\"#{dm_channel_1.id}\"] .chat-channel-unread-indicator",diff --git a/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb b/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rbindex 370aa699aac..dfb922b4686 100644--- a/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb+++ b/plugins/chat/spec/system/message_notifications_with_sidebar_spec.rb@@ -12,12 +12,10 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true denddef create_message(text: "this is fine", channel:, creator: Fabricate(:user))- using_session(creator.username) do- sign_in(creator)- chat_page.visit_channel(channel)- chat_channel_page.send_message(text)- expect(chat_channel_page).to have_message(text: text)- end+ sign_in(creator)+ chat_page.visit_channel(channel)+ chat_channel_page.send_message(text)+ expect(chat_channel_page).to have_message(text: text)endcontext "as a user" do@@ -33,9 +31,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true dcontext "when not member of the channel" docontext "when a message is created" do- xit "doesn't show anything" do+ it "doesn't show anything" dovisit("/")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")expect(page).to have_no_css(".sidebar-row.channel-#{channel_1.id}")@@ -57,9 +55,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d)end- xit "doesn’t show indicator in header" do+ it "doesn’t show indicator in header" dovisit("/")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_css(".do-not-disturb-background")expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")@@ -70,9 +68,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true dbefore { channel_1.membership_for(current_user).update!(muted: true) }context "when a message is created" do- xit "doesn't show anything" do+ it "doesn't show anything" dovisit("/")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")expect(page).to have_no_css(".sidebar-row.channel-#{channel_1.id} .unread")@@ -81,9 +79,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true dendcontext "when a message is created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")expect(page).to have_css(".sidebar-row.channel-#{channel_1.id} .unread")@@ -91,13 +89,15 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true dendcontext "when a message with mentions is created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/")- create_message(- channel: channel_1,- creator: user_1,- text: "hello @#{current_user.username} what's up?",- )+ using_session(:user_1) do+ create_message(+ channel: channel_1,+ creator: user_1,+ text: "hello @#{current_user.username} what's up?",+ )+ endexpect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator.urgent",@@ -118,19 +118,19 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true dfab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, user_2]) }context "when a message is created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/")- create_message(channel: dm_channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1")expect(page).to have_css(".sidebar-row.channel-#{dm_channel_1.id} .icon.urgent")- create_message(channel: dm_channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "2")end- xit "reorders channels" do+ it "reorders channels" dovisit("/chat")expect(page).to have_css(@@ -140,7 +140,7 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(2) .channel-#{dm_channel_2.id}",)- create_message(channel: dm_channel_2, creator: user_2)+ using_session(:user_1) { create_message(channel: dm_channel_2, creator: user_2) }expect(page).to have_css("#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(1) .channel-#{dm_channel_2.id}",@@ -164,14 +164,14 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true dendcontext "when messages are created" do- xit "correctly renders notifications" do+ it "correctly renders notifications" dovisit("/")- create_message(channel: channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")expect(page).to have_css(".sidebar-row.channel-#{channel_1.id} .unread")- create_message(channel: dm_channel_1, creator: user_1)+ using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }expect(page).to have_css(".sidebar-row.channel-#{dm_channel_1.id} .icon.urgent")expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1")diff --git a/plugins/chat/spec/system/replying_indicator_spec.rb b/plugins/chat/spec/system/replying_indicator_spec.rbindex b565e05d489..d2c1dd1a256 100644--- a/plugins/chat/spec/system/replying_indicator_spec.rb+++ b/plugins/chat/spec/system/replying_indicator_spec.rb@@ -16,8 +16,8 @@ RSpec.describe "Replying indicator", type: :system, js: true docontext "when on a channel" docontext "when another user is replying" do- xit "shows the replying indicator" do- using_session(other_user.username) do+ it "shows the replying indicator" do+ using_session(:user_1) dosign_in(other_user)chat.visit_channel(channel_1)find(".chat-composer-input").fill_in(with: "hello there")diff --git a/plugins/chat/spec/system/unfollow_dm_channel_spec.rb b/plugins/chat/spec/system/unfollow_dm_channel_spec.rbindex 149d75a26a9..361e7412970 100644--- a/plugins/chat/spec/system/unfollow_dm_channel_spec.rb+++ b/plugins/chat/spec/system/unfollow_dm_channel_spec.rb@@ -14,23 +14,20 @@ RSpec.describe "Unfollow dm channel", type: :system, js: true dosign_in(current_user)end- def create_message(text: "this is fine", channel:, creator: Fabricate(:user))- using_session(creator.username) do- sign_in(creator)- chat_page.visit_channel(channel)- chat_channel_page.send_message(text)- expect(chat_channel_page).to have_message(text: text)- end- end-context "when receiving a message after unfollowing" do- xit "correctly shows the channel" do+ it "correctly shows the channel" dofind(".channel-#{dm_channel_1.id}").hoverfind(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").clickexpect(page).to have_no_css(".channel-#{dm_channel_1.id}")- create_message(channel: dm_channel_1, creator: other_user)+ using_session(:user_1) do+ text = "this is fine"+ sign_in(other_user)+ chat_page.visit_channel(dm_channel_1)+ chat_channel_page.send_message(text)+ expect(chat_channel_page).to have_message(text: text)+ endexpect(page).to have_css(".channel-#{dm_channel_1.id} .urgent")enddiff --git a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rbindex 4b997a4092c..7ef58ab2fbd 100644--- a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb+++ b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb@@ -163,23 +163,23 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true dofab!(:other_user) { Fabricate(:user) }before do- other_user = Fabricate(:user)channel_1.add(current_user)endit "shows an invitation notification" dochat.visit_channel(channel_1)find(".chat-composer-input").fill_in(with: "this is fine @#{other_user.username}")- Sidekiq::Testing.inline! do- find(".send-btn").click- find(".invite-link").click- end+ find(".send-btn").click+ find(".chat-composer-input").click # ensures autocomplete is closed and not masking invite link+ find(".invite-link", wait: 5).click- sign_in(other_user)- find(".header-dropdown-toggle.current-user").click+ using_session(:user_1) do+ sign_in(other_user)+ find(".header-dropdown-toggle.current-user").click- expect(find("#user-menu-button-chat-notifications")).to have_content(1)- expect(find("#quick-access-all-notifications")).to have_css(".chat-invitation.unread")+ expect(find("#user-menu-button-chat-notifications")).to have_content(1)+ expect(find("#quick-access-all-notifications")).to have_css(".chat-invitation.unread")+ endendendend