DEV: add JS test for topic bulk action modal (#12621)

DEV: add JS test for topic bulk action modal (#12621)

diff --git a/app/assets/javascripts/discourse/app/templates/components/bulk-select-button.hbs b/app/assets/javascripts/discourse/app/templates/components/bulk-select-button.hbs
index 9a950ed..bdc803a 100644
--- a/app/assets/javascripts/discourse/app/templates/components/bulk-select-button.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/bulk-select-button.hbs
@@ -1,5 +1,5 @@
 {{#if selected}}
   <div id="bulk-select">
-    {{d-button class="btn-default" action=(action "showBulkActions") icon="wrench"}}
+    {{d-button class="btn-default bulk-select-btn" action=(action "showBulkActions") icon="wrench"}}
   </div>
 {{/if}}
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js
new file mode 100644
index 0000000..c285eda
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js
@@ -0,0 +1,124 @@
+import {
+  acceptance,
+  invisible,
+  queryAll,
+  updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import { click, visit } from "@ember/test-helpers";
+import { test } from "qunit";
+import I18n from "I18n";
+
+acceptance("Topic - Bulk Actions", function (needs) {
+  needs.user();
+  needs.settings({ tagging_enabled: true });
+  needs.pretender((server, helper) => {
+    server.put("/topics/bulk", () => {
+      return helper.response({
+        topic_ids: [],
+      });
+    });
+  });
+
+  test("bulk select - modal", async function (assert) {
+    updateCurrentUser({ moderator: true });
+    await visit("/latest");
+    await click("button.bulk-select");
+
+    await click(queryAll("input.bulk-select")[0]);
+    await click(queryAll("input.bulk-select")[1]);
+
+    await click(".bulk-select-btn");
+
+    assert.ok(
+      queryAll("#discourse-modal-title")
+        .html()
+        .includes(I18n.t("topics.bulk.actions")),
+      "it opens bulk-select modal"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.change_category")),
+      "it shows an option to change category"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.close_topics")),
+      "it shows an option to close topics"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.archive_topics")),
+      "it shows an option to archive topics"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.notification_level")),
+      "it shows an option to update notification level"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.reset_read")),
+      "it shows an option to reset read"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.unlist_topics")),
+      "it shows an option to unlist topics"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.change_tags")),
+      "it shows an option to replace tags"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.append_tags")),
+      "it shows an option to append tags"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons")
+        .html()
+        .includes(I18n.t("topics.bulk.remove_tags")),
+      "it shows an option to remove all tags"
+    );
+
+    assert.ok(
+      queryAll(".bulk-buttons").html().includes(I18n.t("topics.bulk.delete")),
+      "it shows an option to delete topics"
+    );
+  });
+
+  test("bulk select - delete topics", async function (assert) {
+    updateCurrentUser({ moderator: true });
+    await visit("/latest");
+    await click("button.bulk-select");
+
+    await click(queryAll("input.bulk-select")[0]);
+    await click(queryAll("input.bulk-select")[1]);
+
+    await click(".bulk-select-btn");
+    await click(".modal-body button[aria-label='Delete Topics']");
+
+    assert.ok(
+      invisible(".topic-bulk-actions-modal"),
+      "it closes the bulk select modal"
+    );
+  });
+});

GitHub sha: 21664d8a

This commit appears in #12621 which was approved by eviltrout. It was merged by techAPJ.