DEV: Deprecate `controllerFor` test helper (#19606)

After all the test changes it was only used in a single place in core 🤷

(also updated the recommendation in `assert.not` deprecation message)
This commit is contained in:
Jarek Radosz 2022-12-23 11:33:42 +01:00 committed by GitHub
parent 64dcd44c94
commit 953b823c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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");

View File

@ -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",