mirror of
https://github.com/discourse/discourse.git
synced 2025-02-28 08:19:13 +00:00
DEV: Use getOwner
from @ember/application
in tests (#23670)
This commit is contained in:
parent
3669723a86
commit
52722c7086
@ -12,7 +12,7 @@ import {
|
|||||||
getCachedTopicList,
|
getCachedTopicList,
|
||||||
setCachedTopicList,
|
setCachedTopicList,
|
||||||
} from "discourse/lib/cached-topic-list";
|
} from "discourse/lib/cached-topic-list";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
acceptance("Personal Message", function (needs) {
|
acceptance("Personal Message", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
@ -27,7 +27,7 @@ acceptance("Personal Message", function (needs) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("redirects to inbox after topic is archived and clears topicList cache", async function (assert) {
|
test("redirects to inbox after topic is archived and clears topicList cache", async function (assert) {
|
||||||
const session = getOwnerWithFallback(this).lookup("service:session");
|
const session = getOwner(this).lookup("service:session");
|
||||||
setCachedTopicList(session, {});
|
setCachedTopicList(session, {});
|
||||||
|
|
||||||
await visit("/t/pm-for-testing/12");
|
await visit("/t/pm-for-testing/12");
|
||||||
|
@ -116,7 +116,7 @@ export function updateCurrentUser(properties) {
|
|||||||
|
|
||||||
// Note: do not use this in acceptance tests. Use `loggedIn: true` instead
|
// Note: do not use this in acceptance tests. Use `loggedIn: true` instead
|
||||||
export function logIn() {
|
export function logIn() {
|
||||||
User.resetCurrent(currentUser());
|
return User.resetCurrent(currentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Only use if `loggedIn: true` has been used in an acceptance test
|
// Note: Only use if `loggedIn: true` has been used in an acceptance test
|
||||||
|
@ -3,13 +3,13 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Integration | Component | pending-post", function (hooks) {
|
module("Integration | Component | pending-post", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("it renders", async function (assert) {
|
test("it renders", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
store.createRecord("category", { id: 2 });
|
store.createRecord("category", { id: 2 });
|
||||||
const post = store.createRecord("pending-post", {
|
const post = store.createRecord("pending-post", {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -6,7 +6,7 @@ import { action } from "@ember/object";
|
|||||||
import { extraConnectorClass } from "discourse/lib/plugin-connectors";
|
import { extraConnectorClass } from "discourse/lib/plugin-connectors";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import templateOnly from "@ember/component/template-only";
|
import templateOnly from "@ember/component/template-only";
|
||||||
import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated";
|
import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated";
|
||||||
@ -256,9 +256,7 @@ module("Integration | Component | plugin-outlet", function (hooks) {
|
|||||||
"doesn't render conditional outlet"
|
"doesn't render conditional outlet"
|
||||||
);
|
);
|
||||||
|
|
||||||
getOwnerWithFallback(this).lookup(
|
getOwner(this).lookup("service:site-settings").always_display = true;
|
||||||
"service:site-settings"
|
|
||||||
).always_display = true;
|
|
||||||
await settled();
|
await settled();
|
||||||
assert.true(exists(".conditional-render"), "renders conditional outlet");
|
assert.true(exists(".conditional-render"), "renders conditional outlet");
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ import { render } from "@ember/test-helpers";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module(
|
module(
|
||||||
"Integration | Component | select-kit/category-chooser",
|
"Integration | Component | select-kit/category-chooser",
|
||||||
@ -267,7 +267,7 @@ module(
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("filter works with non english characters", async function (assert) {
|
test("filter works with non english characters", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
store.createRecord("category", {
|
store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "chữ Quốc ngữ",
|
name: "chữ Quốc ngữ",
|
||||||
@ -287,7 +287,7 @@ module(
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("decodes entities in row title", async function (assert) {
|
test("decodes entities in row title", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
store.createRecord("category", {
|
store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "cat-with-entities",
|
name: "cat-with-entities",
|
||||||
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
@ -12,7 +12,7 @@ module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
|||||||
this.siteSettings.automatically_unpin_topics = false;
|
this.siteSettings.automatically_unpin_topics = false;
|
||||||
this.set("subject", selectKit());
|
this.set("subject", selectKit());
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set(
|
this.set(
|
||||||
"topic",
|
"topic",
|
||||||
store.createRecord("topic", {
|
store.createRecord("topic", {
|
||||||
@ -38,7 +38,7 @@ module("Integration | Component | select-kit/pinned-options", function (hooks) {
|
|||||||
test("pinning", async function (assert) {
|
test("pinning", async function (assert) {
|
||||||
this.siteSettings.automatically_unpin_topics = false;
|
this.siteSettings.automatically_unpin_topics = false;
|
||||||
this.set("subject", selectKit());
|
this.set("subject", selectKit());
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set(
|
this.set(
|
||||||
"topic",
|
"topic",
|
||||||
store.createRecord("topic", {
|
store.createRecord("topic", {
|
||||||
|
@ -5,7 +5,7 @@ import I18n from "I18n";
|
|||||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function buildTopic(opts) {
|
function buildTopic(opts) {
|
||||||
return this.store.createRecord("topic", {
|
return this.store.createRecord("topic", {
|
||||||
@ -30,7 +30,7 @@ module(
|
|||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
this.store = getOwner(this).lookup("service:store");
|
||||||
});
|
});
|
||||||
|
|
||||||
hooks.afterEach(function () {
|
hooks.afterEach(function () {
|
||||||
|
@ -4,7 +4,7 @@ import { render } from "@ember/test-helpers";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function extractDescriptions(rows) {
|
function extractDescriptions(rows) {
|
||||||
return [...rows].map((el) => el.querySelector(".desc").textContent.trim());
|
return [...rows].map((el) => el.querySelector(".desc").textContent.trim());
|
||||||
@ -22,7 +22,7 @@ module(
|
|||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("regular topic notification level descriptions", async function (assert) {
|
test("regular topic notification level descriptions", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set(
|
this.set(
|
||||||
"topic",
|
"topic",
|
||||||
store.createRecord("topic", {
|
store.createRecord("topic", {
|
||||||
@ -63,7 +63,7 @@ module(
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("PM topic notification level descriptions", async function (assert) {
|
test("PM topic notification level descriptions", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set(
|
this.set(
|
||||||
"topic",
|
"topic",
|
||||||
store.createRecord("topic", {
|
store.createRecord("topic", {
|
||||||
|
@ -3,13 +3,13 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Integration | Component | topic-list-item", function (hooks) {
|
module("Integration | Component | topic-list-item", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("checkbox is rendered checked if topic is in selected array", async function (assert) {
|
test("checkbox is rendered checked if topic is in selected array", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", { id: 24234 });
|
const topic = store.createRecord("topic", { id: 24234 });
|
||||||
const topic2 = store.createRecord("topic", { id: 24235 });
|
const topic2 = store.createRecord("topic", { id: 24235 });
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
|
@ -2,13 +2,13 @@ import { module, test } from "qunit";
|
|||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Integration | Component | topic-list", function (hooks) {
|
module("Integration | Component | topic-list", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("bulk select", async function (assert) {
|
test("bulk select", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
topics: [
|
topics: [
|
||||||
store.createRecord("topic", { id: 24234 }),
|
store.createRecord("topic", { id: 24234 }),
|
||||||
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { count } from "discourse/tests/helpers/qunit-helpers";
|
import { count } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function postStreamTest(name, attrs) {
|
function postStreamTest(name, attrs) {
|
||||||
test(name, async function (assert) {
|
test(name, async function (assert) {
|
||||||
@ -22,8 +22,8 @@ module("Integration | Component | Widget | post-stream", function (hooks) {
|
|||||||
|
|
||||||
postStreamTest("basics", {
|
postStreamTest("basics", {
|
||||||
posts() {
|
posts() {
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic");
|
const topic = store.createRecord("topic");
|
||||||
topic.set("details.created_by", { id: 123 });
|
topic.set("details.created_by", { id: 123 });
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ module("Integration | Component | Widget | post-stream", function (hooks) {
|
|||||||
|
|
||||||
postStreamTest("deleted posts", {
|
postStreamTest("deleted posts", {
|
||||||
posts() {
|
posts() {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic");
|
const topic = store.createRecord("topic");
|
||||||
topic.set("details.created_by", { id: 123 });
|
topic.set("details.created_by", { id: 123 });
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Integration | Component | Widget | post", function (hooks) {
|
module("Integration | Component | Widget | post", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
@ -162,7 +162,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("like count button", async function (assert) {
|
test("like count button", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", { id: 123 });
|
const topic = store.createRecord("topic", { id: 123 });
|
||||||
const post = store.createRecord("post", {
|
const post = store.createRecord("post", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -517,7 +517,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("expand first post", async function (assert) {
|
test("expand first post", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set("args", { expandablePost: true });
|
this.set("args", { expandablePost: true });
|
||||||
this.set("post", store.createRecord("post", { id: 1234 }));
|
this.set("post", store.createRecord("post", { id: 1234 }));
|
||||||
|
|
||||||
@ -961,7 +961,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
|||||||
emoji: "tooth",
|
emoji: "tooth",
|
||||||
description: "off to dentist",
|
description: "off to dentist",
|
||||||
};
|
};
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { status });
|
const user = store.createRecord("user", { status });
|
||||||
this.set("args", { user });
|
this.set("args", { user });
|
||||||
|
|
||||||
@ -976,7 +976,7 @@ module("Integration | Component | Widget | post", function (hooks) {
|
|||||||
emoji: "tooth",
|
emoji: "tooth",
|
||||||
description: "off to dentist",
|
description: "off to dentist",
|
||||||
};
|
};
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { status });
|
const user = store.createRecord("user", { status });
|
||||||
this.set("args", { user });
|
this.set("args", { user });
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { render } from "@ember/test-helpers";
|
|||||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
const createArgs = (topic) => {
|
const createArgs = (topic) => {
|
||||||
return {
|
return {
|
||||||
@ -37,7 +37,7 @@ module(
|
|||||||
id: 123,
|
id: 123,
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", {
|
const topic = store.createRecord("topic", {
|
||||||
user_id: this.currentUser.id,
|
user_id: this.currentUser.id,
|
||||||
});
|
});
|
||||||
@ -60,7 +60,7 @@ module(
|
|||||||
id: 123,
|
id: 123,
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", {
|
const topic = store.createRecord("topic", {
|
||||||
user_id: this.currentUser.id,
|
user_id: this.currentUser.id,
|
||||||
});
|
});
|
||||||
|
@ -4,13 +4,13 @@ import { click, render } from "@ember/test-helpers";
|
|||||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
|
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Integration | Component | Widget | topic-status", function (hooks) {
|
module("Integration | Component | Widget | topic-status", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("basics", async function (assert) {
|
test("basics", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set("args", {
|
this.set("args", {
|
||||||
topic: store.createRecord("topic", { closed: true }),
|
topic: store.createRecord("topic", { closed: true }),
|
||||||
disableActions: true,
|
disableActions: true,
|
||||||
@ -24,7 +24,7 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("extendability", async function (assert) {
|
test("extendability", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
TopicStatusIcons.addObject([
|
TopicStatusIcons.addObject([
|
||||||
"has_accepted_answer",
|
"has_accepted_answer",
|
||||||
"far-check-square",
|
"far-check-square",
|
||||||
@ -45,7 +45,7 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("toggling pin status", async function (assert) {
|
test("toggling pin status", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set("args", {
|
this.set("args", {
|
||||||
topic: store.createRecord("topic", { closed: true, pinned: true }),
|
topic: store.createRecord("topic", { closed: true, pinned: true }),
|
||||||
});
|
});
|
||||||
|
@ -13,10 +13,8 @@ import pretender, {
|
|||||||
resetPretender,
|
resetPretender,
|
||||||
} from "discourse/tests/helpers/create-pretender";
|
} from "discourse/tests/helpers/create-pretender";
|
||||||
import { resetSettings } from "discourse/tests/helpers/site-settings";
|
import { resetSettings } from "discourse/tests/helpers/site-settings";
|
||||||
import {
|
import { getOwner } from "@ember/application";
|
||||||
getOwnerWithFallback,
|
import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
||||||
setDefaultOwner,
|
|
||||||
} from "discourse-common/lib/get-owner";
|
|
||||||
import {
|
import {
|
||||||
getSettledState,
|
getSettledState,
|
||||||
isSettled,
|
isSettled,
|
||||||
@ -343,7 +341,7 @@ export default function setupTests(config) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.testDone(function () {
|
QUnit.testDone(function () {
|
||||||
testCleanup(getOwnerWithFallback(app), app);
|
testCleanup(getOwner(app), app);
|
||||||
|
|
||||||
sinon.restore();
|
sinon.restore();
|
||||||
resetPretender();
|
resetPretender();
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Controller | reorder-categories", function (hooks) {
|
module("Unit | Controller | reorder-categories", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("reorder set unique position number", function (assert) {
|
test("reorder set unique position number", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup(
|
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||||
"controller:reorder-categories"
|
const store = getOwner(this).lookup("service:store");
|
||||||
);
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
|
||||||
|
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("categories", [
|
site.set("categories", [
|
||||||
store.createRecord("category", { id: 1, position: 0 }),
|
store.createRecord("category", { id: 1, position: 0 }),
|
||||||
store.createRecord("category", { id: 2, position: 0 }),
|
store.createRecord("category", { id: 2, position: 0 }),
|
||||||
@ -26,10 +24,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("reorder places subcategories after their parent categories, while maintaining the relative order", function (assert) {
|
test("reorder places subcategories after their parent categories, while maintaining the relative order", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup(
|
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||||
"controller:reorder-categories"
|
const store = getOwner(this).lookup("service:store");
|
||||||
);
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
|
||||||
|
|
||||||
const parent = store.createRecord("category", {
|
const parent = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -55,7 +51,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
|
const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("categories", [child2, parent, other, child1]);
|
site.set("categories", [child2, parent, other, child1]);
|
||||||
|
|
||||||
controller.reorder();
|
controller.reorder();
|
||||||
@ -67,10 +63,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("changing the position number of a category should place it at given position", function (assert) {
|
test("changing the position number of a category should place it at given position", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup(
|
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||||
"controller:reorder-categories"
|
const store = getOwner(this).lookup("service:store");
|
||||||
);
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
|
||||||
|
|
||||||
const elem1 = store.createRecord("category", {
|
const elem1 = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -90,7 +84,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
slug: "test",
|
slug: "test",
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("categories", [elem1, elem2, elem3]);
|
site.set("categories", [elem1, elem2, elem3]);
|
||||||
|
|
||||||
// Move category 'foo' from position 0 to position 2
|
// Move category 'foo' from position 0 to position 2
|
||||||
@ -104,10 +98,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("changing the position number of a category should place it at given position and respect children", function (assert) {
|
test("changing the position number of a category should place it at given position and respect children", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup(
|
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||||
"controller:reorder-categories"
|
const store = getOwner(this).lookup("service:store");
|
||||||
);
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
|
||||||
|
|
||||||
const elem1 = store.createRecord("category", {
|
const elem1 = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -134,7 +126,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
slug: "test",
|
slug: "test",
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("categories", [elem1, child1, elem2, elem3]);
|
site.set("categories", [elem1, child1, elem2, elem3]);
|
||||||
|
|
||||||
controller.send("change", elem1, { target: { value: 3 } });
|
controller.send("change", elem1, { target: { value: 3 } });
|
||||||
@ -148,10 +140,8 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("changing the position through click on arrow of a category should place it at given position and respect children", function (assert) {
|
test("changing the position through click on arrow of a category should place it at given position and respect children", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup(
|
const controller = getOwner(this).lookup("controller:reorder-categories");
|
||||||
"controller:reorder-categories"
|
const store = getOwner(this).lookup("service:store");
|
||||||
);
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
|
||||||
|
|
||||||
const child2 = store.createRecord("category", {
|
const child2 = store.createRecord("category", {
|
||||||
id: 105,
|
id: 105,
|
||||||
@ -187,7 +177,7 @@ module("Unit | Controller | reorder-categories", function (hooks) {
|
|||||||
slug: "test",
|
slug: "test",
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("categories", [elem1, child1, child2, elem2, elem3]);
|
site.set("categories", [elem1, child1, child2, elem2, elem3]);
|
||||||
|
|
||||||
controller.reorder();
|
controller.reorder();
|
||||||
|
@ -5,7 +5,7 @@ import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
|||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { Placeholder } from "discourse/lib/posts-with-placeholders";
|
import { Placeholder } from "discourse/lib/posts-with-placeholders";
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
function topicWithStream(streamDetails) {
|
function topicWithStream(streamDetails) {
|
||||||
@ -18,11 +18,11 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
this.store = getOwner(this).lookup("service:store");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("editTopic", function (assert) {
|
test("editTopic", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
const model = this.store.createRecord("topic");
|
const model = this.store.createRecord("topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
assert.notOk(controller.editingTopic, "we are not editing by default");
|
assert.notOk(controller.editingTopic, "we are not editing by default");
|
||||||
@ -59,12 +59,10 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
let modalDisplayed = false;
|
let modalDisplayed = false;
|
||||||
model.destroy = async () => (destroyed = true);
|
model.destroy = async () => (destroyed = true);
|
||||||
|
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
siteSettings.min_topic_views_for_delete_confirm = 5;
|
siteSettings.min_topic_views_for_delete_confirm = 5;
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({
|
controller.setProperties({
|
||||||
model,
|
model,
|
||||||
deleteTopicModal: () => (modalDisplayed = true),
|
deleteTopicModal: () => (modalDisplayed = true),
|
||||||
@ -103,7 +101,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
|
|
||||||
test("toggleMultiSelect", async function (assert) {
|
test("toggleMultiSelect", async function (assert) {
|
||||||
const model = this.store.createRecord("topic");
|
const model = this.store.createRecord("topic");
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
assert.notOk(
|
assert.notOk(
|
||||||
@ -148,7 +146,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
const model = topicWithStream.call(this, {
|
const model = topicWithStream.call(this, {
|
||||||
posts: [{ id: 1 }, { id: 2 }, { id: 3 }],
|
posts: [{ id: 1 }, { id: 2 }, { id: 3 }],
|
||||||
});
|
});
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
controller.set("selectedPostIds", [1, 2, 42]);
|
controller.set("selectedPostIds", [1, 2, 42]);
|
||||||
@ -166,7 +164,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
|
|
||||||
test("selectedAllPosts", function (assert) {
|
test("selectedAllPosts", function (assert) {
|
||||||
const model = topicWithStream.call(this, { stream: [1, 2, 3] });
|
const model = topicWithStream.call(this, { stream: [1, 2, 3] });
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
controller.set("selectedPostIds", [1, 2]);
|
controller.set("selectedPostIds", [1, 2]);
|
||||||
@ -200,7 +198,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
],
|
],
|
||||||
stream: [1, 2, 3],
|
stream: [1, 2, 3],
|
||||||
});
|
});
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
@ -240,12 +238,12 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
|
|
||||||
test("showSelectedPostsAtBottom", function (assert) {
|
test("showSelectedPostsAtBottom", function (assert) {
|
||||||
const model = this.store.createRecord("topic", { posts_count: 3 });
|
const model = this.store.createRecord("topic", { posts_count: 3 });
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
assert.notOk(controller.showSelectedPostsAtBottom, "false on desktop");
|
assert.notOk(controller.showSelectedPostsAtBottom, "false on desktop");
|
||||||
|
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("mobileView", true);
|
site.set("mobileView", true);
|
||||||
|
|
||||||
assert.notOk(
|
assert.notOk(
|
||||||
@ -271,7 +269,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
stream: [1, 2, 3],
|
stream: [1, 2, 3],
|
||||||
});
|
});
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({
|
controller.setProperties({
|
||||||
model,
|
model,
|
||||||
currentUser,
|
currentUser,
|
||||||
@ -318,7 +316,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
});
|
});
|
||||||
model.set("details.can_move_posts", false);
|
model.set("details.can_move_posts", false);
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
assert.notOk(
|
assert.notOk(
|
||||||
@ -364,7 +362,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
});
|
});
|
||||||
model.set("currentUser", currentUser);
|
model.set("currentUser", currentUser);
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model, currentUser });
|
controller.setProperties({ model, currentUser });
|
||||||
|
|
||||||
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
|
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
|
||||||
@ -396,12 +394,10 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
});
|
});
|
||||||
model.set("currentUser", currentUser);
|
model.set("currentUser", currentUser);
|
||||||
|
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
siteSettings.moderators_change_post_ownership = true;
|
siteSettings.moderators_change_post_ownership = true;
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model, currentUser });
|
controller.setProperties({ model, currentUser });
|
||||||
|
|
||||||
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
|
assert.notOk(controller.canChangeOwner, "false when no posts are selected");
|
||||||
@ -433,7 +429,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
stream: [1, 2, 3],
|
stream: [1, 2, 3],
|
||||||
});
|
});
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
assert.notOk(controller.canMergePosts, "false when no posts are selected");
|
assert.notOk(controller.canMergePosts, "false when no posts are selected");
|
||||||
@ -464,7 +460,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Select/deselect all", function (assert) {
|
test("Select/deselect all", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
const model = topicWithStream.call(this, { stream: [1, 2, 3] });
|
const model = topicWithStream.call(this, { stream: [1, 2, 3] });
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
@ -490,7 +486,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("togglePostSelection", function (assert) {
|
test("togglePostSelection", function (assert) {
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
controller.selectedPostIds[0],
|
controller.selectedPostIds[0],
|
||||||
@ -514,7 +510,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("selectBelow", function (assert) {
|
test("selectBelow", function (assert) {
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("post_types", { small_action: 3, whisper: 4 });
|
site.set("post_types", { small_action: 3, whisper: 4 });
|
||||||
|
|
||||||
const model = topicWithStream.call(this, {
|
const model = topicWithStream.call(this, {
|
||||||
@ -526,7 +522,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -548,7 +544,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
posts: [{ id: 1 }, { id: 2 }],
|
posts: [{ id: 1 }, { id: 2 }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
|
|
||||||
controller.send("selectReplies", { id: 1 });
|
controller.send("selectReplies", { id: 1 });
|
||||||
@ -586,7 +582,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
const model = topicWithStream.call(this, {
|
const model = topicWithStream.call(this, {
|
||||||
posts: [{ id: 1 }],
|
posts: [{ id: 1 }],
|
||||||
});
|
});
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model });
|
controller.setProperties({ model });
|
||||||
const placeholder = new Placeholder("post-placeholder");
|
const placeholder = new Placeholder("post-placeholder");
|
||||||
|
|
||||||
@ -617,7 +613,7 @@ module("Unit | Controller | topic", function (hooks) {
|
|||||||
posts: [post, { id: 3 }, { id: 4 }],
|
posts: [post, { id: 3 }, { id: 4 }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const controller = getOwnerWithFallback(this).lookup("controller:topic");
|
const controller = getOwner(this).lookup("controller:topic");
|
||||||
controller.setProperties({ model, currentUser });
|
controller.setProperties({ model, currentUser });
|
||||||
|
|
||||||
const done = assert.async();
|
const done = assert.async();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { buildQuote } from "discourse/lib/quote";
|
import { buildQuote } from "discourse/lib/quote";
|
||||||
import PrettyText from "pretty-text/pretty-text";
|
import PrettyText from "pretty-text/pretty-text";
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ module("Unit | Utility | build-quote", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("quotes", function (assert) {
|
test("quotes", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", {
|
const post = store.createRecord("post", {
|
||||||
cooked: "<p><b>lorem</b> ipsum</p>",
|
cooked: "<p><b>lorem</b> ipsum</p>",
|
||||||
username: "eviltrout",
|
username: "eviltrout",
|
||||||
@ -58,7 +58,7 @@ module("Unit | Utility | build-quote", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("quoting a quote", function (assert) {
|
test("quoting a quote", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", {
|
const post = store.createRecord("post", {
|
||||||
cooked: new PrettyText().cook(
|
cooked: new PrettyText().cook(
|
||||||
'[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]\n*Test*'
|
'[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]\n*Test*'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { helperContext } from "discourse-common/lib/helpers";
|
import { helperContext } from "discourse-common/lib/helpers";
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Regular categoryBadge", function (assert) {
|
test("Regular categoryBadge", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const category = store.createRecord("category", {
|
const category = store.createRecord("category", {
|
||||||
name: "hello",
|
name: "hello",
|
||||||
id: 123,
|
id: 123,
|
||||||
@ -43,7 +43,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("undefined color", function (assert) {
|
test("undefined color", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const noColor = store.createRecord("category", { name: "hello", id: 123 });
|
const noColor = store.createRecord("category", { name: "hello", id: 123 });
|
||||||
const tag = $.parseHTML(categoryBadgeHTML(noColor))[0];
|
const tag = $.parseHTML(categoryBadgeHTML(noColor))[0];
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("topic count", function (assert) {
|
test("topic count", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const category = store.createRecord("category", { name: "hello", id: 123 });
|
const category = store.createRecord("category", { name: "hello", id: 123 });
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
@ -69,7 +69,7 @@ module("Unit | Utility | category-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("allowUncategorized", function (assert) {
|
test("allowUncategorized", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const uncategorized = store.createRecord("category", {
|
const uncategorized = store.createRecord("category", {
|
||||||
name: "uncategorized",
|
name: "uncategorized",
|
||||||
id: 345,
|
id: 345,
|
||||||
@ -89,12 +89,10 @@ module("Unit | Utility | category-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("category names are wrapped in dir-spans", function (assert) {
|
test("category names are wrapped in dir-spans", function (assert) {
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
siteSettings.support_mixed_text_direction = true;
|
siteSettings.support_mixed_text_direction = true;
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const rtlCategory = store.createRecord("category", {
|
const rtlCategory = store.createRecord("category", {
|
||||||
name: "תכנות עם Ruby",
|
name: "תכנות עם Ruby",
|
||||||
id: 123,
|
id: 123,
|
||||||
@ -118,10 +116,8 @@ module("Unit | Utility | category-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("recursive", function (assert) {
|
test("recursive", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
|
|
||||||
const foo = store.createRecord("category", {
|
const foo = store.createRecord("category", {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -13,7 +13,7 @@ import { setPrefix } from "discourse-common/lib/get-url";
|
|||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Utility | computed", function (hooks) {
|
module("Unit | Utility | computed", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
@ -29,9 +29,7 @@ module("Unit | Utility | computed", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("setting", function (assert) {
|
test("setting", function (assert) {
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
|
|
||||||
let t = EmberObject.extend({
|
let t = EmberObject.extend({
|
||||||
siteSettings,
|
siteSettings,
|
||||||
|
@ -3,15 +3,13 @@ import { emojiUnescape } from "discourse/lib/text";
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Utility | emoji", function (hooks) {
|
module("Unit | Utility | emoji", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("emojiUnescape", function (assert) {
|
test("emojiUnescape", function (assert) {
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
|
|
||||||
const testUnescape = (input, expected, description, settings = {}) => {
|
const testUnescape = (input, expected, description, settings = {}) => {
|
||||||
const originalSettings = {};
|
const originalSettings = {};
|
||||||
|
@ -12,7 +12,7 @@ import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import domFromString from "discourse-common/lib/dom-from-string";
|
import domFromString from "discourse-common/lib/dom-from-string";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function formatMins(mins, opts = {}) {
|
function formatMins(mins, opts = {}) {
|
||||||
const dt = new Date(new Date() - mins * 60 * 1000);
|
const dt = new Date(new Date() - mins * 60 * 1000);
|
||||||
@ -150,9 +150,7 @@ module("Unit | Utility | formatter", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("formatting tiny dates", function (assert) {
|
test("formatting tiny dates", function (assert) {
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
|
|
||||||
const shortDateYear = shortDateTester("MMM 'YY");
|
const shortDateYear = shortDateTester("MMM 'YY");
|
||||||
siteSettings.relative_date_duration = 14;
|
siteSettings.relative_date_duration = 14;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import LinkLookup from "discourse/lib/link-lookup";
|
import LinkLookup from "discourse/lib/link-lookup";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Utility | link-lookup", function (hooks) {
|
module("Unit | Utility | link-lookup", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.post = store.createRecord("post");
|
this.post = store.createRecord("post");
|
||||||
this.linkLookup = new LinkLookup({
|
this.linkLookup = new LinkLookup({
|
||||||
"en.wikipedia.org/wiki/handheld_game_console": {
|
"en.wikipedia.org/wiki/handheld_game_console": {
|
||||||
|
@ -3,7 +3,7 @@ import EmberObject from "@ember/object";
|
|||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Utility | plugin-api", function (hooks) {
|
module("Unit | Utility | plugin-api", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
@ -16,7 +16,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
getOwnerWithFallback(this).register("test-thingy:main", TestThingy);
|
getOwner(this).register("test-thingy:main", TestThingy);
|
||||||
|
|
||||||
withPluginApi("1.1.0", (api) => {
|
withPluginApi("1.1.0", (api) => {
|
||||||
api.modifyClass("test-thingy:main", {
|
api.modifyClass("test-thingy:main", {
|
||||||
@ -29,7 +29,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const thingy = getOwnerWithFallback(this).lookup("test-thingy:main");
|
const thingy = getOwner(this).lookup("test-thingy:main");
|
||||||
assert.strictEqual(thingy.prop, "hello there");
|
assert.strictEqual(thingy.prop, "hello there");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,10 +41,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getOwnerWithFallback(this).register(
|
getOwner(this).register("native-test-thingy:main", NativeTestThingy);
|
||||||
"native-test-thingy:main",
|
|
||||||
NativeTestThingy
|
|
||||||
);
|
|
||||||
|
|
||||||
withPluginApi("1.1.0", (api) => {
|
withPluginApi("1.1.0", (api) => {
|
||||||
api.modifyClass("native-test-thingy:main", {
|
api.modifyClass("native-test-thingy:main", {
|
||||||
@ -57,7 +54,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const thingy = getOwnerWithFallback(this).lookup("native-test-thingy:main");
|
const thingy = getOwner(this).lookup("native-test-thingy:main");
|
||||||
assert.strictEqual(thingy.prop, "howdy partner");
|
assert.strictEqual(thingy.prop, "howdy partner");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,13 +69,9 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getOwnerWithFallback(this).register(
|
getOwner(this).register("class-test-thingy:main", new ClassTestThingy(), {
|
||||||
"class-test-thingy:main",
|
instantiate: false,
|
||||||
new ClassTestThingy(),
|
});
|
||||||
{
|
|
||||||
instantiate: false,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
withPluginApi("1.1.0", (api) => {
|
withPluginApi("1.1.0", (api) => {
|
||||||
api.modifyClass("class-test-thingy:main", {
|
api.modifyClass("class-test-thingy:main", {
|
||||||
@ -90,7 +83,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const thingy = getOwnerWithFallback(this).lookup("class-test-thingy:main");
|
const thingy = getOwner(this).lookup("class-test-thingy:main");
|
||||||
assert.strictEqual(thingy.keep, "hey!");
|
assert.strictEqual(thingy.keep, "hey!");
|
||||||
assert.strictEqual(thingy.prop, "g'day");
|
assert.strictEqual(thingy.prop, "g'day");
|
||||||
});
|
});
|
||||||
@ -102,7 +95,7 @@ module("Unit | Utility | plugin-api", function (hooks) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
getOwnerWithFallback(this).register("test-class:main", Base, {
|
getOwner(this).register("test-class:main", Base, {
|
||||||
instantiate: false,
|
instantiate: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,16 +12,14 @@ import I18n from "I18n";
|
|||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Utility | uploads", function (hooks) {
|
module("Unit | Utility | uploads", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.siteSettings = getOwnerWithFallback(this).lookup(
|
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
this.store = getOwner(this).lookup("service:store");
|
||||||
);
|
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("validateUploadedFiles", function (assert) {
|
test("validateUploadedFiles", function (assert) {
|
||||||
@ -349,9 +347,7 @@ module("Unit | Utility | uploads", function (hooks) {
|
|||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
|
||||||
const capabilities = getOwnerWithFallback(this).lookup(
|
const capabilities = getOwner(this).lookup("service:capabilities");
|
||||||
"service:capabilities"
|
|
||||||
);
|
|
||||||
sinon.stub(capabilities, "isIOS").get(() => true);
|
sinon.stub(capabilities, "isIOS").get(() => true);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
||||||
|
@ -23,7 +23,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Utilities", function (hooks) {
|
module("Unit | Utilities", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
@ -88,9 +88,7 @@ module("Unit | Utilities", function (hooks) {
|
|||||||
meta.content = "hot";
|
meta.content = "hot";
|
||||||
document.body.appendChild(meta);
|
document.body.appendChild(meta);
|
||||||
|
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
initializeDefaultHomepage(siteSettings);
|
initializeDefaultHomepage(siteSettings);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
@ -102,9 +100,7 @@ module("Unit | Utilities", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("defaultHomepage via site settings", function (assert) {
|
test("defaultHomepage via site settings", function (assert) {
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
siteSettings.top_menu = "top|latest|hot";
|
siteSettings.top_menu = "top|latest|hot";
|
||||||
initializeDefaultHomepage(siteSettings);
|
initializeDefaultHomepage(siteSettings);
|
||||||
|
|
||||||
@ -116,9 +112,7 @@ module("Unit | Utilities", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("setDefaultHomepage", function (assert) {
|
test("setDefaultHomepage", function (assert) {
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
initializeDefaultHomepage(siteSettings);
|
initializeDefaultHomepage(siteSettings);
|
||||||
|
|
||||||
assert.strictEqual(defaultHomepage(), "latest");
|
assert.strictEqual(defaultHomepage(), "latest");
|
||||||
|
@ -5,13 +5,13 @@ import pretender, {
|
|||||||
} from "discourse/tests/helpers/create-pretender";
|
} from "discourse/tests/helpers/create-pretender";
|
||||||
import Badge from "discourse/models/badge";
|
import Badge from "discourse/models/badge";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | badge", function (hooks) {
|
module("Unit | Model | badge", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("newBadge", function (assert) {
|
test("newBadge", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const badge1 = store.createRecord("badge", { name: "New Badge" });
|
const badge1 = store.createRecord("badge", { name: "New Badge" });
|
||||||
const badge2 = store.createRecord("badge", { id: 1, name: "Old Badge" });
|
const badge2 = store.createRecord("badge", { id: 1, name: "Old Badge" });
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ module("Unit | Model | badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("updateFromJson", function (assert) {
|
test("updateFromJson", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const badge = store.createRecord("badge", { name: "Badge 1" });
|
const badge = store.createRecord("badge", { name: "Badge 1" });
|
||||||
badge.updateFromJson({
|
badge.updateFromJson({
|
||||||
badge_types: [{ id: 6, name: "Silver 1" }],
|
badge_types: [{ id: 6, name: "Silver 1" }],
|
||||||
@ -66,7 +66,7 @@ module("Unit | Model | badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("save", async function (assert) {
|
test("save", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const badge = store.createRecord("badge", {
|
const badge = store.createRecord("badge", {
|
||||||
id: 1999,
|
id: 1999,
|
||||||
name: "New Badge",
|
name: "New Badge",
|
||||||
@ -89,7 +89,7 @@ module("Unit | Model | badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", async function (assert) {
|
test("destroy", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const badge = store.createRecord("badge", {
|
const badge = store.createRecord("badge", {
|
||||||
name: "New Badge",
|
name: "New Badge",
|
||||||
description: "This is a new badge.",
|
description: "This is a new badge.",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | bookmark", function (hooks) {
|
module("Unit | Model | bookmark", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("topicForList - Topic bookmarkable", function (assert) {
|
test("topicForList - Topic bookmarkable", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const bookmark = store.createRecord("bookmark", {
|
const bookmark = store.createRecord("bookmark", {
|
||||||
id: 1,
|
id: 1,
|
||||||
bookmarkable_type: "Topic",
|
bookmarkable_type: "Topic",
|
||||||
@ -26,7 +26,7 @@ module("Unit | Model | bookmark", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("topicForList - Post bookmarkable", function (assert) {
|
test("topicForList - Post bookmarkable", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const bookmark = store.createRecord("bookmark", {
|
const bookmark = store.createRecord("bookmark", {
|
||||||
id: 1,
|
id: 1,
|
||||||
bookmarkable_type: "Post",
|
bookmarkable_type: "Post",
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | category", function (hooks) {
|
module("Unit | Model | category", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("slugFor", function (assert) {
|
test("slugFor", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const slugFor = function (cat, val, text) {
|
const slugFor = function (cat, val, text) {
|
||||||
assert.strictEqual(Category.slugFor(cat), val, text);
|
assert.strictEqual(Category.slugFor(cat), val, text);
|
||||||
@ -69,7 +69,7 @@ module("Unit | Model | category", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("findBySlug", function (assert) {
|
test("findBySlug", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const darth = store.createRecord("category", { id: 1, slug: "darth" }),
|
const darth = store.createRecord("category", { id: 1, slug: "darth" }),
|
||||||
luke = store.createRecord("category", {
|
luke = store.createRecord("category", {
|
||||||
id: 2,
|
id: 2,
|
||||||
@ -132,7 +132,7 @@ module("Unit | Model | category", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("findSingleBySlug", function (assert) {
|
test("findSingleBySlug", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const darth = store.createRecord("category", { id: 1, slug: "darth" }),
|
const darth = store.createRecord("category", { id: 1, slug: "darth" }),
|
||||||
luke = store.createRecord("category", {
|
luke = store.createRecord("category", {
|
||||||
id: 2,
|
id: 2,
|
||||||
@ -195,7 +195,7 @@ module("Unit | Model | category", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("findBySlugPathWithID", function (assert) {
|
test("findBySlugPathWithID", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
||||||
const bar = store.createRecord("category", {
|
const bar = store.createRecord("category", {
|
||||||
@ -219,7 +219,7 @@ module("Unit | Model | category", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("minimumRequiredTags", function (assert) {
|
test("minimumRequiredTags", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const foo = store.createRecord("category", {
|
const foo = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -283,7 +283,7 @@ module("Unit | Model | category", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("search with category name", function (assert) {
|
test("search with category name", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const category1 = store.createRecord("category", {
|
const category1 = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "middle term",
|
name: "middle term",
|
||||||
@ -389,7 +389,7 @@ module("Unit | Model | category", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("search with category slug", function (assert) {
|
test("search with category slug", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const category1 = store.createRecord("category", {
|
const category1 = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "middle term",
|
name: "middle term",
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
import { currentUser } from "discourse/tests/helpers/qunit-helpers";
|
import { currentUser } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import AppEvents from "discourse/services/app-events";
|
import AppEvents from "discourse/services/app-events";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import pretender, {
|
import pretender, {
|
||||||
parsePostData,
|
parsePostData,
|
||||||
@ -17,7 +17,7 @@ import pretender, {
|
|||||||
function createComposer(opts = {}) {
|
function createComposer(opts = {}) {
|
||||||
opts.user ??= currentUser();
|
opts.user ??= currentUser();
|
||||||
opts.appEvents = AppEvents.create();
|
opts.appEvents = AppEvents.create();
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
return store.createRecord("composer", opts);
|
return store.createRecord("composer", opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +31,11 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.siteSettings = getOwnerWithFallback(this).lookup(
|
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("replyLength", function (assert) {
|
test("replyLength", function (assert) {
|
||||||
const replyLength = function (val, expectedLength) {
|
const replyLength = (val, expectedLength) => {
|
||||||
const composer = createComposer.call(this, { reply: val });
|
const composer = createComposer.call(this, { reply: val });
|
||||||
assert.strictEqual(composer.replyLength, expectedLength);
|
assert.strictEqual(composer.replyLength, expectedLength);
|
||||||
};
|
};
|
||||||
@ -73,7 +71,13 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
test("missingReplyCharacters", function (assert) {
|
test("missingReplyCharacters", function (assert) {
|
||||||
this.siteSettings.min_first_post_length = 40;
|
this.siteSettings.min_first_post_length = 40;
|
||||||
|
|
||||||
function missingReplyCharacters(val, isPM, isFirstPost, expected, message) {
|
const missingReplyCharacters = (
|
||||||
|
val,
|
||||||
|
isPM,
|
||||||
|
isFirstPost,
|
||||||
|
expected,
|
||||||
|
message
|
||||||
|
) => {
|
||||||
let action;
|
let action;
|
||||||
|
|
||||||
if (isFirstPost) {
|
if (isFirstPost) {
|
||||||
@ -86,7 +90,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
|
|
||||||
const composer = createComposer.call(this, { reply: val, action });
|
const composer = createComposer.call(this, { reply: val, action });
|
||||||
assert.strictEqual(composer.missingReplyCharacters, expected, message);
|
assert.strictEqual(composer.missingReplyCharacters, expected, message);
|
||||||
}
|
};
|
||||||
|
|
||||||
missingReplyCharacters(
|
missingReplyCharacters(
|
||||||
"hi",
|
"hi",
|
||||||
@ -129,7 +133,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("missingTitleCharacters", function (assert) {
|
test("missingTitleCharacters", function (assert) {
|
||||||
const missingTitleCharacters = function (val, isPM, expected, message) {
|
const missingTitleCharacters = (val, isPM, expected, message) => {
|
||||||
const composer = createComposer.call(this, {
|
const composer = createComposer.call(this, {
|
||||||
title: val,
|
title: val,
|
||||||
action: isPM ? PRIVATE_MESSAGE : REPLY,
|
action: isPM ? PRIVATE_MESSAGE : REPLY,
|
||||||
@ -152,7 +156,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("replyDirty", function (assert) {
|
test("replyDirty", function (assert) {
|
||||||
const composer = createComposer();
|
const composer = createComposer.call(this);
|
||||||
assert.ok(!composer.replyDirty, "by default it's false");
|
assert.ok(!composer.replyDirty, "by default it's false");
|
||||||
|
|
||||||
composer.setProperties({
|
composer.setProperties({
|
||||||
@ -169,7 +173,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("appendText", function (assert) {
|
test("appendText", function (assert) {
|
||||||
const composer = createComposer();
|
const composer = createComposer.call(this);
|
||||||
|
|
||||||
assert.blank(composer.reply, "the reply is blank by default");
|
assert.blank(composer.reply, "the reply is blank by default");
|
||||||
|
|
||||||
@ -202,7 +206,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("prependText", function (assert) {
|
test("prependText", function (assert) {
|
||||||
const composer = createComposer();
|
const composer = createComposer.call(this);
|
||||||
|
|
||||||
assert.blank(composer.reply, "the reply is blank by default");
|
assert.blank(composer.reply, "the reply is blank by default");
|
||||||
|
|
||||||
@ -227,7 +231,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
test("Title length for regular topics", function (assert) {
|
test("Title length for regular topics", function (assert) {
|
||||||
this.siteSettings.min_topic_title_length = 5;
|
this.siteSettings.min_topic_title_length = 5;
|
||||||
this.siteSettings.max_topic_title_length = 10;
|
this.siteSettings.max_topic_title_length = 10;
|
||||||
const composer = createComposer();
|
const composer = createComposer.call(this);
|
||||||
|
|
||||||
composer.set("title", "asdf");
|
composer.set("title", "asdf");
|
||||||
assert.ok(!composer.titleLengthValid, "short titles are not valid");
|
assert.ok(!composer.titleLengthValid, "short titles are not valid");
|
||||||
@ -255,7 +259,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Post length for private messages with non human users", function (assert) {
|
test("Post length for private messages with non human users", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", { pm_with_non_human_user: true });
|
const topic = store.createRecord("topic", { pm_with_non_human_user: true });
|
||||||
const composer = createComposer.call(this, {
|
const composer = createComposer.call(this, {
|
||||||
topic,
|
topic,
|
||||||
@ -265,10 +269,10 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("editingFirstPost", function (assert) {
|
test("editingFirstPost", function (assert) {
|
||||||
const composer = createComposer();
|
const composer = createComposer.call(this);
|
||||||
assert.ok(!composer.editingFirstPost, "it's false by default");
|
assert.ok(!composer.editingFirstPost, "it's false by default");
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", { id: 123, post_number: 2 });
|
const post = store.createRecord("post", { id: 123, post_number: 2 });
|
||||||
composer.setProperties({ post, action: EDIT });
|
composer.setProperties({ post, action: EDIT });
|
||||||
assert.ok(
|
assert.ok(
|
||||||
@ -284,7 +288,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("clearState", function (assert) {
|
test("clearState", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const composer = createComposer.call(this, {
|
const composer = createComposer.call(this, {
|
||||||
originalText: "asdf",
|
originalText: "asdf",
|
||||||
reply: "asdf2",
|
reply: "asdf2",
|
||||||
@ -340,7 +344,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
test("open with a quote", function (assert) {
|
test("open with a quote", function (assert) {
|
||||||
const quote =
|
const quote =
|
||||||
'[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]';
|
'[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]';
|
||||||
const newComposer = function () {
|
const newComposer = () => {
|
||||||
return openComposer.call(this, {
|
return openComposer.call(this, {
|
||||||
action: REPLY,
|
action: REPLY,
|
||||||
draftKey: "abcd",
|
draftKey: "abcd",
|
||||||
@ -364,9 +368,9 @@ module("Unit | Model | composer", function (hooks) {
|
|||||||
test("Title length for static page topics as admin", function (assert) {
|
test("Title length for static page topics as admin", function (assert) {
|
||||||
this.siteSettings.min_topic_title_length = 5;
|
this.siteSettings.min_topic_title_length = 5;
|
||||||
this.siteSettings.max_topic_title_length = 10;
|
this.siteSettings.max_topic_title_length = 10;
|
||||||
const composer = createComposer();
|
const composer = createComposer.call(this);
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", {
|
const post = store.createRecord("post", {
|
||||||
id: 123,
|
id: 123,
|
||||||
post_number: 2,
|
post_number: 2,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setPrefix } from "discourse-common/lib/get-url";
|
import { setPrefix } from "discourse-common/lib/get-url";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | email-log", function (hooks) {
|
module("Unit | Model | email-log", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("create", function (assert) {
|
test("create", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
store.createRecord("email-log"),
|
store.createRecord("email-log"),
|
||||||
"it can be created without arguments"
|
"it can be created without arguments"
|
||||||
@ -32,7 +32,7 @@ module("Unit | Model | email-log", function (hooks) {
|
|||||||
"/forum/letter_avatar_proxy/v2/letter/w/dfb087/{size}.png",
|
"/forum/letter_avatar_proxy/v2/letter/w/dfb087/{size}.png",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const emailLog = store.createRecord("email-log", attrs);
|
const emailLog = store.createRecord("email-log", attrs);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | group", function (hooks) {
|
module("Unit | Model | group", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("displayName", function (assert) {
|
test("displayName", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const group = store.createRecord("group", {
|
const group = store.createRecord("group", {
|
||||||
name: "test",
|
name: "test",
|
||||||
display_name: "donkey",
|
display_name: "donkey",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | invite", function (hooks) {
|
module("Unit | Model | invite", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("create", function (assert) {
|
test("create", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
store.createRecord("invite"),
|
store.createRecord("invite"),
|
||||||
"it can be created without arguments"
|
"it can be created without arguments"
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import NavItem from "discourse/models/nav-item";
|
import NavItem from "discourse/models/nav-item";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | nav-item", function (hooks) {
|
module("Unit | Model | nav-item", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const fooCategory = store.createRecord("category", {
|
const fooCategory = store.createRecord("category", {
|
||||||
slug: "foo",
|
slug: "foo",
|
||||||
id: 123,
|
id: 123,
|
||||||
});
|
});
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.categories.addObject(fooCategory);
|
site.categories.addObject(fooCategory);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ module("Unit | Model | nav-item", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("count", function (assert) {
|
test("count", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const navItem = store.createRecord("nav-item", { name: "new" });
|
const navItem = store.createRecord("nav-item", { name: "new" });
|
||||||
|
|
||||||
assert.strictEqual(navItem.count, 0, "it has no count by default");
|
assert.strictEqual(navItem.count, 0, "it has no count by default");
|
||||||
@ -54,7 +54,7 @@ module("Unit | Model | nav-item", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("displayName", function (assert) {
|
test("displayName", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const navItem = store.createRecord("nav-item", {
|
const navItem = store.createRecord("nav-item", {
|
||||||
name: "something",
|
name: "something",
|
||||||
});
|
});
|
||||||
@ -69,7 +69,7 @@ module("Unit | Model | nav-item", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("title", function (assert) {
|
test("title", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const navItem = store.createRecord("nav-item", {
|
const navItem = store.createRecord("nav-item", {
|
||||||
name: "something",
|
name: "something",
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { settled } from "@ember/test-helpers";
|
import { settled } from "@ember/test-helpers";
|
||||||
|
|
||||||
module("Unit | Model | pending-post", function (hooks) {
|
module("Unit | Model | pending-post", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("Properties", async function (assert) {
|
test("Properties", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const category = store.createRecord("category", { id: 2 });
|
const category = store.createRecord("category", { id: 2 });
|
||||||
const post = store.createRecord("pending-post", {
|
const post = store.createRecord("pending-post", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -38,7 +38,7 @@ module("Unit | Model | pending-post", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("it cooks raw_text", async function (assert) {
|
test("it cooks raw_text", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("pending-post", {
|
const post = store.createRecord("pending-post", {
|
||||||
raw_text: "**bold text**",
|
raw_text: "**bold text**",
|
||||||
});
|
});
|
||||||
|
@ -4,11 +4,11 @@ import Post from "discourse/models/post";
|
|||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
function buildStream(id, stream) {
|
function buildStream(id, stream) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", { id, chunk_size: 5 });
|
const topic = store.createRecord("topic", { id, chunk_size: 5 });
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
@ -24,7 +24,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("create", function (assert) {
|
test("create", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
store.createRecord("postStream"),
|
store.createRecord("postStream"),
|
||||||
"it can be created with no parameters"
|
"it can be created with no parameters"
|
||||||
@ -40,7 +40,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("appending posts", function (assert) {
|
test("appending posts", function (assert) {
|
||||||
const postStream = buildStream.call(this, 4567, [1, 3, 4]);
|
const postStream = buildStream.call(this, 4567, [1, 3, 4]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
assert.strictEqual(postStream.lastPostId, 4, "the last post id is 4");
|
assert.strictEqual(postStream.lastPostId, 4, "the last post id is 4");
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("closestPostNumberFor", function (assert) {
|
test("closestPostNumberFor", function (assert) {
|
||||||
const postStream = buildStream.call(this, 1231);
|
const postStream = buildStream.call(this, 1231);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
assert.blank(
|
assert.blank(
|
||||||
postStream.closestPostNumberFor(1),
|
postStream.closestPostNumberFor(1),
|
||||||
@ -193,7 +193,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("removePosts", function (assert) {
|
test("removePosts", function (assert) {
|
||||||
const postStream = buildStream.call(this, 10000001, [1, 2, 3]);
|
const postStream = buildStream.call(this, 10000001, [1, 2, 3]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const p1 = store.createRecord("post", { id: 1, post_number: 2 }),
|
const p1 = store.createRecord("post", { id: 1, post_number: 2 }),
|
||||||
p2 = store.createRecord("post", { id: 2, post_number: 3 }),
|
p2 = store.createRecord("post", { id: 2, post_number: 3 }),
|
||||||
@ -532,7 +532,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("identity map", async function (assert) {
|
test("identity map", async function (assert) {
|
||||||
const postStream = buildStream.call(this, 1234);
|
const postStream = buildStream.call(this, 1234);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const p1 = postStream.appendPost(
|
const p1 = postStream.appendPost(
|
||||||
store.createRecord("post", { id: 1, post_number: 1 })
|
store.createRecord("post", { id: 1, post_number: 1 })
|
||||||
@ -577,7 +577,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("appendMore for megatopic", async function (assert) {
|
test("appendMore for megatopic", async function (assert) {
|
||||||
const postStream = buildStream.call(this, 1234);
|
const postStream = buildStream.call(this, 1234);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", { id: 1, post_number: 1 });
|
const post = store.createRecord("post", { id: 1, post_number: 1 });
|
||||||
|
|
||||||
postStream.setProperties({
|
postStream.setProperties({
|
||||||
@ -600,7 +600,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("prependMore for megatopic", async function (assert) {
|
test("prependMore for megatopic", async function (assert) {
|
||||||
const postStream = buildStream.call(this, 1234);
|
const postStream = buildStream.call(this, 1234);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", { id: 6, post_number: 6 });
|
const post = store.createRecord("post", { id: 6, post_number: 6 });
|
||||||
|
|
||||||
postStream.setProperties({
|
postStream.setProperties({
|
||||||
@ -623,7 +623,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("staging and undoing a new post", function (assert) {
|
test("staging and undoing a new post", function (assert) {
|
||||||
const postStream = buildStream.call(this, 10101, [1]);
|
const postStream = buildStream.call(this, 10101, [1]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const original = store.createRecord("post", {
|
const original = store.createRecord("post", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -724,7 +724,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("staging and committing a post", function (assert) {
|
test("staging and committing a post", function (assert) {
|
||||||
const postStream = buildStream.call(this, 10101, [1]);
|
const postStream = buildStream.call(this, 10101, [1]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const original = store.createRecord("post", {
|
const original = store.createRecord("post", {
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -808,7 +808,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
// This can happen in a race condition between staging a post and it coming through on the
|
// This can happen in a race condition between staging a post and it coming through on the
|
||||||
// message bus. If the id of a post changes we should reconsider the loadedAllPosts property.
|
// message bus. If the id of a post changes we should reconsider the loadedAllPosts property.
|
||||||
const postStream = buildStream.call(this, 10101, [1, 2]);
|
const postStream = buildStream.call(this, 10101, [1, 2]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const postWithoutId = store.createRecord("post", {
|
const postWithoutId = store.createRecord("post", {
|
||||||
raw: "hello world this is my new post",
|
raw: "hello world this is my new post",
|
||||||
});
|
});
|
||||||
@ -828,7 +828,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("triggerRecoveredPost", async function (assert) {
|
test("triggerRecoveredPost", async function (assert) {
|
||||||
const postStream = buildStream.call(this, 4567);
|
const postStream = buildStream.call(this, 4567);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
[1, 2, 3, 5].forEach((id) => {
|
[1, 2, 3, 5].forEach((id) => {
|
||||||
postStream.appendPost(
|
postStream.appendPost(
|
||||||
@ -857,7 +857,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("committing and triggerNewPostsInStream race condition", function (assert) {
|
test("committing and triggerNewPostsInStream race condition", function (assert) {
|
||||||
const postStream = buildStream.call(this, 4964);
|
const postStream = buildStream.call(this, 4964);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
postStream.appendPost(
|
postStream.appendPost(
|
||||||
store.createRecord("post", { id: 1, post_number: 1 })
|
store.createRecord("post", { id: 1, post_number: 1 })
|
||||||
@ -893,7 +893,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("triggerNewPostInStream for ignored posts", async function (assert) {
|
test("triggerNewPostInStream for ignored posts", async function (assert) {
|
||||||
const postStream = buildStream.call(this, 280, [1]);
|
const postStream = buildStream.call(this, 280, [1]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
User.resetCurrent(
|
User.resetCurrent(
|
||||||
store.createRecord("user", {
|
store.createRecord("user", {
|
||||||
username: "eviltrout",
|
username: "eviltrout",
|
||||||
@ -956,7 +956,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
);
|
);
|
||||||
const postsWithPlaceholders = postStream.postsWithPlaceholders;
|
const postsWithPlaceholders = postStream.postsWithPlaceholders;
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const testProxy = ArrayProxy.create({ content: postsWithPlaceholders });
|
const testProxy = ArrayProxy.create({ content: postsWithPlaceholders });
|
||||||
|
|
||||||
@ -1029,7 +1029,7 @@ module("Unit | Model | post-stream", function (hooks) {
|
|||||||
|
|
||||||
test("progressIndexOfPostId", function (assert) {
|
test("progressIndexOfPostId", function (assert) {
|
||||||
const postStream = buildStream.call(this, 4567, [1, 3, 4]);
|
const postStream = buildStream.call(this, 4567, [1, 3, 4]);
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const post = store.createRecord("post", { id: 1, post_number: 5 });
|
const post = store.createRecord("post", { id: 1, post_number: 5 });
|
||||||
|
|
||||||
assert.strictEqual(postStream.progressIndexOfPostId(post), 1);
|
assert.strictEqual(postStream.progressIndexOfPostId(post), 1);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | post", function (hooks) {
|
module("Unit | Model | post", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
this.store = getOwner(this).lookup("service:store");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function (assert) {
|
test("defaults", function (assert) {
|
||||||
|
@ -4,7 +4,7 @@ import { publishToMessageBus } from "discourse/tests/helpers/qunit-helpers";
|
|||||||
import MessageBus from "message-bus-client";
|
import MessageBus from "message-bus-client";
|
||||||
import PrivateMessageTopicTrackingState from "discourse/services/pm-topic-tracking-state";
|
import PrivateMessageTopicTrackingState from "discourse/services/pm-topic-tracking-state";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function setupPretender() {
|
function setupPretender() {
|
||||||
pretender.get(`/u/test/private-message-topic-tracking-state`, () => {
|
pretender.get(`/u/test/private-message-topic-tracking-state`, () => {
|
||||||
@ -24,7 +24,7 @@ module("Unit | Model | private-message-topic-tracking-state", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("modifying state calls onStateChange callbacks", function (assert) {
|
test("modifying state calls onStateChange callbacks", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||||
messageBus: MessageBus,
|
messageBus: MessageBus,
|
||||||
currentUser: store.createRecord("user", { id: 77889, username: "test" }),
|
currentUser: store.createRecord("user", { id: 77889, username: "test" }),
|
||||||
@ -50,7 +50,7 @@ module(
|
|||||||
|
|
||||||
test("modifies the topic state only if the topic was not created by the current user", async function (assert) {
|
test("modifies the topic state only if the topic was not created by the current user", async function (assert) {
|
||||||
setupPretender();
|
setupPretender();
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||||
messageBus: MessageBus,
|
messageBus: MessageBus,
|
||||||
currentUser: store.createRecord("user", {
|
currentUser: store.createRecord("user", {
|
||||||
@ -110,7 +110,7 @@ module(
|
|||||||
|
|
||||||
test("modifies the last_read_post_number and highest_post_number", async function (assert) {
|
test("modifies the last_read_post_number and highest_post_number", async function (assert) {
|
||||||
setupPretender();
|
setupPretender();
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
const pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||||
messageBus: MessageBus,
|
messageBus: MessageBus,
|
||||||
currentUser: store.createRecord("user", {
|
currentUser: store.createRecord("user", {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setPrefix } from "discourse-common/lib/get-url";
|
import { setPrefix } from "discourse-common/lib/get-url";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function reportWithData(data) {
|
function reportWithData(data) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
return store.createRecord("report", {
|
return store.createRecord("report", {
|
||||||
type: "topics",
|
type: "topics",
|
||||||
@ -352,7 +352,7 @@ module("Unit | Model | report", function (hooks) {
|
|||||||
{ type: "bytes", property: "filesize", title: "Filesize" },
|
{ type: "bytes", property: "filesize", title: "Filesize" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const report = store.createRecord("report", {
|
const report = store.createRecord("report", {
|
||||||
type: "topics",
|
type: "topics",
|
||||||
labels,
|
labels,
|
||||||
|
@ -2,14 +2,14 @@ import { module, test } from "qunit";
|
|||||||
import RestAdapter from "discourse/adapters/rest";
|
import RestAdapter from "discourse/adapters/rest";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | rest-model", function (hooks) {
|
module("Unit | Model | rest-model", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("munging", function (assert) {
|
test("munging", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
class Grape extends RestModel {}
|
class Grape extends RestModel {}
|
||||||
Grape.reopenClass({
|
Grape.reopenClass({
|
||||||
munge: function (json) {
|
munge: function (json) {
|
||||||
@ -18,13 +18,13 @@ module("Unit | Model | rest-model", function (hooks) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
getOwnerWithFallback(this).register("model:grape", Grape);
|
getOwner(this).register("model:grape", Grape);
|
||||||
const g = store.createRecord("grape", { store, percent: 0.4 });
|
const g = store.createRecord("grape", { store, percent: 0.4 });
|
||||||
assert.strictEqual(g.inverse, 0.6, "it runs `munge` on `create`");
|
assert.strictEqual(g.inverse, 0.6, "it runs `munge` on `create`");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update", async function (assert) {
|
test("update", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = await store.find("widget", 123);
|
const widget = await store.find("widget", 123);
|
||||||
assert.strictEqual(widget.name, "Trout Lure");
|
assert.strictEqual(widget.name, "Trout Lure");
|
||||||
assert.ok(!widget.isSaving, "it is not saving");
|
assert.ok(!widget.isSaving, "it is not saving");
|
||||||
@ -45,7 +45,7 @@ module("Unit | Model | rest-model", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("updating simultaneously", async function (assert) {
|
test("updating simultaneously", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = await store.find("widget", 123);
|
const widget = await store.find("widget", 123);
|
||||||
|
|
||||||
const firstPromise = widget.update({ name: "new name" });
|
const firstPromise = widget.update({ name: "new name" });
|
||||||
@ -58,7 +58,7 @@ module("Unit | Model | rest-model", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("save new", async function (assert) {
|
test("save new", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget");
|
const widget = store.createRecord("widget");
|
||||||
|
|
||||||
assert.ok(widget.isNew, "it is a new record");
|
assert.ok(widget.isNew, "it is a new record");
|
||||||
@ -84,7 +84,7 @@ module("Unit | Model | rest-model", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("creating simultaneously", async function (assert) {
|
test("creating simultaneously", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget");
|
const widget = store.createRecord("widget");
|
||||||
|
|
||||||
const firstPromise = widget.save({ name: "Evil Widget" });
|
const firstPromise = widget.save({ name: "Evil Widget" });
|
||||||
@ -97,15 +97,15 @@ module("Unit | Model | rest-model", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("destroyRecord", async function (assert) {
|
test("destroyRecord", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = await store.find("widget", 123);
|
const widget = await store.find("widget", 123);
|
||||||
|
|
||||||
assert.ok(await widget.destroyRecord());
|
assert.ok(await widget.destroyRecord());
|
||||||
});
|
});
|
||||||
|
|
||||||
test("custom api name", async function (assert) {
|
test("custom api name", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
getOwnerWithFallback(this).register(
|
getOwner(this).register(
|
||||||
"adapter:my-widget",
|
"adapter:my-widget",
|
||||||
class extends RestAdapter {
|
class extends RestAdapter {
|
||||||
// An adapter like this is used when the server-side key/url
|
// An adapter like this is used when the server-side key/url
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | result-set", function (hooks) {
|
module("Unit | Model | result-set", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("defaults", function (assert) {
|
test("defaults", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const resultSet = store.createRecord("result-set", { content: [] });
|
const resultSet = store.createRecord("result-set", { content: [] });
|
||||||
assert.strictEqual(resultSet.length, 0);
|
assert.strictEqual(resultSet.length, 0);
|
||||||
assert.strictEqual(resultSet.totalRows, 0);
|
assert.strictEqual(resultSet.totalRows, 0);
|
||||||
@ -17,7 +17,7 @@ module("Unit | Model | result-set", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("pagination support", async function (assert) {
|
test("pagination support", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const resultSet = await store.findAll("widget");
|
const resultSet = await store.findAll("widget");
|
||||||
assert.strictEqual(resultSet.length, 2);
|
assert.strictEqual(resultSet.length, 2);
|
||||||
assert.strictEqual(resultSet.totalRows, 4);
|
assert.strictEqual(resultSet.totalRows, 4);
|
||||||
@ -36,7 +36,7 @@ module("Unit | Model | result-set", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("refresh support", async function (assert) {
|
test("refresh support", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const resultSet = await store.findAll("widget");
|
const resultSet = await store.findAll("widget");
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
resultSet.refreshUrl,
|
resultSet.refreshUrl,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import Site from "discourse/models/site";
|
import Site from "discourse/models/site";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | site", function (hooks) {
|
module("Unit | Model | site", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("create", function (assert) {
|
test("create", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
assert.ok(store.createRecord("site"), "it can create with no parameters");
|
assert.ok(store.createRecord("site"), "it can create with no parameters");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ module("Unit | Model | site", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("create categories", function (assert) {
|
test("create categories", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const site = store.createRecord("site", {
|
const site = store.createRecord("site", {
|
||||||
categories: [
|
categories: [
|
||||||
{ id: 3456, name: "Test Subcategory", parent_category_id: 1234 },
|
{ id: 3456, name: "Test Subcategory", parent_category_id: 1234 },
|
||||||
@ -73,7 +73,7 @@ module("Unit | Model | site", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("sortedCategories returns categories sorted by topic counts and sorts child categories after parent", function (assert) {
|
test("sortedCategories returns categories sorted by topic counts and sorts child categories after parent", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const site = store.createRecord("site", {
|
const site = store.createRecord("site", {
|
||||||
categories: [
|
categories: [
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | staff-action-log", function (hooks) {
|
module("Unit | Model | staff-action-log", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("create", function (assert) {
|
test("create", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
store.createRecord("staff-action-log"),
|
store.createRecord("staff-action-log"),
|
||||||
"it can be created without arguments"
|
"it can be created without arguments"
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | tag", function (hooks) {
|
module("Unit | Model | tag", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
this.store = getOwner(this).lookup("service:store");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("totalCount when pm_count is not present", function (assert) {
|
test("totalCount when pm_count is not present", function (assert) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | theme", function (hooks) {
|
module("Unit | Model | theme", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("can add an upload correctly", function (assert) {
|
test("can add an upload correctly", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const theme = store.createRecord("theme");
|
const theme = store.createRecord("theme");
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | topic-details", function (hooks) {
|
module("Unit | Model | topic-details", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("defaults", function (assert) {
|
test("defaults", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", { id: 1234 });
|
const topic = store.createRecord("topic", { id: 1234 });
|
||||||
const details = topic.details;
|
const details = topic.details;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ module("Unit | Model | topic-details", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("updateFromJson", function (assert) {
|
test("updateFromJson", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const topic = store.createRecord("topic", { id: 1234 });
|
const topic = store.createRecord("topic", { id: 1234 });
|
||||||
const details = topic.details;
|
const details = topic.details;
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@ import { module, test } from "qunit";
|
|||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import Topic from "discourse/models/topic";
|
import Topic from "discourse/models/topic";
|
||||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | topic", function (hooks) {
|
module("Unit | Model | topic", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
this.store = getOwner(this).lookup("service:store");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function (assert) {
|
test("defaults", function (assert) {
|
||||||
@ -204,9 +204,7 @@ module("Unit | Model | topic", function (hooks) {
|
|||||||
fancy_title: "This is a test",
|
fancy_title: "This is a test",
|
||||||
});
|
});
|
||||||
|
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
siteSettings.support_mixed_text_direction = true;
|
siteSettings.support_mixed_text_direction = true;
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -11,7 +11,7 @@ import { NotificationLevels } from "discourse/lib/notification-levels";
|
|||||||
import TopicTrackingState from "discourse/models/topic-tracking-state";
|
import TopicTrackingState from "discourse/models/topic-tracking-state";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
|
|
||||||
module("Unit | Model | topic-tracking-state", function (hooks) {
|
module("Unit | Model | topic-tracking-state", function (hooks) {
|
||||||
@ -19,7 +19,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
|||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.clock = fakeTime("2012-12-31 12:00");
|
this.clock = fakeTime("2012-12-31 12:00");
|
||||||
this.store = getOwnerWithFallback(this).lookup("service:store");
|
this.store = getOwner(this).lookup("service:store");
|
||||||
});
|
});
|
||||||
|
|
||||||
hooks.afterEach(function () {
|
hooks.afterEach(function () {
|
||||||
@ -672,7 +672,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getSubCategoryIds", function (assert) {
|
test("getSubCategoryIds", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
const foo = store.createRecord("category", { id: 1, slug: "foo" });
|
||||||
const bar = store.createRecord("category", {
|
const bar = store.createRecord("category", {
|
||||||
id: 2,
|
id: 2,
|
||||||
@ -693,7 +693,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("countNew", function (assert) {
|
test("countNew", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const foo = store.createRecord("category", {
|
const foo = store.createRecord("category", {
|
||||||
id: 1,
|
id: 1,
|
||||||
slug: "foo",
|
slug: "foo",
|
||||||
@ -842,10 +842,8 @@ module("Unit | Model | topic-tracking-state | /unread", function (hooks) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
|
|
||||||
this.currentUser = store.createRecord("user", {
|
this.currentUser = store.createRecord("user", {
|
||||||
username: "chuck",
|
username: "chuck",
|
||||||
@ -1097,10 +1095,8 @@ module("Unit | Model | topic-tracking-state | /new", function (hooks) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
|
|
||||||
this.currentUser = store.createRecord("user", {
|
this.currentUser = store.createRecord("user", {
|
||||||
username: "chuck",
|
username: "chuck",
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import UserAction from "discourse/models/user-action";
|
import UserAction from "discourse/models/user-action";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | user-action", function (hooks) {
|
module("Unit | Model | user-action", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("collapsing likes", function (assert) {
|
test("collapsing likes", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const actions = UserAction.collapseStream([
|
const actions = UserAction.collapseStream([
|
||||||
store.createRecord("user-action", {
|
store.createRecord("user-action", {
|
||||||
action_type: UserAction.TYPES.likes_given,
|
action_type: UserAction.TYPES.likes_given,
|
||||||
|
@ -3,7 +3,7 @@ import UserBadge from "discourse/models/user-badge";
|
|||||||
import badgeFixtures from "discourse/tests/fixtures/user-badges";
|
import badgeFixtures from "discourse/tests/fixtures/user-badges";
|
||||||
import { cloneJSON } from "discourse-common/lib/object";
|
import { cloneJSON } from "discourse-common/lib/object";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | user-badge", function (hooks) {
|
module("Unit | Model | user-badge", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
@ -58,14 +58,14 @@ module("Unit | Model | user-badge", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("revoke", async function (assert) {
|
test("revoke", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const userBadge = store.createRecord("user-badge", { id: 1 });
|
const userBadge = store.createRecord("user-badge", { id: 1 });
|
||||||
const result = await userBadge.revoke();
|
const result = await userBadge.revoke();
|
||||||
assert.deepEqual(result, { success: true });
|
assert.deepEqual(result, { success: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
test("favorite", async function (assert) {
|
test("favorite", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const userBadge = store.createRecord("user-badge", { id: 1 });
|
const userBadge = store.createRecord("user-badge", { id: 1 });
|
||||||
assert.notOk(userBadge.is_favorite);
|
assert.notOk(userBadge.is_favorite);
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ import { module, test } from "qunit";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { NEW_TOPIC_KEY } from "discourse/models/composer";
|
import { NEW_TOPIC_KEY } from "discourse/models/composer";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | user-draft", function (hooks) {
|
module("Unit | Model | user-draft", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("stream", function (assert) {
|
test("stream", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||||
const stream = user.userDraftsStream;
|
const stream = user.userDraftsStream;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ module("Unit | Model | user-draft", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("draft", function (assert) {
|
test("draft", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const drafts = [
|
const drafts = [
|
||||||
store.createRecord("user-draft", {
|
store.createRecord("user-draft", {
|
||||||
draft_key: "topic_1",
|
draft_key: "topic_1",
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import UserAction from "discourse/models/user-action";
|
import UserAction from "discourse/models/user-action";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | user-stream", function (hooks) {
|
module("Unit | Model | user-stream", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("basics", function (assert) {
|
test("basics", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||||
const stream = user.stream;
|
const stream = user.stream;
|
||||||
assert.present(stream, "a user has a stream by default");
|
assert.present(stream, "a user has a stream by default");
|
||||||
@ -21,7 +21,7 @@ module("Unit | Model | user-stream", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("filterParam", function (assert) {
|
test("filterParam", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||||
const stream = user.stream;
|
const stream = user.stream;
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import PreloadStore from "discourse/lib/preload-store";
|
|||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { settled } from "@ember/test-helpers";
|
import { settled } from "@ember/test-helpers";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Model | user", function (hooks) {
|
module("Unit | Model | user", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("staff", function (assert) {
|
test("staff", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
|
||||||
|
|
||||||
assert.ok(!user.staff, "user is not staff");
|
assert.ok(!user.staff, "user is not staff");
|
||||||
@ -23,7 +23,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("searchContext", function (assert) {
|
test("searchContext", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { id: 1, username: "EvilTrout" });
|
const user = store.createRecord("user", { id: 1, username: "EvilTrout" });
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -34,7 +34,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("isAllowedToUploadAFile", function (assert) {
|
test("isAllowedToUploadAFile", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { trust_level: 0, admin: true });
|
const user = store.createRecord("user", { trust_level: 0, admin: true });
|
||||||
assert.ok(
|
assert.ok(
|
||||||
user.isAllowedToUploadAFile("image"),
|
user.isAllowedToUploadAFile("image"),
|
||||||
@ -49,7 +49,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("canMangeGroup", function (assert) {
|
test("canMangeGroup", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", { admin: true });
|
const user = store.createRecord("user", { admin: true });
|
||||||
const group = store.createRecord("group", { automatic: true });
|
const group = store.createRecord("group", { automatic: true });
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("muted ids", function (assert) {
|
test("muted ids", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", {
|
const user = store.createRecord("user", {
|
||||||
username: "chuck",
|
username: "chuck",
|
||||||
muted_category_ids: [],
|
muted_category_ids: [],
|
||||||
@ -118,7 +118,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("subsequent calls to trackStatus and stopTrackingStatus increase and decrease subscribers counter", function (assert) {
|
test("subsequent calls to trackStatus and stopTrackingStatus increase and decrease subscribers counter", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user");
|
const user = store.createRecord("user");
|
||||||
assert.strictEqual(user._subscribersCount, 0);
|
assert.strictEqual(user._subscribersCount, 0);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("attempt to stop tracking status if status wasn't tracked doesn't throw", function (assert) {
|
test("attempt to stop tracking status if status wasn't tracked doesn't throw", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user");
|
const user = store.createRecord("user");
|
||||||
user.stopTrackingStatus();
|
user.stopTrackingStatus();
|
||||||
assert.ok(true);
|
assert.ok(true);
|
||||||
@ -151,7 +151,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
description: "user2 status",
|
description: "user2 status",
|
||||||
emoji: "speech_balloon",
|
emoji: "speech_balloon",
|
||||||
};
|
};
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user1 = store.createRecord("user", {
|
const user1 = store.createRecord("user", {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: status1,
|
status: status1,
|
||||||
@ -179,7 +179,7 @@ module("Unit | Model | user", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("create() doesn't set internal status tracking fields", function (assert) {
|
test("create() doesn't set internal status tracking fields", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const user = store.createRecord("user", {
|
const user = store.createRecord("user", {
|
||||||
_subscribersCount: 10,
|
_subscribersCount: 10,
|
||||||
_clearStatusTimerId: 100,
|
_clearStatusTimerId: 100,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("basic state", function (assert) {
|
test("basic state", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const field = store.createRecord("wizard-field", { type: "text" });
|
const field = store.createRecord("wizard-field", { type: "text" });
|
||||||
assert.ok(field.unchecked);
|
assert.ok(field.unchecked);
|
||||||
assert.ok(!field.valid);
|
assert.ok(!field.valid);
|
||||||
@ -14,7 +14,7 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("text - required - validation", function (assert) {
|
test("text - required - validation", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const field = store.createRecord("wizard-field", {
|
const field = store.createRecord("wizard-field", {
|
||||||
type: "text",
|
type: "text",
|
||||||
required: true,
|
required: true,
|
||||||
@ -34,7 +34,7 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("text - optional - validation", function (assert) {
|
test("text - optional - validation", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const field = store.createRecord("wizard-field", { type: "text" });
|
const field = store.createRecord("wizard-field", { type: "text" });
|
||||||
assert.ok(field.unchecked);
|
assert.ok(field.unchecked);
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { currentUser } from "discourse/tests/helpers/qunit-helpers";
|
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import Session from "discourse/models/session";
|
|
||||||
|
|
||||||
module("Unit | Service | document-title", function (hooks) {
|
module("Unit | Service | document-title", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
Session.current().hasFocus = true;
|
const session = getOwner(this).lookup("service:session");
|
||||||
this.documentTitle = getOwnerWithFallback(this).lookup(
|
session.hasFocus = true;
|
||||||
"service:document-title"
|
|
||||||
);
|
this.documentTitle = getOwner(this).lookup("service:document-title");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("it updates the document title", function (assert) {
|
test("it updates the document title", function (assert) {
|
||||||
@ -29,8 +28,13 @@ module("Unit | Service | document-title", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("it displays notification counts for logged in users", function (assert) {
|
test("it displays notification counts for logged in users", function (assert) {
|
||||||
this.documentTitle.currentUser = currentUser();
|
const currentUser = logIn();
|
||||||
this.documentTitle.currentUser.user_option.dynamic_favicon = false;
|
this.owner.unregister("service:current-user");
|
||||||
|
this.owner.register("service:current-user", currentUser, {
|
||||||
|
instantiate: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
currentUser.user_option.dynamic_favicon = false;
|
||||||
this.documentTitle.setTitle("test notifications");
|
this.documentTitle.setTitle("test notifications");
|
||||||
this.documentTitle.updateNotificationCount(5);
|
this.documentTitle.updateNotificationCount(5);
|
||||||
assert.strictEqual(document.title, "test notifications");
|
assert.strictEqual(document.title, "test notifications");
|
||||||
@ -42,13 +46,17 @@ module("Unit | Service | document-title", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("it doesn't display notification counts for users in do not disturb", function (assert) {
|
test("it doesn't display notification counts for users in do not disturb", function (assert) {
|
||||||
this.documentTitle.currentUser = currentUser();
|
const currentUser = logIn();
|
||||||
|
this.owner.unregister("service:current-user");
|
||||||
|
this.owner.register("service:current-user", currentUser, {
|
||||||
|
instantiate: false,
|
||||||
|
});
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setHours(date.getHours() + 1);
|
date.setHours(date.getHours() + 1);
|
||||||
this.documentTitle.currentUser.do_not_disturb_until = date.toUTCString();
|
currentUser.do_not_disturb_until = date.toUTCString();
|
||||||
|
|
||||||
this.documentTitle.currentUser.user_option.dynamic_favicon = false;
|
currentUser.user_option.dynamic_favicon = false;
|
||||||
this.documentTitle.setTitle("test notifications");
|
this.documentTitle.setTitle("test notifications");
|
||||||
this.documentTitle.updateNotificationCount(5);
|
this.documentTitle.updateNotificationCount(5);
|
||||||
assert.strictEqual(document.title, "test notifications");
|
assert.strictEqual(document.title, "test notifications");
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
module("Unit | Service | emoji-store", function (hooks) {
|
module("Unit | Service | emoji-store", function (hooks) {
|
||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.emojiStore = getOwnerWithFallback(this).lookup("service:emoji-store");
|
this.emojiStore = getOwner(this).lookup("service:emoji-store");
|
||||||
this.emojiStore.reset();
|
this.emojiStore.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { module, test } from "qunit";
|
|||||||
import { click } from "@ember/test-helpers";
|
import { click } from "@ember/test-helpers";
|
||||||
import { LIGHTBOX_APP_EVENT_NAMES } from "discourse/lib/lightbox/constants";
|
import { LIGHTBOX_APP_EVENT_NAMES } from "discourse/lib/lightbox/constants";
|
||||||
import domFromString from "discourse-common/lib/dom-from-string";
|
import domFromString from "discourse-common/lib/dom-from-string";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ module("Unit | Service | Experimental Lightbox", function (hooks) {
|
|||||||
const selector = ".lightbox";
|
const selector = ".lightbox";
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.lightbox = getOwnerWithFallback(this).lookup("service:lightbox");
|
this.lightbox = getOwner(this).lookup("service:lightbox");
|
||||||
this.appEvents = getOwnerWithFallback(this).lookup("service:app-events");
|
this.appEvents = getOwner(this).lookup("service:app-events");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Lightbox Service has appEvents", async function (assert) {
|
test("Lightbox Service has appEvents", async function (assert) {
|
||||||
|
@ -7,7 +7,7 @@ import { PresenceChannelNotFound } from "discourse/services/presence";
|
|||||||
import { setTestPresence } from "discourse/lib/user-presence";
|
import { setTestPresence } from "discourse/lib/user-presence";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
|
|
||||||
function usersFixture() {
|
function usersFixture() {
|
||||||
@ -63,7 +63,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("subscribing and receiving updates", async function (assert) {
|
test("subscribing and receiving updates", async function (assert) {
|
||||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
let presenceService = getOwner(this).lookup("service:presence");
|
||||||
let channel = presenceService.getChannel("/test/ch1");
|
let channel = presenceService.getChannel("/test/ch1");
|
||||||
let changes = 0;
|
let changes = 0;
|
||||||
const countChanges = () => changes++;
|
const countChanges = () => changes++;
|
||||||
@ -106,7 +106,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("fetches data when no initial state", async function (assert) {
|
test("fetches data when no initial state", async function (assert) {
|
||||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
let presenceService = getOwner(this).lookup("service:presence");
|
||||||
let channel = presenceService.getChannel("/test/ch1");
|
let channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
await channel.subscribe();
|
await channel.subscribe();
|
||||||
@ -152,7 +152,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("raises error when subscribing to nonexistent channel", async function (assert) {
|
test("raises error when subscribing to nonexistent channel", async function (assert) {
|
||||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
let presenceService = getOwner(this).lookup("service:presence");
|
||||||
let channel = presenceService.getChannel("/nonexistent/ch1");
|
let channel = presenceService.getChannel("/nonexistent/ch1");
|
||||||
|
|
||||||
assert.rejects(
|
assert.rejects(
|
||||||
@ -163,7 +163,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("can subscribe to count_only channel", async function (assert) {
|
test("can subscribe to count_only channel", async function (assert) {
|
||||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
let presenceService = getOwner(this).lookup("service:presence");
|
||||||
let channel = presenceService.getChannel("/count-only/ch1");
|
let channel = presenceService.getChannel("/count-only/ch1");
|
||||||
|
|
||||||
await channel.subscribe();
|
await channel.subscribe();
|
||||||
@ -200,7 +200,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("can share data between multiple PresenceChannel objects", async function (assert) {
|
test("can share data between multiple PresenceChannel objects", async function (assert) {
|
||||||
let presenceService = getOwnerWithFallback(this).lookup("service:presence");
|
let presenceService = getOwner(this).lookup("service:presence");
|
||||||
let channel = presenceService.getChannel("/test/ch1");
|
let channel = presenceService.getChannel("/test/ch1");
|
||||||
let channelDup = presenceService.getChannel("/test/ch1");
|
let channelDup = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
@ -285,8 +285,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("can join and leave channels", async function (assert) {
|
test("can join and leave channels", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
@ -313,8 +312,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("join should be a no-op if already present", async function (assert) {
|
test("join should be a no-op if already present", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
@ -330,8 +328,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("leave should be a no-op if not present", async function (assert) {
|
test("leave should be a no-op if not present", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
@ -355,8 +352,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
(resolve) => (resolveServerResponse = resolve)
|
(resolve) => (resolveServerResponse = resolve)
|
||||||
);
|
);
|
||||||
|
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
@ -381,8 +377,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("raises an error when entering a non-existent channel", async function (assert) {
|
test("raises an error when entering a non-existent channel", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/blah/does-not-exist");
|
const channel = presenceService.getChannel("/blah/does-not-exist");
|
||||||
await assert.rejects(
|
await assert.rejects(
|
||||||
@ -393,8 +388,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("deduplicates calls from multiple PresenceChannel instances", async function (assert) {
|
test("deduplicates calls from multiple PresenceChannel instances", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
const channelDup = presenceService.getChannel("/test/ch1");
|
const channelDup = presenceService.getChannel("/test/ch1");
|
||||||
@ -433,8 +427,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("updates the server presence after going idle", async function (assert) {
|
test("updates the server presence after going idle", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
@ -471,8 +464,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("handles the onlyWhileActive flag", async function (assert) {
|
test("handles the onlyWhileActive flag", async function (assert) {
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
await channel.enter();
|
await channel.enter();
|
||||||
@ -531,8 +523,7 @@ module("Unit | Service | presence | entering and leaving", function (hooks) {
|
|||||||
return response(429, { extras: { wait_seconds: 2 } });
|
return response(429, { extras: { wait_seconds: 2 } });
|
||||||
});
|
});
|
||||||
|
|
||||||
const presenceService =
|
const presenceService = getOwner(this).lookup("service:presence");
|
||||||
getOwnerWithFallback(this).lookup("service:presence");
|
|
||||||
presenceService.currentUser = currentUser();
|
presenceService.currentUser = currentUser();
|
||||||
const channel = presenceService.getChannel("/test/ch1");
|
const channel = presenceService.getChannel("/test/ch1");
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import EmberObject, { computed } from "@ember/object";
|
import EmberObject, { computed } from "@ember/object";
|
||||||
|
|
||||||
@ -17,9 +17,7 @@ module("Unit | Service | site-settings", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.siteSettings = getOwnerWithFallback(this).lookup(
|
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||||
"service:site-settings"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("contains settings", function (assert) {
|
test("contains settings", function (assert) {
|
||||||
@ -29,8 +27,8 @@ module("Unit | Service | site-settings", function (hooks) {
|
|||||||
test("notifies getters", function (assert) {
|
test("notifies getters", function (assert) {
|
||||||
this.siteSettings.title = "original";
|
this.siteSettings.title = "original";
|
||||||
|
|
||||||
getOwnerWithFallback(this).register("test-class:main", TestClass);
|
getOwner(this).register("test-class:main", TestClass);
|
||||||
const object = getOwnerWithFallback(this).lookup("test-class:main");
|
const object = getOwner(this).lookup("test-class:main");
|
||||||
assert.strictEqual(object.text, "The title: original");
|
assert.strictEqual(object.text, "The title: original");
|
||||||
|
|
||||||
this.siteSettings.title = "updated";
|
this.siteSettings.title = "updated";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupTest } from "ember-qunit";
|
import { setupTest } from "ember-qunit";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import pretender, {
|
import pretender, {
|
||||||
fixturesByUrl,
|
fixturesByUrl,
|
||||||
response,
|
response,
|
||||||
@ -10,7 +10,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
setupTest(hooks);
|
setupTest(hooks);
|
||||||
|
|
||||||
test("createRecord", function (assert) {
|
test("createRecord", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget", { id: 111, name: "hello" });
|
const widget = store.createRecord("widget", { id: 111, name: "hello" });
|
||||||
|
|
||||||
assert.false(widget.isNew, "it is not a new record");
|
assert.false(widget.isNew, "it is not a new record");
|
||||||
@ -19,7 +19,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("createRecord without an `id`", function (assert) {
|
test("createRecord without an `id`", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget", { name: "hello" });
|
const widget = store.createRecord("widget", { name: "hello" });
|
||||||
|
|
||||||
assert.true(widget.isNew, "it is a new record");
|
assert.true(widget.isNew, "it is a new record");
|
||||||
@ -27,7 +27,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("createRecord doesn't modify the input `id` field", function (assert) {
|
test("createRecord doesn't modify the input `id` field", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget", { id: 1, name: "hello" });
|
const widget = store.createRecord("widget", { id: 1, name: "hello" });
|
||||||
|
|
||||||
const obj = { id: 1, name: "something" };
|
const obj = { id: 1, name: "something" };
|
||||||
@ -39,7 +39,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("createRecord without attributes", function (assert) {
|
test("createRecord without attributes", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget");
|
const widget = store.createRecord("widget");
|
||||||
|
|
||||||
assert.strictEqual(widget.id, undefined, "there is no id");
|
assert.strictEqual(widget.id, undefined, "there is no id");
|
||||||
@ -47,7 +47,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("createRecord with a record as attributes returns that record from the map", function (assert) {
|
test("createRecord with a record as attributes returns that record from the map", function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget", { id: 33 });
|
const widget = store.createRecord("widget", { id: 33 });
|
||||||
const secondWidget = store.createRecord("widget", { id: 33 });
|
const secondWidget = store.createRecord("widget", { id: 33 });
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("find", async function (assert) {
|
test("find", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
|
|
||||||
const widget = await store.find("widget", 123);
|
const widget = await store.find("widget", 123);
|
||||||
assert.strictEqual(widget.name, "Trout Lure");
|
assert.strictEqual(widget.name, "Trout Lure");
|
||||||
@ -78,19 +78,19 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("find with object id", async function (assert) {
|
test("find with object id", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = await store.find("widget", { id: 123 });
|
const widget = await store.find("widget", { id: 123 });
|
||||||
assert.strictEqual(widget.firstObject.name, "Trout Lure");
|
assert.strictEqual(widget.firstObject.name, "Trout Lure");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("find with query param", async function (assert) {
|
test("find with query param", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = await store.find("widget", { name: "Trout Lure" });
|
const widget = await store.find("widget", { name: "Trout Lure" });
|
||||||
assert.strictEqual(widget.firstObject.id, 123);
|
assert.strictEqual(widget.firstObject.id, 123);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("findStale with no stale results", async function (assert) {
|
test("findStale with no stale results", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const stale = store.findStale("widget", { name: "Trout Lure" });
|
const stale = store.findStale("widget", { name: "Trout Lure" });
|
||||||
|
|
||||||
assert.false(stale.hasResults, "there are no stale results");
|
assert.false(stale.hasResults, "there are no stale results");
|
||||||
@ -118,7 +118,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const notifications = await store.find("notification", { slug: "souna" });
|
const notifications = await store.find("notification", { slug: "souna" });
|
||||||
assert.strictEqual(notifications.content[0].slug, "souna");
|
assert.strictEqual(notifications.content[0].slug, "souna");
|
||||||
|
|
||||||
@ -131,19 +131,19 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("update", async function (assert) {
|
test("update", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const result = await store.update("widget", 123, { name: "hello" });
|
const result = await store.update("widget", 123, { name: "hello" });
|
||||||
assert.strictEqual(result.payload.name, "hello");
|
assert.strictEqual(result.payload.name, "hello");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update with a multi world name", async function (assert) {
|
test("update with a multi world name", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const result = await store.update("cool-thing", 123, { name: "hello" });
|
const result = await store.update("cool-thing", 123, { name: "hello" });
|
||||||
assert.strictEqual(result.payload.name, "hello");
|
assert.strictEqual(result.payload.name, "hello");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("findAll", async function (assert) {
|
test("findAll", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const result = await store.findAll("widget");
|
const result = await store.findAll("widget");
|
||||||
assert.strictEqual(result.length, 2);
|
assert.strictEqual(result.length, 2);
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("destroyRecord", async function (assert) {
|
test("destroyRecord", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = await store.find("widget", 123);
|
const widget = await store.find("widget", 123);
|
||||||
|
|
||||||
const result = await store.destroyRecord("widget", widget);
|
const result = await store.destroyRecord("widget", widget);
|
||||||
@ -161,14 +161,14 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("destroyRecord when new", async function (assert) {
|
test("destroyRecord when new", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const widget = store.createRecord("widget", { name: "hello" });
|
const widget = store.createRecord("widget", { name: "hello" });
|
||||||
|
|
||||||
assert.true(await store.destroyRecord("widget", widget));
|
assert.true(await store.destroyRecord("widget", widget));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("find embedded", async function (assert) {
|
test("find embedded", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const fruit = await store.find("fruit", 1);
|
const fruit = await store.find("fruit", 1);
|
||||||
|
|
||||||
assert.propContains(
|
assert.propContains(
|
||||||
@ -182,7 +182,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("embedded records can be cleared", async function (assert) {
|
test("embedded records can be cleared", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
let fruit = await store.find("fruit", 4);
|
let fruit = await store.find("fruit", 4);
|
||||||
fruit.set("farmer", { dummy: "object" });
|
fruit.set("farmer", { dummy: "object" });
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("meta types", async function (assert) {
|
test("meta types", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const barn = await store.find("barn", 1);
|
const barn = await store.find("barn", 1);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
barn.owner.name,
|
barn.owner.name,
|
||||||
@ -201,7 +201,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("findAll embedded", async function (assert) {
|
test("findAll embedded", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const fruits = await store.findAll("fruit");
|
const fruits = await store.findAll("fruit");
|
||||||
assert.strictEqual(fruits.objectAt(0).farmer.name, "Old MacDonald");
|
assert.strictEqual(fruits.objectAt(0).farmer.name, "Old MacDonald");
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
@ -235,7 +235,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const users = await store.findAll("user");
|
const users = await store.findAll("user");
|
||||||
assert.strictEqual(users.objectAt(0).username, "souna");
|
assert.strictEqual(users.objectAt(0).username, "souna");
|
||||||
});
|
});
|
||||||
@ -249,7 +249,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
return response(fixturesByUrl["/c/bug/1/l/latest.json"]);
|
return response(fixturesByUrl["/c/bug/1/l/latest.json"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const result = await store.findFiltered("topicList", {
|
const result = await store.findFiltered("topicList", {
|
||||||
filter: "topics/created-by/trout",
|
filter: "topics/created-by/trout",
|
||||||
params: {
|
params: {
|
||||||
@ -265,7 +265,7 @@ module("Unit | Service | store", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Spec incompliant embedded record name", async function (assert) {
|
test("Spec incompliant embedded record name", async function (assert) {
|
||||||
const store = getOwnerWithFallback(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
const fruit = await store.find("fruit", 4);
|
const fruit = await store.find("fruit", 4);
|
||||||
|
|
||||||
assert.propContains(
|
assert.propContains(
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
import { test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwner } from "@ember/application";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { setupTest } from "ember-qunit";
|
||||||
|
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
acceptance("Unit | Service | user-tips", function (needs) {
|
module("Unit | Service | user-tips", function (hooks) {
|
||||||
needs.user();
|
setupTest(hooks);
|
||||||
|
|
||||||
test("hideUserTipForever() makes a single request", async function (assert) {
|
test("hideUserTipForever() makes a single request", async function (assert) {
|
||||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
const currentUser = logIn();
|
||||||
|
this.owner.unregister("service:current-user");
|
||||||
|
this.owner.register("service:current-user", currentUser, {
|
||||||
|
instantiate: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const site = getOwner(this).lookup("service:site");
|
||||||
site.set("user_tips", { first_notification: 1 });
|
site.set("user_tips", { first_notification: 1 });
|
||||||
const userTips = getOwnerWithFallback(this).lookup("service:user-tips");
|
|
||||||
|
|
||||||
let requestsCount = 0;
|
let requestsCount = 0;
|
||||||
pretender.put("/u/eviltrout.json", () => {
|
pretender.put("/u/eviltrout.json", () => {
|
||||||
@ -23,6 +29,7 @@ acceptance("Unit | Service | user-tips", function (needs) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const userTips = getOwner(this).lookup("service:user-tips");
|
||||||
await userTips.hideUserTipForever("first_notification");
|
await userTips.hideUserTipForever("first_notification");
|
||||||
assert.strictEqual(requestsCount, 1);
|
assert.strictEqual(requestsCount, 1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user