A platform for community discussion. Free, open, simple.
FIX: Modal methods should be wired up in `setupTests` not in module
Robin Ward625cf5a8ae4a
diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.jsindex c1c45225746..7776186da1e 100644--- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js@@ -32,7 +32,6 @@ import { getOwner } from "discourse-common/lib/get-owner";import { setTopicList } from "discourse/lib/topic-list-tracker";import { setURLContainer } from "discourse/lib/url";import { setDefaultOwner } from "discourse-common/lib/get-owner";-import bootbox from "bootbox";import { moduleFor } from "ember-qunit";import QUnit, { module } from "qunit";import siteFixtures from "discourse/tests/fixtures/site-fixtures";@@ -68,36 +67,6 @@ export function fakeTime(timeString, timezone = null, advanceTime = false) {});}-const Plugin = $.fn.modal;-const Modal = Plugin.Constructor;--function AcceptanceModal(option, _relatedTarget) {- return this.each(function () {- var $this = $(this);- var data = $this.data("bs.modal");- var options = $.extend(- {},- Modal.DEFAULTS,- $this.data(),- typeof option === "object" && option- );-- if (!data) {- $this.data("bs.modal", (data = new Modal(this, options)));- }- data.$body = $("#ember-testing");-- if (typeof option === "string") {- data[option](_relatedTarget);- } else if (options.show) {- data.show(_relatedTarget);- }- });-}--bootbox.$body = $("#ember-testing");-$.fn.modal = AcceptanceModal;-let _pretenderCallbacks = {};export function resetSite(siteSettings, extras) {diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.jsindex efa8b2baf86..d4405bc2a80 100644--- a/app/assets/javascripts/discourse/tests/setup-tests.js+++ b/app/assets/javascripts/discourse/tests/setup-tests.js@@ -26,6 +26,34 @@ import MessageBus from "message-bus-client";import deprecated from "discourse-common/lib/deprecated";import sinon from "sinon";import { setApplication, setResolver } from "@ember/test-helpers";+import bootbox from "bootbox";++const Plugin = $.fn.modal;+const Modal = Plugin.Constructor;++function AcceptanceModal(option, _relatedTarget) {+ return this.each(function () {+ var $this = $(this);+ var data = $this.data("bs.modal");+ var options = $.extend(+ {},+ Modal.DEFAULTS,+ $this.data(),+ typeof option === "object" && option+ );++ if (!data) {+ $this.data("bs.modal", (data = new Modal(this, options)));+ }+ data.$body = $("#ember-testing");++ if (typeof option === "string") {+ data[option](_relatedTarget);+ } else if (options.show) {+ data.show(_relatedTarget);+ }+ });+}export default function setupTests(app, container) {setResolver(buildResolver("discourse").create({ namespace: app }));@@ -45,6 +73,8 @@ export default function setupTests(app, container) {app.setupForTesting();app.SiteSettings = currentSettings();app.start();+ bootbox.$body = $("#ember-testing");+ $.fn.modal = AcceptanceModal;// disable logster error reportingif (window.Logster) {