mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 07:52:19 +08:00
DEV: add JS test for topic bulk action modal (#12621)
This commit is contained in:
parent
2e17e6269c
commit
21664d8a1c
|
@ -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}}
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user