FEATURE: move posts to new/existing PM (#6802)

This commit is contained in:
Arpit Jalan
2018-12-31 17:17:22 +05:30
committed by GitHub
parent b478984f60
commit 70fdc10365
22 changed files with 1357 additions and 691 deletions

View File

@@ -0,0 +1,121 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Topic move posts", { loggedIn: true });
QUnit.test("default", async assert => {
await visit("/t/internationalization-localization");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
await click("#post_11 .select-below");
assert.equal(
find(".selected-posts .move-to-topic")
.text()
.trim(),
I18n.t("topic.move_to.action"),
"it should show the move to button"
);
await click(".selected-posts .move-to-topic");
assert.ok(
find(".move-to-modal .title")
.html()
.includes(I18n.t("topic.move_to.title")),
"it opens move to modal"
);
assert.ok(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.split_topic.radio_label")),
"it shows an option to move to new topic"
);
assert.ok(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.merge_topic.radio_label")),
"it shows an option to move to existing topic"
);
assert.ok(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.move_to_new_message.radio_label")),
"it shows an option to move to new message"
);
});
QUnit.test("moving all posts", async assert => {
await visit("/t/internationalization-localization");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
await click(".select-all");
await click(".selected-posts .move-to-topic");
assert.ok(
find(".move-to-modal .title")
.html()
.includes(I18n.t("topic.move_to.title")),
"it opens move to modal"
);
assert.not(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.split_topic.radio_label")),
"it does not show an option to move to new topic"
);
assert.ok(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.merge_topic.radio_label")),
"it shows an option to move to existing topic"
);
assert.not(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.move_to_new_message.radio_label")),
"it does not show an option to move to new message"
);
});
QUnit.test("moving posts from personal message", async assert => {
await visit("/t/pm-for-testing/12");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
await click("#post_1 .select-post");
assert.equal(
find(".selected-posts .move-to-topic")
.text()
.trim(),
I18n.t("topic.move_to.action"),
"it should show the move to button"
);
await click(".selected-posts .move-to-topic");
assert.ok(
find(".move-to-modal .title")
.html()
.includes(I18n.t("topic.move_to.title")),
"it opens move to modal"
);
assert.ok(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.move_to_new_message.radio_label")),
"it shows an option to move to new message"
);
assert.ok(
find(".move-to-modal .radios")
.html()
.includes(I18n.t("topic.move_to_existing_message.radio_label")),
"it shows an option to move to existing message"
);
});

View File

@@ -281,10 +281,6 @@ QUnit.test("Can split/merge topic", function(assert) {
const controller = this.subject({ model });
const selectedPostIds = controller.get("selectedPostIds");
assert.not(
controller.get("canSplitTopic"),
"can't split topic when no posts are selected"
);
assert.not(
controller.get("canMergeTopic"),
"can't merge topic when no posts are selected"
@@ -292,10 +288,6 @@ QUnit.test("Can split/merge topic", function(assert) {
selectedPostIds.pushObject(1);
assert.not(
controller.get("canSplitTopic"),
"can't split topic when can't move posts"
);
assert.not(
controller.get("canMergeTopic"),
"can't merge topic when can't move posts"
@@ -303,16 +295,11 @@ QUnit.test("Can split/merge topic", function(assert) {
model.set("details.can_move_posts", true);
assert.ok(controller.get("canSplitTopic"), "can split topic");
assert.ok(controller.get("canMergeTopic"), "can merge topic");
selectedPostIds.removeObject(1);
selectedPostIds.pushObject(2);
assert.not(
controller.get("canSplitTopic"),
"can't split topic when 1st post is not a regular post"
);
assert.ok(
controller.get("canMergeTopic"),
"can merge topic when 1st post is not a regular post"
@@ -320,10 +307,6 @@ QUnit.test("Can split/merge topic", function(assert) {
selectedPostIds.pushObject(3);
assert.not(
controller.get("canSplitTopic"),
"can't split topic when all posts are selected"
);
assert.ok(
controller.get("canMergeTopic"),
"can merge topic when all posts are selected"