DEV: fix tests

This commit is contained in:
Renato Atilio 2024-11-06 23:00:22 -03:00
parent 825fd9330d
commit 1f5f278b0e
No known key found for this signature in database
GPG Key ID: CBF93DCB5CBCA1A5
2 changed files with 17 additions and 17 deletions

View File

@ -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) {

View File

@ -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(