FIX: Select topics instead of posts (#15674)

A code error caused post objects to be added to the selected array.
This commit is contained in:
Bianca Nenciu 2022-01-21 19:52:09 +02:00 committed by GitHub
parent 984089c94a
commit 3bb1cd5c4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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);
});
});