Skip to content

A platform for community discussion. Free, open, simple.

FIX: chat bookmarks in drawer mode (#29757)

Régis Hanolfd1220af69f6
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat.js b/plugins/chat/assets/javascripts/discourse/routes/chat.js
index 3890c297b03..1f203707b1f 100644
--- a/plugins/chat/assets/javascripts/discourse/routes/chat.js
+++ b/plugins/chat/assets/javascripts/discourse/routes/chat.js
@@ -34,11 +34,8 @@ export default class ChatRoute extends DiscourseRoute {
) {
transition.abort();
- if (this.chatDrawerRouter.currentRouteName === transition.targetName) {
- return;
- }
-
let url = transition.intent.url;
+
if (transition.targetName.startsWith("chat.channel")) {
url ??= this.router.urlFor(
transition.targetName,
@@ -49,6 +46,7 @@ export default class ChatRoute extends DiscourseRoute {
}
this.appEvents.trigger("chat:open-url", url);
+
return;
}
diff --git a/plugins/chat/spec/system/bookmark_message_spec.rb b/plugins/chat/spec/system/bookmark_message_spec.rb
index 303416dbbcd..365a4c11755 100644
--- a/plugins/chat/spec/system/bookmark_message_spec.rb
+++ b/plugins/chat/spec/system/bookmark_message_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe "Bookmark message", type: :system do
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:thread_page) { PageObjects::Pages::ChatThread.new }
let(:bookmark_modal) { PageObjects::Modals::Bookmark.new }
+ let(:user_menu) { PageObjects::Components::UserMenu.new }
fab!(:category_channel_1) { Fabricate(:category_channel) }
fab!(:message_1) { Fabricate(:chat_message, chat_channel: category_channel_1) }
@@ -48,6 +49,36 @@ RSpec.describe "Bookmark message", type: :system do
expect(thread_page).to have_bookmarked_message(first_message)
end
+ context "in drawer mode" do
+ fab!(:category_channel_2) { Fabricate(:category_channel) }
+ fab!(:message_2) { Fabricate(:chat_message, chat_channel: category_channel_2) }
+
+ fab!(:bookmark_1) { Bookmark.create!(bookmarkable: message_1, user: current_user) }
+ fab!(:bookmark_2) { Bookmark.create!(bookmarkable: message_2, user: current_user) }
+
+ before do
+ chat_page.prefers_drawer
+ category_channel_2.add(current_user)
+ end
+
+ it "supports visiting multiple chat bookmarks from the user menu" do
+ visit("/")
+
+ user_menu.open
+ user_menu.click_bookmarks_tab
+
+ expect(user_menu).to have_bookmark_count_of(2)
+
+ user_menu.click_bookmark(bookmark_1)
+
+ expect(channel_page).to have_bookmarked_message(message_1)
+
+ user_menu.click_bookmark(bookmark_2)
+
+ expect(channel_page).to have_bookmarked_message(message_2)
+ end
+ end
+
context "when the user has a bookmark auto_delete_preference" do
before do
current_user.user_option.update!(
diff --git a/spec/system/page_objects/components/user_menu.rb b/spec/system/page_objects/components/user_menu.rb
index 6f63c2a9ed7..0591bb12877 100644
--- a/spec/system/page_objects/components/user_menu.rb
+++ b/spec/system/page_objects/components/user_menu.rb
@@ -15,6 +15,12 @@ module PageObjects
self
end
+ def click_bookmarks_tab
+ click_link("user-menu-button-bookmarks")
+ has_css?("#quick-access-bookmarks")
+ self
+ end
+
def click_profile_tab
click_link("user-menu-button-profile")
has_css?("#quick-access-profile")
@@ -27,6 +33,11 @@ module PageObjects
self
end
+ def click_bookmark(bookmark)
+ find("#quick-access-bookmarks .bookmark a[href='#{bookmark.bookmarkable.url}']").click
+ self
+ end
+
def sign_out
open
click_profile_tab
@@ -47,6 +58,10 @@ module PageObjects
def has_notification_count_of?(count)
page.has_css?(".user-menu li.notification", count: count)
end
+
+ def has_bookmark_count_of?(count)
+ page.has_css?(".user-menu #quick-access-bookmarks li.bookmark", count: count)
+ end
end
end
end