A platform for community discussion. Free, open, simple.
FIX: Default parameter recipients to create new message via params must be a string (#22455)
Sérgio Saquetim657c1023fd09
diff --git a/app/assets/javascripts/discourse/app/mixins/open-composer.js b/app/assets/javascripts/discourse/app/mixins/open-composer.jsindex dac088ce906..68dd5f71c5e 100644--- a/app/assets/javascripts/discourse/app/mixins/open-composer.js+++ b/app/assets/javascripts/discourse/app/mixins/open-composer.js@@ -59,7 +59,7 @@ export default Mixin.create({},openComposerWithMessageParams({- recipients = [],+ recipients = "",topicTitle = "",topicBody = "",hasGroups = false,diff --git a/app/assets/javascripts/discourse/app/routes/application.js b/app/assets/javascripts/discourse/app/routes/application.jsindex a2fe0b99f50..eb5e1a19b4c 100644--- a/app/assets/javascripts/discourse/app/routes/application.js+++ b/app/assets/javascripts/discourse/app/routes/application.js@@ -213,7 +213,7 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {},createNewMessageViaParams({- recipients = [],+ recipients = "",topicTitle = "",topicBody = "",hasGroups = false,diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.jsindex 16f59a1d182..b864e19ecca 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-messages-test.js@@ -11,6 +11,7 @@ import {waitUntil,} from "@ember/test-helpers";import { test } from "qunit";+import selectKit from "discourse/tests/helpers/select-kit-helper";import I18n from "I18n";import pretender, { response } from "../helpers/create-pretender";@@ -160,3 +161,118 @@ acceptance("Composer - Messages - Duplicate links", function (needs) {.exists("shows composer warning message");});});++acceptance("Composer - Messages - Private Messages", function (needs) {+ needs.user({+ id: 32,+ username: "codinghorror",+ });++ needs.pretender((server, helper) => {+ server.get("/composer_messages/user_not_seen_in_a_while", () => {+ return helper.response({});+ });++ server.get("/u/search/users", () =>+ response({+ users: [+ {+ username: "codinghorror",+ },+ {+ username: "sam",+ },+ ],+ })+ );+ });++ test("Shows warning in the composer if the user is sending a message only to himself", async function (assert) {+ await visit("/new-message");++ const privateMessageUsers = selectKit("#private-message-users");++ assert.strictEqual(+ privateMessageUsers.header().value(),+ null,+ "target recipients are empty"+ );++ // Since we are activating the composer via the route /new-message, it was initialized with+ // default values. Filling the input before assigning the target recipient of the message+ // also ensures that the popup test is executed correctly when targetRecipients is empty.+ await fillIn("#reply-title", "Private message test title");+ await triggerKeyEvent(".d-editor-input", "keyup", "Space");++ assert.false(+ exists(".composer-popup"),+ "composer warning is not shown if the target recipients are empty"+ );++ // filling the input with the username of the current user+ await privateMessageUsers.expand();+ await privateMessageUsers.fillInFilter("codinghorror");+ await privateMessageUsers.selectRowByValue("codinghorror");+ await privateMessageUsers.collapse();++ await triggerKeyEvent(".d-editor-input", "keyup", "Space");++ assert.true(exists(".composer-popup"), "shows composer warning message");+ assert.true(+ query(".composer-popup").innerHTML.includes(+ I18n.t("composer.yourself_confirm.title")+ ),+ "warning message has correct title"+ );+ assert.true(+ query(".composer-popup").innerHTML.includes(+ I18n.t("composer.yourself_confirm.body")+ ),+ "warning message has correct body"+ );+ });++ test("Does not show a warning in the composer if the message is sent to other users", async function (assert) {+ await visit("/new-message");++ const privateMessageUsers = selectKit("#private-message-users");++ assert.strictEqual(+ privateMessageUsers.header().value(),+ null,+ "target recipients are empty"+ );++ // Since we are activating the composer via the route /new-message, it was initialized with+ // default values. Filling the input before assigning the target recipient of the message+ // also ensures that the popup test is executed correctly when targetRecipients is empty.+ await fillIn("#reply-title", "Private message test title");+ await triggerKeyEvent(".d-editor-input", "keyup", "Space");++ assert.false(+ exists(".composer-popup"),+ "composer warning is not shown if the target recipients are empty"+ );++ // filling the input with the username of another user+ await privateMessageUsers.expand();+ await privateMessageUsers.fillInFilter("sam");+ await privateMessageUsers.selectRowByValue("sam");+ await privateMessageUsers.collapse();++ await triggerKeyEvent(".d-editor-input", "keyup", "Space");+ assert.false(exists(".composer-popup"), "do not show it for other user");++ // filling the input with the username of the current user+ await privateMessageUsers.expand();+ await privateMessageUsers.fillInFilter("codinghorror");+ await privateMessageUsers.selectRowByValue("codinghorror");+ await privateMessageUsers.collapse();++ await triggerKeyEvent(".d-editor-input", "keyup", "Space");+ assert.false(+ exists(".composer-popup"),+ "do not show it when the current user is just one of the target recipients"+ );+ });+});