diff --git a/app/assets/javascripts/discourse/app/components/topic-list.js b/app/assets/javascripts/discourse/app/components/topic-list.js index 4a4ee62697e..c425dc1a666 100644 --- a/app/assets/javascripts/discourse/app/components/topic-list.js +++ b/app/assets/javascripts/discourse/app/components/topic-list.js @@ -72,7 +72,9 @@ export default class TopicList extends Component.extend(LoadMore) { // for the classNameBindings @dependentKeyCompat get bulkSelectEnabled() { - return this.bulkSelectHelper?.bulkSelectEnabled; + return ( + this.get("canBulkSelect") && this.bulkSelectHelper?.bulkSelectEnabled + ); } get toggleInTitle() { diff --git a/spec/system/discovery_list_spec.rb b/spec/system/discovery_list_spec.rb index 1ac2c564016..364a039fe6b 100644 --- a/spec/system/discovery_list_spec.rb +++ b/spec/system/discovery_list_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe "Topic list focus", type: :system do +describe "Discovery list", type: :system do fab!(:topics) { Fabricate.times(10, :post).map(&:topic) } fab!(:reply) { Fabricate(:post, topic: topics.first) } @@ -38,4 +38,27 @@ describe "Topic list focus", type: :system do expect(page).to have_css("th[data-sort-order='posts'][aria-sort=ascending]") expect(nth_topic_id(10)).to eq(reply.topic_id.to_s) end + + describe "bulk topic options" do + fab!(:user) + fab!(:topic) { Fabricate(:topic, user: user) } + fab!(:post1) { create_post(user: user, topic: topic) } + fab!(:post2) { create_post(topic: topic) } + + it "should correctly show/hide the bulk select toggle for regular users" do + sign_in(user) + visit("/unread") + + # The bulk select toggle should be visible, the user has an unread post + find("button.bulk-select").click + expect(page).to have_css(".topic-list-body .bulk-select") + + find("#navigation-bar .latest > a").click + + # No bulk select toggle or checkboxes + # this action is not available for this user in /latest + expect(page).to have_no_css(".topic-list-body .bulk-select") + expect(page).to have_no_css("button.bulk-select") + end + end end