From 953b823c5a134d247cade81fc4f2b79e4326ea31 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Fri, 23 Dec 2022 11:33:42 +0100 Subject: [PATCH] DEV: Deprecate `controllerFor` test helper (#19606) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After all the test changes it was only used in a single place in core 🤷 (also updated the recommendation in `assert.not` deprecation message) --- .../discourse/tests/acceptance/modal-test.js | 4 ++-- .../discourse/tests/helpers/qunit-helpers.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js index 79f31319c4e..91fc61547b1 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js @@ -1,6 +1,5 @@ import { acceptance, - controllerFor, count, exists, query, @@ -11,6 +10,7 @@ import I18n from "I18n"; import { hbs } from "ember-cli-htmlbars"; import showModal from "discourse/lib/show-modal"; import { registerTemporaryModule } from "../helpers/temporary-module-helper"; +import { getOwner } from "discourse-common/lib/get-owner"; acceptance("Modal", function (needs) { let _translations; @@ -38,7 +38,7 @@ acceptance("Modal", function (needs) { await click(".login-button"); assert.strictEqual(count(".d-modal:visible"), 1, "modal should appear"); - let controller = controllerFor("modal"); + const controller = getOwner(this).lookup("controller:modal"); assert.strictEqual(controller.name, "login"); await click(".modal-outer-container"); diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index b4d49f2f6dc..79d7b6453ef 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -397,6 +397,14 @@ export function acceptance(name, optionsOrCallback) { } export function controllerFor(controller, model) { + deprecated( + 'controllerFor is deprecated. Use the standard `getOwner(this).lookup("controller:NAME")` instead', + { + id: "controller-for", + since: "3.0.0.beta14", + } + ); + controller = getOwner(this).lookup("controller:" + controller); if (model) { controller.set("model", model); @@ -412,7 +420,7 @@ export function fixture(selector) { } QUnit.assert.not = function (actual, message) { - deprecated("assert.not() is deprecated. Use assert.notOk() instead.", { + deprecated("assert.not() is deprecated. Use assert.false() instead.", { since: "2.9.0.beta1", dropFrom: "2.10.0.beta1", id: "discourse.qunit.assert-not",