mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:02:20 +08:00
Remove Discourse.SiteSettings
from tests (#10193)
* Remove unused Discourse.SiteSettings * Remove `Discourse.SiteSettings` from many tests * REFACTOR: `lib:formatter` was using a lot of leaky state * Remove more `Discourse.SiteSettings` from tests * More SiteSettings removed from tests
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import EmberObject from "@ember/object";
|
||||
import { currentUser } from "helpers/qunit-helpers";
|
||||
import { discourseModule, currentUser } from "helpers/qunit-helpers";
|
||||
import AppEvents from "discourse/services/app-events";
|
||||
import Composer from "discourse/models/composer";
|
||||
import Post from "discourse/models/post";
|
||||
import createStore from "helpers/create-store";
|
||||
|
||||
QUnit.module("model:composer");
|
||||
discourseModule("model:composer");
|
||||
|
||||
function createComposer(opts) {
|
||||
opts = opts || {};
|
||||
@ -41,8 +41,8 @@ QUnit.test("replyLength", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("missingReplyCharacters", assert => {
|
||||
Discourse.SiteSettings.min_first_post_length = 40;
|
||||
QUnit.test("missingReplyCharacters", function(assert) {
|
||||
this.siteSettings.min_first_post_length = 40;
|
||||
const missingReplyCharacters = function(
|
||||
val,
|
||||
isPM,
|
||||
@ -62,21 +62,21 @@ QUnit.test("missingReplyCharacters", assert => {
|
||||
"hi",
|
||||
false,
|
||||
false,
|
||||
Discourse.SiteSettings.min_post_length - 2,
|
||||
this.siteSettings.min_post_length - 2,
|
||||
"too short public post"
|
||||
);
|
||||
missingReplyCharacters(
|
||||
"hi",
|
||||
false,
|
||||
true,
|
||||
Discourse.SiteSettings.min_first_post_length - 2,
|
||||
this.siteSettings.min_first_post_length - 2,
|
||||
"too short first post"
|
||||
);
|
||||
missingReplyCharacters(
|
||||
"hi",
|
||||
true,
|
||||
false,
|
||||
Discourse.SiteSettings.min_personal_message_post_length - 2,
|
||||
this.siteSettings.min_personal_message_post_length - 2,
|
||||
"too short private message"
|
||||
);
|
||||
|
||||
@ -95,7 +95,7 @@ QUnit.test("missingReplyCharacters", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("missingTitleCharacters", assert => {
|
||||
QUnit.test("missingTitleCharacters", function(assert) {
|
||||
const missingTitleCharacters = function(val, isPM, expected, message) {
|
||||
const composer = createComposer({
|
||||
title: val,
|
||||
@ -107,13 +107,13 @@ QUnit.test("missingTitleCharacters", assert => {
|
||||
missingTitleCharacters(
|
||||
"hi",
|
||||
false,
|
||||
Discourse.SiteSettings.min_topic_title_length - 2,
|
||||
this.siteSettings.min_topic_title_length - 2,
|
||||
"too short post title"
|
||||
);
|
||||
missingTitleCharacters(
|
||||
"z",
|
||||
true,
|
||||
Discourse.SiteSettings.min_personal_message_title_length - 1,
|
||||
this.siteSettings.min_personal_message_title_length - 1,
|
||||
"too short pm title"
|
||||
);
|
||||
});
|
||||
@ -191,9 +191,9 @@ QUnit.test("prependText", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Title length for regular topics", assert => {
|
||||
Discourse.SiteSettings.min_topic_title_length = 5;
|
||||
Discourse.SiteSettings.max_topic_title_length = 10;
|
||||
QUnit.test("Title length for regular topics", function(assert) {
|
||||
this.siteSettings.min_topic_title_length = 5;
|
||||
this.siteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer();
|
||||
|
||||
composer.set("title", "asdf");
|
||||
@ -206,24 +206,9 @@ QUnit.test("Title length for regular topics", assert => {
|
||||
assert.ok(composer.get("titleLengthValid"), "in the range is okay");
|
||||
});
|
||||
|
||||
QUnit.test("Title length for private messages", assert => {
|
||||
Discourse.SiteSettings.min_personal_message_title_length = 5;
|
||||
Discourse.SiteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer({ action: Composer.PRIVATE_MESSAGE });
|
||||
|
||||
composer.set("title", "asdf");
|
||||
assert.ok(!composer.get("titleLengthValid"), "short titles are not valid");
|
||||
|
||||
composer.set("title", "this is a long title");
|
||||
assert.ok(!composer.get("titleLengthValid"), "long titles are not valid");
|
||||
|
||||
composer.set("title", "just right");
|
||||
assert.ok(composer.get("titleLengthValid"), "in the range is okay");
|
||||
});
|
||||
|
||||
QUnit.test("Title length for private messages", assert => {
|
||||
Discourse.SiteSettings.min_personal_message_title_length = 5;
|
||||
Discourse.SiteSettings.max_topic_title_length = 10;
|
||||
QUnit.test("Title length for private messages", function(assert) {
|
||||
this.siteSettings.min_personal_message_title_length = 5;
|
||||
this.siteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer({ action: Composer.PRIVATE_MESSAGE });
|
||||
|
||||
composer.set("title", "asdf");
|
||||
@ -278,8 +263,8 @@ QUnit.test("clearState", assert => {
|
||||
assert.blank(composer.get("title"));
|
||||
});
|
||||
|
||||
QUnit.test("initial category when uncategorized is allowed", assert => {
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = true;
|
||||
QUnit.test("initial category when uncategorized is allowed", function(assert) {
|
||||
this.siteSettings.allow_uncategorized_topics = true;
|
||||
const composer = openComposer({
|
||||
action: "createTopic",
|
||||
draftKey: "asfd",
|
||||
@ -288,8 +273,10 @@ QUnit.test("initial category when uncategorized is allowed", assert => {
|
||||
assert.ok(!composer.get("categoryId"), "Uncategorized by default");
|
||||
});
|
||||
|
||||
QUnit.test("initial category when uncategorized is not allowed", assert => {
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = false;
|
||||
QUnit.test("initial category when uncategorized is not allowed", function(
|
||||
assert
|
||||
) {
|
||||
this.siteSettings.allow_uncategorized_topics = false;
|
||||
const composer = openComposer({
|
||||
action: "createTopic",
|
||||
draftKey: "asfd",
|
||||
@ -325,9 +312,9 @@ QUnit.test("open with a quote", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Title length for static page topics as admin", assert => {
|
||||
Discourse.SiteSettings.min_topic_title_length = 5;
|
||||
Discourse.SiteSettings.max_topic_title_length = 10;
|
||||
QUnit.test("Title length for static page topics as admin", function(assert) {
|
||||
this.siteSettings.min_topic_title_length = 5;
|
||||
this.siteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer();
|
||||
|
||||
const post = Post.create({
|
||||
@ -353,7 +340,7 @@ QUnit.test("Title length for static page topics as admin", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("title placeholder depends on what you're doing", assert => {
|
||||
QUnit.test("title placeholder depends on what you're doing", function(assert) {
|
||||
let composer = createComposer({ action: Composer.CREATE_TOPIC });
|
||||
assert.equal(
|
||||
composer.get("titlePlaceholder"),
|
||||
@ -368,7 +355,7 @@ QUnit.test("title placeholder depends on what you're doing", assert => {
|
||||
"placeholder for private message"
|
||||
);
|
||||
|
||||
Discourse.SiteSettings.topic_featured_link_enabled = true;
|
||||
this.siteSettings.topic_featured_link_enabled = true;
|
||||
|
||||
composer = createComposer({ action: Composer.CREATE_TOPIC });
|
||||
assert.equal(
|
||||
@ -385,9 +372,9 @@ QUnit.test("title placeholder depends on what you're doing", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("allows featured link before choosing a category", assert => {
|
||||
Discourse.SiteSettings.topic_featured_link_enabled = true;
|
||||
Discourse.SiteSettings.allow_uncategorized_topics = false;
|
||||
QUnit.test("allows featured link before choosing a category", function(assert) {
|
||||
this.siteSettings.topic_featured_link_enabled = true;
|
||||
this.siteSettings.allow_uncategorized_topics = false;
|
||||
let composer = createComposer({ action: Composer.CREATE_TOPIC });
|
||||
assert.equal(
|
||||
composer.get("titlePlaceholder"),
|
||||
|
Reference in New Issue
Block a user