PluginConnector remains a Classic Component, so this commit does not require any changes from plugin/theme developers. Two shims are introduced for backwards compatibility: - The component variable passed to shouldRender is replaced with a helperContext instance which includes all the common injections (the new PluginOutlet component instance does not have any of these) - A custom component manager is introduced so that parentView continues to work. Using parentView was never really intended as an API, so it's now deprecated and will print a warning to the console. Users should switch to using the outlet's explicit arguments, or data from a service (e.g. the Router service).
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
|
import { hbs } from "ember-cli-htmlbars";
|
|
import { test } from "qunit";
|
|
import { visit } from "@ember/test-helpers";
|
|
import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated";
|
|
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
|
|
|
acceptance("Plugin Outlet - Deprecated parentView", function (needs) {
|
|
needs.hooks.beforeEach(function () {
|
|
registerTemporaryModule(
|
|
"discourse/templates/connectors/user-profile-primary/hello",
|
|
hbs`<span class='hello-username'>{{parentView.parentView.class}}</span>`
|
|
);
|
|
});
|
|
|
|
test("Can access parentview", async function (assert) {
|
|
await withSilencedDeprecationsAsync(
|
|
"discourse.plugin-outlet-parent-view",
|
|
async () => {
|
|
await visit("/u/eviltrout");
|
|
assert.strictEqual(
|
|
query(".hello-username").innerText,
|
|
"user-main",
|
|
"it renders a value from parentView.parentView"
|
|
);
|
|
}
|
|
);
|
|
});
|
|
});
|