Files
David TaylorandGitHub 666b5dddde DEV: Move discourse-common/(utils|lib) to discourse/lib (#30733)
`discourse-common` was created in the past to share logic between the
'wizard' app and the main 'discourse' app. Since then, the wizard has
been consolidated into the main app, so the separation of
`discourse-common` is no longer useful.

This commit moves `discourse-common/(lib|utils)/*` into
`discourse/lib/*`, adds shims for the imports, and updates existing
uses in core.
2025-01-13 13:02:49 +00:00

50 lines
1.3 KiB
JavaScript

import { getOwner } from "@ember/owner";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { withSilencedDeprecations } from "discourse/lib/deprecated";
import Site from "discourse/models/site";
import User from "discourse/models/user";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Acceptance | Globals", function () {
test("Globals function as expected", async function (assert) {
await visit("/");
assert.notStrictEqual(
window.Discourse,
undefined,
"window.Discourse is present"
);
assert.strictEqual(
window.Discourse,
getOwner(this),
"matches the expected application instance"
);
withSilencedDeprecations("discourse.global.user", () => {
assert.strictEqual(
window.Discourse.User,
User,
"Deprecated User alias is present"
);
});
withSilencedDeprecations("discourse.global.site", () => {
assert.strictEqual(
window.Discourse.Site,
Site,
"Deprecated Site alias is present"
);
});
withSilencedDeprecations("discourse.global.site-settings", () => {
assert.strictEqual(
window.Discourse.SiteSettings,
getOwner(this).lookup("service:site-settings"),
"Deprecated SiteSettings alias is present"
);
});
});
});