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/integration/components/composer-editor-test.js
Bianca Nenciu 93859037ef
FEATURE: Improve composer warnings for mentions (#18796)
* FEATURE: Show warning if group cannot be mentioned

A similar warning is displayed when the user cannot be mentioned because
they have not been invited to the topic.

* FEATURE: Resolve mentions for new topic

This commit improves several improvements and refactors
/u/is_local_username route to a better /composer/mentions route that
can handle new topics too.

* FEATURE: Show warning if only some are notified

Sometimes users are still notified even if the group that was mentioned
was not invited to the message. This happens because its members were
invited directly or are members of other groups that were invited.

* DEV: Refactor _warnCannotSeeMention
2022-12-05 20:22:05 +02:00

47 lines
1.4 KiB
JavaScript

import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { fillIn, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
module("Integration | Component | ComposerEditor", function (hooks) {
setupRenderingTest(hooks);
test("warns about users that will not see a mention", async function (assert) {
assert.expect(2);
this.set("model", {});
this.set("noop", () => {});
this.set("expectation", (warning) => {
if (warning.name === "user-no") {
assert.deepEqual(warning, { name: "user-no", reason: "a reason" });
} else if (warning.name === "user-nope") {
assert.deepEqual(warning, { name: "user-nope", reason: "a reason" });
}
});
pretender.get("/composer/mentions", () => {
return response({
users: ["user-ok", "user-no", "user-nope"],
user_reasons: {
"user-no": "a reason",
"user-nope": "a reason",
},
groups: {},
group_reasons: {},
max_users_notified_per_group_mention: 100,
});
});
await render(hbs`
<ComposerEditor
@composer={{this.model}}
@afterRefresh={{this.noop}}
@cannotSeeMention={{this.expectation}}
/>
`);
await fillIn("textarea", "@user-no @user-ok @user-nope");
});
});