2019-10-29 15:23:50 -04:00
|
|
|
import EmberObject from "@ember/object";
|
2015-04-01 14:18:46 -04:00
|
|
|
import { currentUser } from "helpers/qunit-helpers";
|
2019-10-04 10:06:08 -04:00
|
|
|
import AppEvents from "discourse/services/app-events";
|
2015-09-03 16:55:55 -04:00
|
|
|
import Composer from "discourse/models/composer";
|
2019-11-08 13:13:13 -05:00
|
|
|
import Post from "discourse/models/post";
|
2015-09-03 16:55:55 -04:00
|
|
|
import createStore from "helpers/create-store";
|
2015-04-01 14:18:46 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.module("model:composer");
|
2015-04-01 14:18:46 -04:00
|
|
|
|
|
|
|
function createComposer(opts) {
|
|
|
|
opts = opts || {};
|
|
|
|
opts.user = opts.user || currentUser();
|
2018-11-23 12:22:34 -05:00
|
|
|
opts.appEvents = AppEvents.create();
|
2015-09-03 16:55:55 -04:00
|
|
|
return createStore().createRecord("composer", opts);
|
|
|
|
}
|
|
|
|
|
|
|
|
function openComposer(opts) {
|
|
|
|
const composer = createComposer(opts);
|
|
|
|
composer.open(opts);
|
|
|
|
return composer;
|
2015-04-01 14:18:46 -04:00
|
|
|
}
|
2013-06-17 11:38:30 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("replyLength", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const replyLength = function(val, expectedLength) {
|
|
|
|
const composer = createComposer({ reply: val });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("replyLength"), expectedLength);
|
2013-06-17 11:38:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
replyLength("basic reply", 11, "basic reply length");
|
|
|
|
replyLength(" \nbasic reply\t", 11, "trims whitespaces");
|
|
|
|
replyLength("ba sic\n\nreply", 12, "count only significant whitespaces");
|
|
|
|
replyLength(
|
|
|
|
"1[quote=]not counted[/quote]2[quote=]at all[/quote]3",
|
|
|
|
3,
|
|
|
|
"removes quotes"
|
|
|
|
);
|
|
|
|
replyLength(
|
|
|
|
"1[quote=]not[quote=]counted[/quote]yay[/quote]2",
|
|
|
|
2,
|
|
|
|
"handles nested quotes correctly"
|
|
|
|
);
|
2013-06-20 12:33:21 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("missingReplyCharacters", assert => {
|
2015-03-19 10:17:55 -04:00
|
|
|
Discourse.SiteSettings.min_first_post_length = 40;
|
2015-04-01 14:18:46 -04:00
|
|
|
const missingReplyCharacters = function(
|
|
|
|
val,
|
|
|
|
isPM,
|
|
|
|
isFirstPost,
|
|
|
|
expected,
|
|
|
|
message
|
|
|
|
) {
|
|
|
|
const composer = createComposer({
|
|
|
|
reply: val,
|
|
|
|
creatingPrivateMessage: isPM,
|
|
|
|
creatingTopic: isFirstPost
|
|
|
|
});
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("missingReplyCharacters"), expected, message);
|
2013-06-21 14:06:20 -04:00
|
|
|
};
|
2013-06-20 12:33:21 -04:00
|
|
|
|
2015-03-19 10:17:55 -04:00
|
|
|
missingReplyCharacters(
|
|
|
|
"hi",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
Discourse.SiteSettings.min_post_length - 2,
|
|
|
|
"too short public post"
|
|
|
|
);
|
|
|
|
missingReplyCharacters(
|
|
|
|
"hi",
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
Discourse.SiteSettings.min_first_post_length - 2,
|
|
|
|
"too short first post"
|
|
|
|
);
|
2018-01-31 00:56:00 -05:00
|
|
|
missingReplyCharacters(
|
|
|
|
"hi",
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
Discourse.SiteSettings.min_personal_message_post_length - 2,
|
|
|
|
"too short private message"
|
|
|
|
);
|
2016-12-05 07:31:43 -05:00
|
|
|
|
2016-12-09 15:46:26 -05:00
|
|
|
const link = "http://imgur.com/gallery/grxX8";
|
|
|
|
const composer = createComposer({
|
|
|
|
canEditTopicFeaturedLink: true,
|
|
|
|
title: link,
|
|
|
|
featuredLink: link,
|
|
|
|
reply: link
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("missingReplyCharacters"),
|
|
|
|
0,
|
|
|
|
"don't require any post content"
|
|
|
|
);
|
2013-06-20 12:33:21 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("missingTitleCharacters", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const missingTitleCharacters = function(val, isPM, expected, message) {
|
|
|
|
const composer = createComposer({
|
|
|
|
title: val,
|
|
|
|
creatingPrivateMessage: isPM
|
|
|
|
});
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("missingTitleCharacters"), expected, message);
|
2013-06-21 14:06:20 -04:00
|
|
|
};
|
2013-06-20 12:33:21 -04:00
|
|
|
|
|
|
|
missingTitleCharacters(
|
|
|
|
"hi",
|
|
|
|
false,
|
|
|
|
Discourse.SiteSettings.min_topic_title_length - 2,
|
|
|
|
"too short post title"
|
|
|
|
);
|
2018-01-31 00:56:00 -05:00
|
|
|
missingTitleCharacters(
|
|
|
|
"z",
|
|
|
|
true,
|
|
|
|
Discourse.SiteSettings.min_personal_message_title_length - 1,
|
|
|
|
"too short pm title"
|
|
|
|
);
|
2013-07-04 13:35:15 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("replyDirty", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const composer = createComposer();
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("replyDirty"), "by default it's false");
|
2013-07-04 13:35:15 -04:00
|
|
|
|
|
|
|
composer.setProperties({
|
|
|
|
originalText: "hello",
|
|
|
|
reply: "hello"
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(
|
|
|
|
!composer.get("replyDirty"),
|
|
|
|
"it's false when the originalText is the same as the reply"
|
|
|
|
);
|
2013-07-04 13:35:15 -04:00
|
|
|
composer.set("reply", "hello world");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("replyDirty"), "it's true when the reply changes");
|
2013-07-05 11:53:09 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("appendText", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const composer = createComposer();
|
2013-07-05 11:53:09 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.blank(composer.get("reply"), "the reply is blank by default");
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.appendText("hello");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("reply"), "hello", "it appends text to nothing");
|
2013-07-05 11:53:09 -04:00
|
|
|
composer.appendText(" world");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("reply"),
|
|
|
|
"hello world",
|
|
|
|
"it appends text to existing text"
|
|
|
|
);
|
2013-07-05 11:53:09 -04:00
|
|
|
|
2014-06-18 01:17:32 -04:00
|
|
|
composer.clearState();
|
|
|
|
composer.appendText("a\n\n\n\nb");
|
|
|
|
composer.appendText("c", 3, { block: true });
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("reply"), "a\n\nc\n\nb");
|
2014-06-18 01:17:32 -04:00
|
|
|
|
|
|
|
composer.clearState();
|
|
|
|
composer.appendText("ab");
|
|
|
|
composer.appendText("c", 1, { block: true });
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("reply"), "a\n\nc\n\nb");
|
2014-06-18 01:17:32 -04:00
|
|
|
|
|
|
|
composer.clearState();
|
|
|
|
composer.appendText("\nab");
|
|
|
|
composer.appendText("c", 0, { block: true });
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("reply"), "c\n\nab");
|
2013-07-04 13:35:15 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("prependText", assert => {
|
2016-05-03 05:07:57 -04:00
|
|
|
const composer = createComposer();
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.blank(composer.get("reply"), "the reply is blank by default");
|
2016-05-03 05:07:57 -04:00
|
|
|
|
|
|
|
composer.prependText("hello");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("reply"), "hello", "it prepends text to nothing");
|
2016-05-03 05:07:57 -04:00
|
|
|
|
|
|
|
composer.prependText("world ");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("reply"),
|
|
|
|
"world hello",
|
|
|
|
"it prepends text to existing text"
|
|
|
|
);
|
2018-06-15 11:03:24 -04:00
|
|
|
|
2016-05-03 05:07:57 -04:00
|
|
|
composer.prependText("before new line", { new_line: true });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("reply"),
|
|
|
|
"before new line\n\nworld hello",
|
|
|
|
"it prepends text with new line to existing text"
|
|
|
|
);
|
2016-05-03 05:07:57 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Title length for regular topics", assert => {
|
2013-07-05 11:53:09 -04:00
|
|
|
Discourse.SiteSettings.min_topic_title_length = 5;
|
|
|
|
Discourse.SiteSettings.max_topic_title_length = 10;
|
2015-04-01 14:18:46 -04:00
|
|
|
const composer = createComposer();
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "asdf");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("titleLengthValid"), "short titles are not valid");
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "this is a long title");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("titleLengthValid"), "long titles are not valid");
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "just right");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("titleLengthValid"), "in the range is okay");
|
2013-07-05 11:53:09 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Title length for private messages", assert => {
|
2018-01-31 00:56:00 -05:00
|
|
|
Discourse.SiteSettings.min_personal_message_title_length = 5;
|
2013-07-05 11:53:09 -04:00
|
|
|
Discourse.SiteSettings.max_topic_title_length = 10;
|
2015-09-03 16:55:55 -04:00
|
|
|
const composer = createComposer({ action: Composer.PRIVATE_MESSAGE });
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "asdf");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("titleLengthValid"), "short titles are not valid");
|
2013-07-04 13:35:15 -04:00
|
|
|
|
2013-07-05 11:53:09 -04:00
|
|
|
composer.set("title", "this is a long title");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("titleLengthValid"), "long titles are not valid");
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "just right");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("titleLengthValid"), "in the range is okay");
|
2013-07-05 11:53:09 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Title length for private messages", assert => {
|
2018-01-31 00:56:00 -05:00
|
|
|
Discourse.SiteSettings.min_personal_message_title_length = 5;
|
2013-07-05 11:53:09 -04:00
|
|
|
Discourse.SiteSettings.max_topic_title_length = 10;
|
2015-09-03 16:55:55 -04:00
|
|
|
const composer = createComposer({ action: Composer.PRIVATE_MESSAGE });
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "asdf");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("titleLengthValid"), "short titles are not valid");
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "this is a long title");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("titleLengthValid"), "long titles are not valid");
|
2013-07-05 11:53:09 -04:00
|
|
|
|
|
|
|
composer.set("title", "just right");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("titleLengthValid"), "in the range is okay");
|
2013-07-05 11:53:09 -04:00
|
|
|
});
|
2013-07-04 13:35:15 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Post length for private messages with non human users", assert => {
|
2017-04-26 23:53:53 -04:00
|
|
|
const composer = createComposer({
|
2019-10-29 15:23:50 -04:00
|
|
|
topic: EmberObject.create({ pm_with_non_human_user: true })
|
2017-04-26 23:53:53 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(composer.get("minimumPostLength"), 1);
|
2017-04-26 23:53:53 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("editingFirstPost", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const composer = createComposer();
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("editingFirstPost"), "it's false by default");
|
2018-06-15 11:03:24 -04:00
|
|
|
|
2019-11-08 13:13:13 -05:00
|
|
|
const post = Post.create({ id: 123, post_number: 2 });
|
2015-09-03 16:55:55 -04:00
|
|
|
composer.setProperties({ post: post, action: Composer.EDIT });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(
|
|
|
|
!composer.get("editingFirstPost"),
|
|
|
|
"it's false when not editing the first post"
|
|
|
|
);
|
2018-06-15 11:03:24 -04:00
|
|
|
|
2013-07-05 11:53:09 -04:00
|
|
|
post.set("post_number", 1);
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(
|
|
|
|
composer.get("editingFirstPost"),
|
|
|
|
"it's true when editing the first post"
|
|
|
|
);
|
2013-07-05 11:53:09 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("clearState", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const composer = createComposer({
|
2013-07-05 13:01:51 -04:00
|
|
|
originalText: "asdf",
|
|
|
|
reply: "asdf2",
|
2019-11-08 13:13:13 -05:00
|
|
|
post: Post.create({ id: 1 }),
|
2013-07-05 13:01:51 -04:00
|
|
|
title: "wat"
|
|
|
|
});
|
|
|
|
|
|
|
|
composer.clearState();
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.blank(composer.get("originalText"));
|
|
|
|
assert.blank(composer.get("reply"));
|
|
|
|
assert.blank(composer.get("post"));
|
|
|
|
assert.blank(composer.get("title"));
|
2013-07-05 13:01:51 -04:00
|
|
|
});
|
2013-08-21 16:14:04 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("initial category when uncategorized is allowed", assert => {
|
2013-08-21 16:14:04 -04:00
|
|
|
Discourse.SiteSettings.allow_uncategorized_topics = true;
|
2015-09-03 16:55:55 -04:00
|
|
|
const composer = openComposer({
|
|
|
|
action: "createTopic",
|
|
|
|
draftKey: "asfd",
|
|
|
|
draftSequence: 1
|
|
|
|
});
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!composer.get("categoryId"), "Uncategorized by default");
|
2013-08-21 16:14:04 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("initial category when uncategorized is not allowed", assert => {
|
2013-08-21 16:14:04 -04:00
|
|
|
Discourse.SiteSettings.allow_uncategorized_topics = false;
|
2015-09-03 16:55:55 -04:00
|
|
|
const composer = openComposer({
|
|
|
|
action: "createTopic",
|
|
|
|
draftKey: "asfd",
|
|
|
|
draftSequence: 1
|
|
|
|
});
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(
|
|
|
|
!composer.get("categoryId"),
|
|
|
|
"Uncategorized by default. Must choose a category."
|
|
|
|
);
|
2013-10-17 12:19:09 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("open with a quote", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
const quote =
|
|
|
|
'[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]';
|
|
|
|
const newComposer = function() {
|
2015-11-20 20:27:06 -05:00
|
|
|
return openComposer({
|
|
|
|
action: Composer.REPLY,
|
|
|
|
draftKey: "asfd",
|
|
|
|
draftSequence: 1,
|
|
|
|
quote: quote
|
|
|
|
});
|
2013-11-15 13:13:42 -05:00
|
|
|
};
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
newComposer().get("originalText"),
|
|
|
|
quote,
|
|
|
|
"originalText is the quote"
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
newComposer().get("replyDirty"),
|
|
|
|
false,
|
|
|
|
"replyDirty is initally false with a quote"
|
|
|
|
);
|
2014-07-28 16:40:06 -04:00
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("Title length for static page topics as admin", assert => {
|
2015-04-01 14:18:46 -04:00
|
|
|
Discourse.SiteSettings.min_topic_title_length = 5;
|
|
|
|
Discourse.SiteSettings.max_topic_title_length = 10;
|
|
|
|
const composer = createComposer();
|
2014-07-28 16:40:06 -04:00
|
|
|
|
2019-11-08 13:13:13 -05:00
|
|
|
const post = Post.create({
|
2015-04-01 14:18:46 -04:00
|
|
|
id: 123,
|
|
|
|
post_number: 2,
|
|
|
|
static_doc: true
|
|
|
|
});
|
2015-09-03 16:55:55 -04:00
|
|
|
composer.setProperties({ post: post, action: Composer.EDIT });
|
2014-08-01 14:53:35 -04:00
|
|
|
|
2014-07-28 16:40:06 -04:00
|
|
|
composer.set("title", "asdf");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("titleLengthValid"), "admins can use short titles");
|
2014-07-28 16:40:06 -04:00
|
|
|
|
|
|
|
composer.set("title", "this is a long title");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("titleLengthValid"), "admins can use long titles");
|
2014-07-28 16:40:06 -04:00
|
|
|
|
|
|
|
composer.set("title", "just right");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(composer.get("titleLengthValid"), "in the range is okay");
|
2014-07-28 16:40:06 -04:00
|
|
|
|
|
|
|
composer.set("title", "");
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(
|
|
|
|
!composer.get("titleLengthValid"),
|
|
|
|
"admins must set title to at least 1 character"
|
|
|
|
);
|
2014-07-30 18:56:01 -04:00
|
|
|
});
|
2016-12-08 16:08:44 -05:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("title placeholder depends on what you're doing", assert => {
|
2016-12-08 16:08:44 -05:00
|
|
|
let composer = createComposer({ action: Composer.CREATE_TOPIC });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("titlePlaceholder"),
|
|
|
|
"composer.title_placeholder",
|
|
|
|
"placeholder for normal topic"
|
|
|
|
);
|
2018-06-15 11:03:24 -04:00
|
|
|
|
2016-12-08 16:08:44 -05:00
|
|
|
composer = createComposer({ action: Composer.PRIVATE_MESSAGE });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("titlePlaceholder"),
|
|
|
|
"composer.title_placeholder",
|
|
|
|
"placeholder for private message"
|
|
|
|
);
|
2016-12-08 16:08:44 -05:00
|
|
|
|
|
|
|
Discourse.SiteSettings.topic_featured_link_enabled = true;
|
|
|
|
|
|
|
|
composer = createComposer({ action: Composer.CREATE_TOPIC });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("titlePlaceholder"),
|
|
|
|
"composer.title_or_link_placeholder",
|
|
|
|
"placeholder invites you to paste a link"
|
|
|
|
);
|
2018-06-15 11:03:24 -04:00
|
|
|
|
2016-12-08 16:08:44 -05:00
|
|
|
composer = createComposer({ action: Composer.PRIVATE_MESSAGE });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("titlePlaceholder"),
|
|
|
|
"composer.title_placeholder",
|
|
|
|
"placeholder for private message with topic links enabled"
|
|
|
|
);
|
2016-12-08 16:08:44 -05:00
|
|
|
});
|
2016-12-21 13:39:41 -05:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("allows featured link before choosing a category", assert => {
|
2016-12-21 13:39:41 -05:00
|
|
|
Discourse.SiteSettings.topic_featured_link_enabled = true;
|
|
|
|
Discourse.SiteSettings.allow_uncategorized_topics = false;
|
|
|
|
let composer = createComposer({ action: Composer.CREATE_TOPIC });
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(
|
|
|
|
composer.get("titlePlaceholder"),
|
|
|
|
"composer.title_or_link_placeholder",
|
|
|
|
"placeholder invites you to paste a link"
|
|
|
|
);
|
|
|
|
assert.ok(composer.get("canEditTopicFeaturedLink"), "can paste link");
|
|
|
|
});
|
2020-01-07 08:33:48 -05:00
|
|
|
|
|
|
|
QUnit.test("targetRecipientsArray contains types", assert => {
|
|
|
|
let composer = createComposer({
|
|
|
|
targetRecipients: "test,codinghorror,staff,foo@bar.com"
|
|
|
|
});
|
|
|
|
assert.ok(composer.targetRecipientsArray, [
|
|
|
|
{ type: "group", name: "test" },
|
|
|
|
{ type: "user", name: "codinghorror" },
|
|
|
|
{ type: "group", name: "staff" },
|
|
|
|
{ type: "email", name: "foo@bar.com" }
|
|
|
|
]);
|
|
|
|
});
|