Skip to content

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

FIX: Select topics instead of posts (#15674)

Bianca Nenciu3bb1cd5c4d89
diff --git a/app/assets/javascripts/discourse/app/controllers/full-page-search.js b/app/assets/javascripts/discourse/app/controllers/full-page-search.js
index bec3624eb4c..c364cb3f815 100644
--- a/app/assets/javascripts/discourse/app/controllers/full-page-search.js
+++ b/app/assets/javascripts/discourse/app/controllers/full-page-search.js
@@ -406,7 +406,7 @@ export default Controller.extend({
},
selectAll() {
- this.selected.addObjects(this.get("model.posts")).mapBy("topic");
+ this.selected.addObjects(this.get("model.posts").mapBy("topic"));
// Doing this the proper way is a HUGE pain,
// we can hack this to work by observing each on the array
diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js
index 950cf0729c9..19169cfd2a2 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js
@@ -16,6 +16,8 @@ import {
} from "discourse/controllers/full-page-search";
import selectKit from "discourse/tests/helpers/select-kit-helper";
+let lastBody;
+
acceptance("Search - Full Page", function (needs) {
needs.user();
needs.settings({ tagging_enabled: true });
@@ -91,6 +93,11 @@ acceptance("Search - Full Page", function (needs) {
],
});
});
+
+ server.put("/topics/bulk", (request) => {
+ lastBody = helper.parsePostData(request.requestBody);
+ return helper.response({ topic_ids: [7] });
+ });
});
test("perform various searches", async function (assert) {
@@ -580,4 +587,15 @@ acceptance("Search - Full Page", function (needs) {
"clicking on element expands filters"
);
});
+
+ test("bulk operations work", async function (assert) {
+ await visit("/search");
+ await fillIn(".search-query", "discourse");
+ await click(".search-cta");
+ await click(".bulk-select"); // toggle bulk
+ await click(".bulk-select-visible .btn:nth-child(2)"); // select all
+ await click(".bulk-select-btn"); // show bulk actions
+ await click(".topic-bulk-actions-modal .btn:nth-child(2)"); // close topics
+ assert.equal(lastBody["topic_ids[]"], 7);
+ });
});