Revert Ember.run refactors

This reverts commit 5ca60fcb6b592524086f98279d3e4fd949598343.
This commit is contained in:
Robin Ward
2019-10-29 17:10:47 -04:00
parent cfa5d123a3
commit fcb1ca52f9
153 changed files with 319 additions and 493 deletions

View File

@ -1,4 +1,3 @@
import { run } from "@ember/runloop";
import selectKit from "helpers/select-kit-helper";
import { acceptance } from "helpers/qunit-helpers";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
@ -85,7 +84,7 @@ QUnit.test("Tests the Composer controls", async assert => {
event[mac ? "metaKey" : "ctrlKey"] = true;
event.keyCode = 66;
run(() => textarea.dispatchEvent(event));
Ember.run(() => textarea.dispatchEvent(event));
const example = I18n.t(`composer.bold_text`);
assert.equal(

View File

@ -1,4 +1,3 @@
import { run } from "@ember/runloop";
import { acceptance, controllerFor } from "helpers/qunit-helpers";
import showModal from "discourse/lib/show-modal";
@ -38,7 +37,7 @@ QUnit.test("modal", async function(assert) {
'{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}'
);
run(() => showModal("not-dismissable", {}));
Ember.run(() => showModal("not-dismissable", {}));
assert.ok(find(".d-modal:visible").length === 1, "modal should appear");

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import componentTest from "helpers/component-test";
import { withPluginApi } from "discourse/lib/plugin-api";
import formatTextWithSelection from "helpers/d-editor-helper";
@ -748,7 +747,7 @@ composerTestCase("replace-text event for composer", async function(assert) {
.lookup("service:app-events")
.trigger("composer:replace-text", "green", "yellow", { forceFocus: true });
next(() => {
Ember.run.next(() => {
let expect = formatTextWithSelection(AFTER, CASE.after);
let actual = formatTextWithSelection(
this.value,

View File

@ -1,5 +1,4 @@
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import Topic from "discourse/models/topic";
import PostStream from "discourse/models/post-stream";
import { Placeholder } from "discourse/lib/posts-with-placeholders";
@ -546,7 +545,7 @@ QUnit.test(
const done = assert.async();
controller.send("deletePost", post);
next(() => {
Ember.run.next(() => {
assert.ok(destroyed, "post was destroyed");
done();
});

View File

@ -1,5 +1,3 @@
import { run } from "@ember/runloop";
import { later } from "@ember/runloop";
/* global QUnit, resetSite */
import sessionFixtures from "fixtures/session-fixtures";
@ -157,7 +155,7 @@ export function controllerFor(controller, model) {
export function asyncTestDiscourse(text, func) {
QUnit.test(text, function(assert) {
const done = assert.async();
run(() => {
Ember.run(() => {
func.call(this, assert);
done();
});
@ -208,7 +206,7 @@ export function waitFor(assert, callback, timeout) {
timeout = timeout || 500;
const done = assert.async();
later(() => {
Ember.run.later(() => {
callback();
done();
}, timeout);

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
import { fixture, logIn } from "helpers/qunit-helpers";
@ -174,7 +173,7 @@ QUnit.skip("restores the href after a while", async assert => {
assert.timeout(75);
const done = assert.async();
later(() => {
Ember.run.later(() => {
assert.equal(fixture("a").attr("href"), "http://www.google.com");
done();
});

View File

@ -1,9 +1,8 @@
import { run } from "@ember/runloop";
import createStore from "helpers/create-store";
QUnit.module("Discourse.NavItem", {
beforeEach() {
run(function() {
Ember.run(function() {
const asianCategory = Discourse.Category.create({
name: "确实是这样",
id: 343434

View File

@ -73,7 +73,8 @@ if (window.Logster) {
window.Logster = { enabled: false };
}
var pretender = require("helpers/create-pretender", null, null, false),
var origDebounce = Ember.run.debounce,
pretender = require("helpers/create-pretender", null, null, false),
fixtures = require("fixtures/site-fixtures", null, null, false).default,
flushMap = require("discourse/models/store", null, null, false).flushMap,
ScrollingDOMMethods = require("discourse/mixins/scrolling", null, null, false)
@ -136,9 +137,15 @@ QUnit.testStart(function(ctx) {
// Unless we ever need to test this, let's leave it off.
$.fn.autocomplete = function() {};
// Don't debounce in test unless we're testing debouncing
if (ctx.module.indexOf("debounce") === -1) {
Ember.run.debounce = Ember.run;
}
});
QUnit.testDone(function() {
Ember.run.debounce = origDebounce;
window.sandbox.restore();
// Destroy any modals

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import { moduleForWidget, widgetTest } from "helpers/widget-test";
import { createWidget } from "discourse/widgets/widget";
import { withPluginApi } from "discourse/lib/plugin-api";
@ -160,7 +159,7 @@ widgetTest("widget update with promise", {
click() {
return new Ember.RSVP.Promise(resolve => {
next(() => {
Ember.run.next(() => {
this.state.name = "Robin";
resolve();
});