mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +08:00
DEV: fix tests
This commit is contained in:
parent
825fd9330d
commit
1f5f278b0e
|
@ -526,7 +526,7 @@ export default class ComposerEditor extends Component {
|
|||
// previously we would warn after @bob even if you were about to mention @bob2
|
||||
@debounce(DEBOUNCE_JIT_MS)
|
||||
_warnCannotSeeMention(preview) {
|
||||
if (this.composer.model.draftKey === Composer.NEW_PRIVATE_MESSAGE_KEY) {
|
||||
if (this.composer.model?.draftKey === Composer.NEW_PRIVATE_MESSAGE_KEY) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -907,7 +907,9 @@ export default class ComposerEditor extends Component {
|
|||
return this._selectedFormTemplateId;
|
||||
}
|
||||
|
||||
return this.composer.formTemplateId || this.composer.formTemplateIds?.[0];
|
||||
return (
|
||||
this.composer.model.formTemplateId || this.composer.formTemplateIds?.[0]
|
||||
);
|
||||
}
|
||||
|
||||
set selectedFormTemplateId(value) {
|
||||
|
|
|
@ -9,8 +9,6 @@ module("Integration | Component | ComposerEditor", function (hooks) {
|
|||
setupRenderingTest(hooks);
|
||||
|
||||
test("warns about users that will not see a mention", async function (assert) {
|
||||
const model = {};
|
||||
const noop = () => {};
|
||||
const expectation = (warning) => {
|
||||
if (warning.name === "user-no") {
|
||||
assert.deepEqual(warning, { name: "user-no", reason: "a reason" });
|
||||
|
@ -32,24 +30,24 @@ module("Integration | Component | ComposerEditor", function (hooks) {
|
|||
});
|
||||
});
|
||||
|
||||
await render(<template>
|
||||
<ComposerEditor
|
||||
@composer={{model}}
|
||||
@afterRefresh={{noop}}
|
||||
@cannotSeeMention={{expectation}}
|
||||
/>
|
||||
</template>);
|
||||
const originalComposerService = this.owner.lookup("service:composer");
|
||||
const composerMockClass = class ComposerMock extends originalComposerService.constructor {
|
||||
cannotSeeMention() {
|
||||
expectation(...arguments);
|
||||
}
|
||||
};
|
||||
this.owner.unregister("service:composer");
|
||||
this.owner.register("service:composer", new composerMockClass(this.owner), {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
await render(<template><ComposerEditor /></template>);
|
||||
|
||||
await fillIn("textarea", "@user-no @user-ok @user-nope");
|
||||
});
|
||||
|
||||
test("preview sanitizes HTML", async function (assert) {
|
||||
const model = {};
|
||||
const noop = () => {};
|
||||
|
||||
await render(<template>
|
||||
<ComposerEditor @composer={{model}} @afterRefresh={{noop}} />
|
||||
</template>);
|
||||
await render(<template><ComposerEditor /></template>);
|
||||
|
||||
await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`);
|
||||
assert.strictEqual(
|
||||
|
|
Loading…
Reference in New Issue
Block a user