mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
REFACTOR: We can't use Ember.HTMLBars.compile in Ember CLI
Instead we use the inline `hbs` helper. Note in the non-Ember CLI version this will not actually inline compile, but it will still work for all our tests.
This commit is contained in:
@ -3,12 +3,11 @@ import { visit } from "@ember/test-helpers";
|
|||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import Ember from "ember";
|
import Ember from "ember";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
acceptance("CustomHTML template", function (needs) {
|
acceptance("CustomHTML template", function (needs) {
|
||||||
needs.hooks.beforeEach(() => {
|
needs.hooks.beforeEach(() => {
|
||||||
Ember.TEMPLATES["top"] = Ember.HTMLBars.compile(
|
Ember.TEMPLATES["top"] = hbs`<span class='top-span'>TOP</span>`;
|
||||||
`<span class='top-span'>TOP</span>`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
needs.hooks.afterEach(() => {
|
needs.hooks.afterEach(() => {
|
||||||
delete Ember.TEMPLATES["top"];
|
delete Ember.TEMPLATES["top"];
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
controllerFor,
|
controllerFor,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
acceptance("Modal", function (needs) {
|
acceptance("Modal", function (needs) {
|
||||||
let _translations;
|
let _translations;
|
||||||
@ -60,9 +61,9 @@ acceptance("Modal", function (needs) {
|
|||||||
"ESC should close the modal"
|
"ESC should close the modal"
|
||||||
);
|
);
|
||||||
|
|
||||||
Ember.TEMPLATES["modal/not-dismissable"] = Ember.HTMLBars.compile(
|
Ember.TEMPLATES[
|
||||||
'{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}'
|
"modal/not-dismissable"
|
||||||
);
|
] = hbs`{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}`;
|
||||||
|
|
||||||
run(() => showModal("not-dismissable", {}));
|
run(() => showModal("not-dismissable", {}));
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ acceptance("Modal", function (needs) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("rawTitle in modal panels", async function (assert) {
|
test("rawTitle in modal panels", async function (assert) {
|
||||||
Ember.TEMPLATES["modal/test-raw-title-panels"] = Ember.HTMLBars.compile("");
|
Ember.TEMPLATES["modal/test-raw-title-panels"] = hbs``;
|
||||||
const panels = [
|
const panels = [
|
||||||
{ id: "test1", rawTitle: "Test 1" },
|
{ id: "test1", rawTitle: "Test 1" },
|
||||||
{ id: "test2", rawTitle: "Test 2" },
|
{ id: "test2", rawTitle: "Test 2" },
|
||||||
@ -98,10 +99,10 @@ acceptance("Modal", function (needs) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("modal title", async function (assert) {
|
test("modal title", async function (assert) {
|
||||||
Ember.TEMPLATES["modal/test-title"] = Ember.HTMLBars.compile("");
|
Ember.TEMPLATES["modal/test-title"] = hbs``;
|
||||||
Ember.TEMPLATES["modal/test-title-with-body"] = Ember.HTMLBars.compile(
|
Ember.TEMPLATES[
|
||||||
"{{#d-modal-body}}test{{/d-modal-body}}"
|
"modal/test-title-with-body"
|
||||||
);
|
] = hbs`{{#d-modal-body}}test{{/d-modal-body}}`;
|
||||||
|
|
||||||
await visit("/");
|
await visit("/");
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import { test } from "qunit";
|
|||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { extraConnectorClass } from "discourse/lib/plugin-connectors";
|
import { extraConnectorClass } from "discourse/lib/plugin-connectors";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
const PREFIX = "javascripts/single-test/connectors";
|
const PREFIX = "javascripts/single-test/connectors";
|
||||||
|
|
||||||
@ -45,20 +46,16 @@ acceptance("Plugin Outlet - Connector Class", function (needs) {
|
|||||||
|
|
||||||
Ember.TEMPLATES[
|
Ember.TEMPLATES[
|
||||||
`${PREFIX}/user-profile-primary/hello`
|
`${PREFIX}/user-profile-primary/hello`
|
||||||
] = Ember.HTMLBars.compile(
|
] = hbs`<span class='hello-username'>{{model.username}}</span>
|
||||||
`<span class='hello-username'>{{model.username}}</span>
|
|
||||||
<button class='say-hello' {{action "sayHello"}}></button>
|
<button class='say-hello' {{action "sayHello"}}></button>
|
||||||
<span class='hello-result'>{{hello}}</span>`
|
<span class='hello-result'>{{hello}}</span>`;
|
||||||
);
|
|
||||||
Ember.TEMPLATES[
|
Ember.TEMPLATES[
|
||||||
`${PREFIX}/user-profile-primary/hi`
|
`${PREFIX}/user-profile-primary/hi`
|
||||||
] = Ember.HTMLBars.compile(
|
] = hbs`<button class='say-hi' {{action "sayHi"}}></button>
|
||||||
`<button class='say-hi' {{action "sayHi"}}></button>
|
<span class='hi-result'>{{hi}}</span>`;
|
||||||
<span class='hi-result'>{{hi}}</span>`
|
|
||||||
);
|
|
||||||
Ember.TEMPLATES[
|
Ember.TEMPLATES[
|
||||||
`${PREFIX}/user-profile-primary/dont-render`
|
`${PREFIX}/user-profile-primary/dont-render`
|
||||||
] = Ember.HTMLBars.compile(`I'm not rendered!`);
|
] = hbs`I'm not rendered!`;
|
||||||
});
|
});
|
||||||
|
|
||||||
needs.hooks.afterEach(() => {
|
needs.hooks.afterEach(() => {
|
||||||
|
@ -4,6 +4,7 @@ import { visit } from "@ember/test-helpers";
|
|||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
const PREFIX = "javascripts/single-test/connectors";
|
const PREFIX = "javascripts/single-test/connectors";
|
||||||
|
|
||||||
@ -11,12 +12,8 @@ acceptance("Plugin Outlet - Decorator", function (needs) {
|
|||||||
needs.user();
|
needs.user();
|
||||||
|
|
||||||
needs.hooks.beforeEach(() => {
|
needs.hooks.beforeEach(() => {
|
||||||
Ember.TEMPLATES[
|
Ember.TEMPLATES[`${PREFIX}/discovery-list-container-top/foo`] = hbs`FOO`;
|
||||||
`${PREFIX}/discovery-list-container-top/foo`
|
Ember.TEMPLATES[`${PREFIX}/discovery-list-container-top/bar`] = hbs`BAR`;
|
||||||
] = Ember.HTMLBars.compile("FOO");
|
|
||||||
Ember.TEMPLATES[
|
|
||||||
`${PREFIX}/discovery-list-container-top/bar`
|
|
||||||
] = Ember.HTMLBars.compile("BAR");
|
|
||||||
|
|
||||||
withPluginApi("0.8.38", (api) => {
|
withPluginApi("0.8.38", (api) => {
|
||||||
api.decoratePluginOutlet(
|
api.decoratePluginOutlet(
|
||||||
|
@ -3,6 +3,7 @@ import { visit } from "@ember/test-helpers";
|
|||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { clearCache } from "discourse/lib/plugin-connectors";
|
import { clearCache } from "discourse/lib/plugin-connectors";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
const HELLO = "javascripts/multi-test/connectors/user-profile-primary/hello";
|
const HELLO = "javascripts/multi-test/connectors/user-profile-primary/hello";
|
||||||
const GOODBYE =
|
const GOODBYE =
|
||||||
@ -11,12 +12,8 @@ const GOODBYE =
|
|||||||
acceptance("Plugin Outlet - Multi Template", function (needs) {
|
acceptance("Plugin Outlet - Multi Template", function (needs) {
|
||||||
needs.hooks.beforeEach(() => {
|
needs.hooks.beforeEach(() => {
|
||||||
clearCache();
|
clearCache();
|
||||||
Ember.TEMPLATES[HELLO] = Ember.HTMLBars.compile(
|
Ember.TEMPLATES[HELLO] = hbs`<span class='hello-span'>Hello</span>`;
|
||||||
`<span class='hello-span'>Hello</span>`
|
Ember.TEMPLATES[GOODBYE] = hbs`<span class='bye-span'>Goodbye</span>`;
|
||||||
);
|
|
||||||
Ember.TEMPLATES[GOODBYE] = Ember.HTMLBars.compile(
|
|
||||||
`<span class='bye-span'>Goodbye</span>`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
needs.hooks.afterEach(() => {
|
needs.hooks.afterEach(() => {
|
||||||
|
@ -2,15 +2,16 @@ import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
|||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import hbs from "htmlbars-inline-precompile";
|
||||||
|
|
||||||
const CONNECTOR =
|
const CONNECTOR =
|
||||||
"javascripts/single-test/connectors/user-profile-primary/hello";
|
"javascripts/single-test/connectors/user-profile-primary/hello";
|
||||||
|
|
||||||
acceptance("Plugin Outlet - Single Template", function (needs) {
|
acceptance("Plugin Outlet - Single Template", function (needs) {
|
||||||
needs.hooks.beforeEach(() => {
|
needs.hooks.beforeEach(() => {
|
||||||
Ember.TEMPLATES[CONNECTOR] = Ember.HTMLBars.compile(
|
Ember.TEMPLATES[
|
||||||
`<span class='hello-username'>{{model.username}}</span>`
|
CONNECTOR
|
||||||
);
|
] = hbs`<span class='hello-username'>{{model.username}}</span>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
needs.hooks.afterEach(() => {
|
needs.hooks.afterEach(() => {
|
||||||
|
@ -17,6 +17,14 @@ define("ember-qunit", () => {
|
|||||||
moduleForComponent: window.moduleForComponent,
|
moduleForComponent: window.moduleForComponent,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
define("htmlbars-inline-precompile", () => {
|
||||||
|
return {
|
||||||
|
default: function (str) {
|
||||||
|
return Ember.HTMLBars.compile(str[0]);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
let _app;
|
let _app;
|
||||||
define("@ember/test-helpers", () => {
|
define("@ember/test-helpers", () => {
|
||||||
let helpers = {
|
let helpers = {
|
||||||
|
Reference in New Issue
Block a user