2018-06-15 11:03:24 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
import { _clearSnapshots } from "select-kit/components/composer-actions";
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
acceptance("Composer Actions", {
|
2018-02-01 10:42:56 -05:00
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
|
|
|
enable_whispers: true
|
2018-05-23 13:57:12 -04:00
|
|
|
},
|
|
|
|
beforeEach() {
|
|
|
|
_clearSnapshots();
|
2018-06-15 11:03:24 -04:00
|
|
|
}
|
2018-02-01 10:42:56 -05:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("replying to post", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click("article#post_3 button.reply");
|
2018-04-23 02:42:25 -04:00
|
|
|
await composerActions.expandAwait();
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
|
|
|
|
assert.equal(
|
|
|
|
composerActions.rowByIndex(1).value(),
|
|
|
|
"reply_as_private_message"
|
|
|
|
);
|
|
|
|
assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic");
|
|
|
|
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
|
2018-04-23 02:42:25 -04:00
|
|
|
assert.equal(composerActions.rowByIndex(4).value(), undefined);
|
2018-02-01 10:42:56 -05:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("replying to post - reply_as_private_message", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click("article#post_3 button.reply");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-05-22 20:16:23 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_as_private_message");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror");
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-input")
|
|
|
|
.val()
|
|
|
|
.indexOf("Continuing the discussion") >= 0
|
|
|
|
);
|
2018-02-01 10:42:56 -05:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("replying to post - reply_to_topic", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click("article#post_3 button.reply");
|
|
|
|
await fillIn(
|
|
|
|
".d-editor-input",
|
|
|
|
"test replying to topic when initially replied to post"
|
|
|
|
);
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-05-21 23:56:11 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_to_topic");
|
2018-05-21 23:56:11 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".action-title .topic-link")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"Internationalization / localization"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".action-title .topic-link").attr("href"),
|
|
|
|
"/t/internationalization-localization/280"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find(".d-editor-input").val(),
|
|
|
|
"test replying to topic when initially replied to post"
|
|
|
|
);
|
2018-02-01 10:42:56 -05:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("replying to post - toggle_whisper", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click("article#post_3 button.reply");
|
|
|
|
await fillIn(
|
|
|
|
".d-editor-input",
|
|
|
|
"test replying as whisper to topic when initially not a whisper"
|
|
|
|
);
|
2018-05-23 09:52:15 -04:00
|
|
|
|
|
|
|
await composerActions.expandAwait();
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("toggle_whisper");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-05-23 09:52:15 -04:00
|
|
|
assert.ok(
|
2018-06-15 11:03:24 -04:00
|
|
|
find(".composer-fields .whisper")
|
|
|
|
.text()
|
|
|
|
.indexOf(I18n.t("composer.whisper")) > 0
|
2018-05-23 09:52:15 -04:00
|
|
|
);
|
2018-02-01 10:42:56 -05:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("replying to post - reply_as_new_topic", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
|
|
|
const categoryChooser = selectKit(".title-wrapper .category-chooser");
|
|
|
|
const categoryChooserReplyArea = selectKit(".reply-area .category-chooser");
|
|
|
|
const quote = "test replying as new topic when initially replied to post";
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/t/internationalization-localization/280");
|
2018-05-23 09:52:15 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await click("#topic-title .d-icon-pencil");
|
2018-05-23 09:52:15 -04:00
|
|
|
await categoryChooser.expandAwait();
|
|
|
|
await categoryChooser.selectRowByValueAwait(4);
|
2018-06-15 11:03:24 -04:00
|
|
|
await click("#topic-title .submit-edit");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await click("article#post_3 button.reply");
|
|
|
|
await fillIn(".d-editor-input", quote);
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-05-23 09:52:15 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_as_new_topic");
|
2018-02-01 10:42:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(categoryChooserReplyArea.header().name(), "faq");
|
|
|
|
assert.equal(
|
|
|
|
find(".action-title")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("topic.create_long")
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-input")
|
|
|
|
.val()
|
|
|
|
.includes(quote)
|
|
|
|
);
|
2018-02-08 05:46:55 -05:00
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("shared draft", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
2018-05-23 09:52:15 -04:00
|
|
|
|
|
|
|
await visit("/");
|
2018-06-15 11:03:24 -04:00
|
|
|
await click("#create-topic");
|
2018-05-23 09:52:15 -04:00
|
|
|
|
|
|
|
await composerActions.expandAwait();
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("shared_draft");
|
2018-05-23 09:52:15 -04:00
|
|
|
|
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
find("#reply-control .btn-primary.create .d-button-label").text(),
|
|
|
|
I18n.t("composer.create_shared_draft")
|
2018-05-23 09:52:15 -04:00
|
|
|
);
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(find("#reply-control.composing-shared-draft").length === 1);
|
2018-03-13 15:59:12 -04:00
|
|
|
});
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("hide component if no content", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
2018-05-23 12:25:58 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/u/eviltrout/messages");
|
|
|
|
await click(".new-private-message");
|
2018-05-23 12:25:58 -04:00
|
|
|
|
|
|
|
assert.ok(composerActions.el().hasClass("is-hidden"));
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("interactions", async assert => {
|
|
|
|
const composerActions = selectKit(".composer-actions");
|
|
|
|
const quote = "Life is like riding a bicycle.";
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click("article#post_3 button.reply");
|
|
|
|
await fillIn(".d-editor-input", quote);
|
2018-05-22 04:50:54 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_to_topic");
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".action-title")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"Internationalization / localization"
|
|
|
|
);
|
|
|
|
assert.equal(find(".d-editor-input").val(), quote);
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-05-22 04:50:54 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
|
|
|
|
assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post");
|
|
|
|
assert.equal(
|
|
|
|
composerActions.rowByIndex(2).value(),
|
|
|
|
"reply_as_private_message"
|
|
|
|
);
|
|
|
|
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
|
2018-05-23 09:52:15 -04:00
|
|
|
assert.equal(composerActions.rows().length, 4);
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_to_post");
|
2018-05-22 04:50:54 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(exists(find(".action-title img.avatar")));
|
|
|
|
assert.equal(
|
|
|
|
find(".action-title .user-link")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
"codinghorror"
|
|
|
|
);
|
|
|
|
assert.equal(find(".d-editor-input").val(), quote);
|
|
|
|
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
|
|
|
|
assert.equal(
|
|
|
|
composerActions.rowByIndex(1).value(),
|
|
|
|
"reply_as_private_message"
|
|
|
|
);
|
|
|
|
assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic");
|
|
|
|
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
|
2018-05-23 09:52:15 -04:00
|
|
|
assert.equal(composerActions.rows().length, 4);
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_as_new_topic");
|
2018-05-22 04:50:54 -04:00
|
|
|
await composerActions.expandAwait();
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".action-title")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("topic.create_long")
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-input")
|
|
|
|
.val()
|
|
|
|
.includes(quote)
|
|
|
|
);
|
|
|
|
assert.equal(composerActions.rowByIndex(0).value(), "reply_to_post");
|
|
|
|
assert.equal(
|
|
|
|
composerActions.rowByIndex(1).value(),
|
|
|
|
"reply_as_private_message"
|
|
|
|
);
|
|
|
|
assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic");
|
|
|
|
assert.equal(composerActions.rowByIndex(3).value(), "shared_draft");
|
2018-05-23 09:52:15 -04:00
|
|
|
assert.equal(composerActions.rows().length, 4);
|
2018-02-08 05:46:55 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
await composerActions.selectRowByValueAwait("reply_as_private_message");
|
2018-05-22 04:50:54 -04:00
|
|
|
await composerActions.expandAwait();
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".action-title")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("topic.private_message")
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
find(".d-editor-input")
|
|
|
|
.val()
|
|
|
|
.indexOf("Continuing the discussion") === 0
|
|
|
|
);
|
|
|
|
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
|
|
|
|
assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post");
|
|
|
|
assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic");
|
2018-05-23 09:52:15 -04:00
|
|
|
assert.equal(composerActions.rows().length, 3);
|
2018-02-01 10:42:56 -05:00
|
|
|
});
|