This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js
David Taylor c139767055
DEV: Remove Ember.TEMPLATES and centralize template resolution rules (#19220)
In the past, the result of template compilation would be stored directly in `Ember.TEMPLATES`. Following the move to more modern ember-cli-based compilation, templates are now compiled to es6 modules. To handle forward/backwards compatibility during these changes we had logic in `discourse-boot` which would extract templates from the es6 modules and store them into the legacy-style `Ember.TEMPLATES` object.

This commit removes that shim, and updates our resolver to fetch templates directly from es6 modules. This is closer to how 'vanilla' Ember handles template resolution. We still have a lot of discourse-specific logic, but now it is centralised in one location and should be easier to understand and normalize in future.

This commit should not introduce any behaviour change.
2022-11-29 10:24:35 +00:00

46 lines
1.3 KiB
JavaScript

import {
acceptance,
count,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { hbs } from "ember-cli-htmlbars";
import { test } from "qunit";
import { visit } from "@ember/test-helpers";
import { registerTemplateModule } from "../helpers/template-module-helper";
const HELLO =
"discourse/plugins/my-plugin/templates/connectors/user-profile-primary/hello";
const GOODBYE =
"discourse/plugins/my-plugin/templates/connectors/user-profile-primary/goodbye";
acceptance("Plugin Outlet - Multi Template", function (needs) {
needs.hooks.beforeEach(() => {
registerTemplateModule(HELLO, hbs`<span class='hello-span'>Hello</span>`);
registerTemplateModule(GOODBYE, hbs`<span class='bye-span'>Goodbye</span>`);
});
test("Renders a template into the outlet", async function (assert) {
await visit("/u/eviltrout");
assert.strictEqual(
count(".user-profile-primary-outlet.hello"),
1,
"it has class names"
);
assert.strictEqual(
count(".user-profile-primary-outlet.goodbye"),
1,
"it has class names"
);
assert.strictEqual(
query(".hello-span").innerText,
"Hello",
"it renders into the outlet"
);
assert.strictEqual(
query(".bye-span").innerText,
"Goodbye",
"it renders into the outlet"
);
});
});