mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:42:46 +08:00
parent
e3108ded11
commit
dc5dc78309
|
@ -9,7 +9,6 @@ import {
|
|||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import Draft from "discourse/models/draft";
|
||||
import I18n from "I18n";
|
||||
import { Promise } from "rsvp";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import sinon from "sinon";
|
||||
import { test } from "qunit";
|
||||
|
@ -117,9 +116,8 @@ acceptance("Composer Actions", function (needs) {
|
|||
});
|
||||
|
||||
test("replying to post - reply_as_new_topic", async function (assert) {
|
||||
sinon
|
||||
.stub(Draft, "get")
|
||||
.returns(Promise.resolve({ draft: "", draft_sequence: 0 }));
|
||||
sinon.stub(Draft, "get").resolves({ draft: "", draft_sequence: 0 });
|
||||
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
const categoryChooser = selectKit(".title-wrapper .category-chooser");
|
||||
const categoryChooserReplyArea = selectKit(".reply-area .category-chooser");
|
||||
|
@ -405,13 +403,11 @@ acceptance("Composer Actions", function (needs) {
|
|||
});
|
||||
|
||||
function stubDraftResponse() {
|
||||
sinon.stub(Draft, "get").returns(
|
||||
Promise.resolve({
|
||||
draft:
|
||||
'{"reply":"dum de dum da ba.","action":"createTopic","title":"dum da ba dum dum","categoryId":null,"archetypeId":"regular","metaData":null,"composerTime":540879,"typingTime":3400}',
|
||||
draft_sequence: 0,
|
||||
})
|
||||
);
|
||||
sinon.stub(Draft, "get").resolves({
|
||||
draft:
|
||||
'{"reply":"dum de dum da ba.","action":"createTopic","title":"dum da ba dum dum","categoryId":null,"archetypeId":"regular","metaData":null,"composerTime":540879,"typingTime":3400}',
|
||||
draft_sequence: 0,
|
||||
});
|
||||
}
|
||||
|
||||
acceptance("Composer Actions With New Topic Draft", function (needs) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import {
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import I18n from "I18n";
|
||||
import { test } from "qunit";
|
||||
import { Promise } from "rsvp";
|
||||
import sinon from "sinon";
|
||||
|
||||
acceptance("Composer", function (needs) {
|
||||
|
@ -774,12 +773,10 @@ acceptance("Composer", function (needs) {
|
|||
|
||||
const longText = "a".repeat(256);
|
||||
|
||||
sinon.stub(Draft, "get").returns(
|
||||
Promise.resolve({
|
||||
draft: null,
|
||||
draft_sequence: 0,
|
||||
})
|
||||
);
|
||||
sinon.stub(Draft, "get").resolves({
|
||||
draft: null,
|
||||
draft_sequence: 0,
|
||||
});
|
||||
|
||||
await click(".btn-primary.create.btn");
|
||||
|
||||
|
@ -816,13 +813,11 @@ acceptance("Composer", function (needs) {
|
|||
test("Loading draft also replaces the recipients", async function (assert) {
|
||||
toggleCheckDraftPopup(true);
|
||||
|
||||
sinon.stub(Draft, "get").returns(
|
||||
Promise.resolve({
|
||||
draft:
|
||||
'{"reply":"hello","action":"privateMessage","title":"hello","categoryId":null,"archetypeId":"private_message","metaData":null,"recipients":"codinghorror","composerTime":9159,"typingTime":2500}',
|
||||
draft_sequence: 0,
|
||||
})
|
||||
);
|
||||
sinon.stub(Draft, "get").resolves({
|
||||
draft:
|
||||
'{"reply":"hello","action":"privateMessage","title":"hello","categoryId":null,"archetypeId":"private_message","metaData":null,"recipients":"codinghorror","composerTime":9159,"typingTime":2500}',
|
||||
draft_sequence: 0,
|
||||
});
|
||||
|
||||
await visit("/u/charlie");
|
||||
await click("button.compose-pm");
|
||||
|
@ -835,14 +830,12 @@ acceptance("Composer", function (needs) {
|
|||
test("Loads tags and category from draft payload", async function (assert) {
|
||||
updateCurrentUser({ has_topic_draft: true });
|
||||
|
||||
sinon.stub(Draft, "get").returns(
|
||||
Promise.resolve({
|
||||
draft:
|
||||
'{"reply":"Hey there","action":"createTopic","title":"Draft topic","categoryId":2,"tags":["fun", "times"],"archetypeId":"regular","metaData":null,"composerTime":25269,"typingTime":8100}',
|
||||
draft_sequence: 0,
|
||||
draft_key: NEW_TOPIC_KEY,
|
||||
})
|
||||
);
|
||||
sinon.stub(Draft, "get").resolves({
|
||||
draft:
|
||||
'{"reply":"Hey there","action":"createTopic","title":"Draft topic","categoryId":2,"tags":["fun", "times"],"archetypeId":"regular","metaData":null,"composerTime":25269,"typingTime":8100}',
|
||||
draft_sequence: 0,
|
||||
draft_key: NEW_TOPIC_KEY,
|
||||
});
|
||||
|
||||
await visit("/latest");
|
||||
assert.strictEqual(
|
||||
|
|
|
@ -66,7 +66,6 @@ module(
|
|||
assert.ok(exists("li.unread"));
|
||||
|
||||
this.item.notification.read = true;
|
||||
// await pauseTest();
|
||||
await settled();
|
||||
|
||||
assert.ok(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import EmberObject from "@ember/object";
|
||||
import { Placeholder } from "discourse/lib/posts-with-placeholders";
|
||||
import { Promise } from "rsvp";
|
||||
import Topic from "discourse/models/topic";
|
||||
import User from "discourse/models/user";
|
||||
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
@ -70,9 +69,8 @@ discourseModule("Unit | Controller | topic", function (hooks) {
|
|||
const model = Topic.create();
|
||||
let destroyed = false;
|
||||
let modalDisplayed = false;
|
||||
model.destroy = () => {
|
||||
model.destroy = async () => {
|
||||
destroyed = true;
|
||||
return Promise.resolve();
|
||||
};
|
||||
const controller = this.getController("topic", {
|
||||
model,
|
||||
|
@ -672,9 +670,8 @@ discourseModule("Unit | Controller | topic", function (hooks) {
|
|||
post_number: 2,
|
||||
can_delete: true,
|
||||
reply_count: 3,
|
||||
destroy: () => {
|
||||
destroy: async () => {
|
||||
destroyed = true;
|
||||
return Promise.resolve();
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ module("Unit | Utility | preload-store", function (hooks) {
|
|||
});
|
||||
|
||||
test("getAndRemove returns a promise that resolves to the result of the finder's promise", async function (assert) {
|
||||
const finder = () => Promise.resolve("hahahah");
|
||||
const finder = async () => "hahahah";
|
||||
const result = await PreloadStore.getAndRemove("joker", finder);
|
||||
|
||||
assert.strictEqual(result, "hahahah");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
||||
import { module, test } from "qunit";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
class FakeUppy {
|
||||
constructor() {
|
||||
|
@ -75,9 +74,7 @@ module("Unit | Utility | UppyMediaOptimization Plugin", function () {
|
|||
const fakeUppy = new FakeUppy();
|
||||
const plugin = new UppyMediaOptimization(fakeUppy, {
|
||||
runParallel: true,
|
||||
optimizeFn: () => {
|
||||
return Promise.resolve("new file state");
|
||||
},
|
||||
optimizeFn: async () => "new file state",
|
||||
});
|
||||
plugin.install();
|
||||
const done = assert.async();
|
||||
|
@ -96,10 +93,8 @@ module("Unit | Utility | UppyMediaOptimization Plugin", function () {
|
|||
const fakeUppy = new FakeUppy();
|
||||
const plugin = new UppyMediaOptimization(fakeUppy, {
|
||||
runParallel: true,
|
||||
optimizeFn: () => {
|
||||
return new Promise(() => {
|
||||
throw new Error("bad stuff");
|
||||
});
|
||||
optimizeFn: async () => {
|
||||
throw new Error("bad stuff");
|
||||
},
|
||||
});
|
||||
plugin.install();
|
||||
|
@ -119,9 +114,7 @@ module("Unit | Utility | UppyMediaOptimization Plugin", function () {
|
|||
const fakeUppy = new FakeUppy();
|
||||
const plugin = new UppyMediaOptimization(fakeUppy, {
|
||||
runParallel: false,
|
||||
optimizeFn: () => {
|
||||
return Promise.resolve("new file state");
|
||||
},
|
||||
optimizeFn: async () => "new file state",
|
||||
});
|
||||
plugin.install();
|
||||
const done = assert.async();
|
||||
|
@ -151,9 +144,7 @@ module("Unit | Utility | UppyMediaOptimization Plugin", function () {
|
|||
const fakeUppy = new FakeUppy();
|
||||
const plugin = new UppyMediaOptimization(fakeUppy, {
|
||||
runParallel: true,
|
||||
optimizeFn: () => {
|
||||
return Promise.resolve("new file state");
|
||||
},
|
||||
optimizeFn: async () => "new file state",
|
||||
});
|
||||
plugin.install();
|
||||
const done = assert.async();
|
||||
|
|
|
@ -2,7 +2,6 @@ import { module, test } from "qunit";
|
|||
import AppEvents from "discourse/services/app-events";
|
||||
import ArrayProxy from "@ember/array/proxy";
|
||||
import Post from "discourse/models/post";
|
||||
import { Promise } from "rsvp";
|
||||
import User from "discourse/models/user";
|
||||
import createStore from "discourse/tests/helpers/create-store";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
|
@ -232,7 +231,7 @@ module("Unit | Model | post-stream", function () {
|
|||
test("cancelFilter", function (assert) {
|
||||
const postStream = buildStream(1235);
|
||||
|
||||
sinon.stub(postStream, "refresh").returns(Promise.resolve());
|
||||
sinon.stub(postStream, "refresh").resolves();
|
||||
|
||||
postStream.set("filter", "summary");
|
||||
postStream.cancelFilter();
|
||||
|
@ -274,7 +273,7 @@ module("Unit | Model | post-stream", function () {
|
|||
|
||||
test("fillGapBefore", function (assert) {
|
||||
const postStream = buildStream(1234, [60]);
|
||||
sinon.stub(postStream, "findPostsByIds").returns(Promise.resolve([]));
|
||||
sinon.stub(postStream, "findPostsByIds").resolves([]);
|
||||
let post = postStream.store.createRecord("post", {
|
||||
id: 60,
|
||||
post_number: 60,
|
||||
|
@ -294,7 +293,7 @@ module("Unit | Model | post-stream", function () {
|
|||
|
||||
test("filterParticipant", function (assert) {
|
||||
const postStream = buildStream(1236);
|
||||
sinon.stub(postStream, "refresh").returns(Promise.resolve());
|
||||
sinon.stub(postStream, "refresh").resolves();
|
||||
|
||||
assert.strictEqual(
|
||||
postStream.get("userFilters.length"),
|
||||
|
@ -320,7 +319,7 @@ module("Unit | Model | post-stream", function () {
|
|||
store.createRecord("post", { id: 2, post_number: 3 })
|
||||
);
|
||||
|
||||
sinon.stub(postStream, "refresh").returns(Promise.resolve());
|
||||
sinon.stub(postStream, "refresh").resolves();
|
||||
|
||||
assert.strictEqual(
|
||||
postStream.get("filterRepliesToPostNumber"),
|
||||
|
@ -351,7 +350,7 @@ module("Unit | Model | post-stream", function () {
|
|||
store.createRecord("post", { id: 2, post_number: 3 })
|
||||
);
|
||||
|
||||
sinon.stub(postStream, "refresh").returns(Promise.resolve());
|
||||
sinon.stub(postStream, "refresh").resolves();
|
||||
|
||||
assert.strictEqual(
|
||||
postStream.get("filterUpwardsPostID"),
|
||||
|
@ -376,7 +375,7 @@ module("Unit | Model | post-stream", function () {
|
|||
|
||||
test("streamFilters", function (assert) {
|
||||
const postStream = buildStream(1237);
|
||||
sinon.stub(postStream, "refresh").returns(Promise.resolve());
|
||||
sinon.stub(postStream, "refresh").resolves();
|
||||
|
||||
assert.deepEqual(
|
||||
postStream.get("streamFilters"),
|
||||
|
@ -960,9 +959,7 @@ module("Unit | Model | post-stream", function () {
|
|||
username: "ignoreduser",
|
||||
});
|
||||
|
||||
let stub = sinon
|
||||
.stub(postStream, "findPostsByIds")
|
||||
.returns(Promise.resolve([post2]));
|
||||
let stub = sinon.stub(postStream, "findPostsByIds").resolves([post2]);
|
||||
|
||||
await postStream.triggerNewPostsInStream([101]);
|
||||
assert.strictEqual(
|
||||
|
@ -977,7 +974,7 @@ module("Unit | Model | post-stream", function () {
|
|||
);
|
||||
|
||||
stub.restore();
|
||||
sinon.stub(postStream, "findPostsByIds").returns(Promise.resolve([post3]));
|
||||
sinon.stub(postStream, "findPostsByIds").resolves([post3]);
|
||||
|
||||
await postStream.triggerNewPostsInStream([102]);
|
||||
assert.strictEqual(
|
||||
|
|
Loading…
Reference in New Issue
Block a user