mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 01:58:12 +08:00
DEV: Convert composer-editor tests to gjs (#23768)
This commit is contained in:
parent
d269018c16
commit
6271e02369
|
@ -1,23 +1,23 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { fillIn, render } from "@ember/test-helpers";
|
import { fillIn, render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import ComposerEditor from "discourse/components/composer-editor";
|
||||||
|
|
||||||
module("Integration | Component | ComposerEditor", function (hooks) {
|
module("Integration | Component | ComposerEditor", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("warns about users that will not see a mention", async function (assert) {
|
test("warns about users that will not see a mention", async function (assert) {
|
||||||
this.set("model", {});
|
const model = {};
|
||||||
this.set("noop", () => {});
|
const noop = () => {};
|
||||||
this.set("expectation", (warning) => {
|
const expectation = (warning) => {
|
||||||
if (warning.name === "user-no") {
|
if (warning.name === "user-no") {
|
||||||
assert.deepEqual(warning, { name: "user-no", reason: "a reason" });
|
assert.deepEqual(warning, { name: "user-no", reason: "a reason" });
|
||||||
} else if (warning.name === "user-nope") {
|
} else if (warning.name === "user-nope") {
|
||||||
assert.deepEqual(warning, { name: "user-nope", reason: "a reason" });
|
assert.deepEqual(warning, { name: "user-nope", reason: "a reason" });
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
pretender.get("/composer/mentions", () => {
|
pretender.get("/composer/mentions", () => {
|
||||||
return response({
|
return response({
|
||||||
|
@ -32,27 +32,24 @@ module("Integration | Component | ComposerEditor", function (hooks) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await render(hbs`
|
await render(<template>
|
||||||
<ComposerEditor
|
<ComposerEditor
|
||||||
@composer={{this.model}}
|
@composer={{model}}
|
||||||
@afterRefresh={{this.noop}}
|
@afterRefresh={{noop}}
|
||||||
@cannotSeeMention={{this.expectation}}
|
@cannotSeeMention={{expectation}}
|
||||||
/>
|
/>
|
||||||
`);
|
</template>);
|
||||||
|
|
||||||
await fillIn("textarea", "@user-no @user-ok @user-nope");
|
await fillIn("textarea", "@user-no @user-ok @user-nope");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("preview sanitizes HTML", async function (assert) {
|
test("preview sanitizes HTML", async function (assert) {
|
||||||
this.set("model", {});
|
const model = {};
|
||||||
this.set("noop", () => {});
|
const noop = () => {};
|
||||||
|
|
||||||
await render(hbs`
|
await render(<template>
|
||||||
<ComposerEditor
|
<ComposerEditor @composer={{model}} @afterRefresh={{noop}} />
|
||||||
@composer={{this.model}}
|
</template>);
|
||||||
@afterRefresh={{this.noop}}
|
|
||||||
/>
|
|
||||||
`);
|
|
||||||
|
|
||||||
await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`);
|
await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
Loading…
Reference in New Issue
Block a user