DEV: Remove reply_as_private_message from composer (#16979)

* Remove 'New Message' option from composer dropdown
* Update Acceptance Tests
This commit is contained in:
Isaac Janzen 2022-06-06 15:10:34 -05:00 committed by GitHub
parent d7bc395182
commit 49415de3fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 113 additions and 144 deletions

View File

@ -2,7 +2,6 @@ import {
acceptance,
count,
exists,
query,
queryAll,
selectText,
updateCurrentUser,
@ -16,6 +15,8 @@ import selectKit from "discourse/tests/helpers/select-kit-helper";
import sinon from "sinon";
import { test } from "qunit";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
import userFixtures from "discourse/tests/fixtures/user-fixtures";
import { cloneJSON } from "discourse-common/lib/object";
acceptance("Composer Actions", function (needs) {
needs.user();
@ -25,25 +26,9 @@ acceptance("Composer Actions", function (needs) {
enable_whispers: true,
});
needs.site({ can_tag_topics: true });
test("creating new topic and then reply_as_private_message keeps attributes", async function (assert) {
await visit("/");
await click("button#create-topic");
await fillIn("#reply-title", "this is the title");
await fillIn(".d-editor-input", "this is the reply");
const composerActions = selectKit(".composer-actions");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
assert.ok(queryAll("#reply-title").val(), "this is the title");
assert.ok(queryAll(".d-editor-input").val(), "this is the reply");
await click("#reply-control a.cancel");
assert.ok(
exists(".discard-draft-modal.modal"),
"it pops up the discard drafts modal"
);
needs.pretender((server, helper) => {
const cardResponse = cloneJSON(userFixtures["/u/shade/card.json"]);
server.get("/u/shade/card.json", () => helper.response(cardResponse));
});
test("replying to post", async function (assert) {
@ -57,34 +42,13 @@ acceptance("Composer Actions", function (needs) {
composerActions.rowByIndex(0).value(),
"reply_as_new_topic"
);
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "toggle_whisper");
assert.strictEqual(
composerActions.rowByIndex(1).value(),
"reply_as_private_message"
);
assert.strictEqual(composerActions.rowByIndex(2).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.strictEqual(
composerActions.rowByIndex(4).value(),
composerActions.rowByIndex(3).value(),
"toggle_topic_bump"
);
assert.strictEqual(composerActions.rowByIndex(5).value(), null);
});
test("replying to post - reply_as_private_message", async function (assert) {
const composerActions = selectKit(".composer-actions");
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
const privateMessageUsers = selectKit("#private-message-users");
assert.strictEqual(privateMessageUsers.header().value(), "codinghorror");
assert.ok(
queryAll(".d-editor-input").val().indexOf("Continuing the discussion") >=
0
);
assert.strictEqual(composerActions.rowByIndex(4).value(), null);
});
test("replying to post - reply_to_topic", async function (assert) {
@ -199,28 +163,6 @@ acceptance("Composer Actions", function (needs) {
assert.deepEqual(privateMessageUsers.header().value(), "foo,foo_group");
});
test("allow switching back to New Topic", async function (assert) {
await visit("/");
await click("button#create-topic");
const composerActions = selectKit(".composer-actions");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
assert.strictEqual(
query(".action-title").innerText,
I18n.t("topic.private_message")
);
await composerActions.expand();
await composerActions.selectRowByValue("create_topic");
assert.strictEqual(
query(".action-title").innerText,
I18n.t("topic.create_long")
);
});
test("interactions", async function (assert) {
const composerActions = selectKit(".composer-actions");
const quote = "Life is like riding a bicycle.";
@ -244,16 +186,12 @@ acceptance("Composer Actions", function (needs) {
"reply_as_new_topic"
);
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_post");
assert.strictEqual(composerActions.rowByIndex(2).value(), "toggle_whisper");
assert.strictEqual(
composerActions.rowByIndex(2).value(),
"reply_as_private_message"
);
assert.strictEqual(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.strictEqual(
composerActions.rowByIndex(4).value(),
composerActions.rowByIndex(3).value(),
"toggle_topic_bump"
);
assert.strictEqual(composerActions.rows().length, 5);
assert.strictEqual(composerActions.rows().length, 4);
await composerActions.selectRowByValue("reply_to_post");
await composerActions.expand();
@ -268,17 +206,13 @@ acceptance("Composer Actions", function (needs) {
composerActions.rowByIndex(0).value(),
"reply_as_new_topic"
);
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "toggle_whisper");
assert.strictEqual(
composerActions.rowByIndex(1).value(),
"reply_as_private_message"
);
assert.strictEqual(composerActions.rowByIndex(2).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.strictEqual(
composerActions.rowByIndex(4).value(),
composerActions.rowByIndex(3).value(),
"toggle_topic_bump"
);
assert.strictEqual(composerActions.rows().length, 5);
assert.strictEqual(composerActions.rows().length, 4);
await composerActions.selectRowByValue("reply_as_new_topic");
await composerActions.expand();
@ -289,32 +223,25 @@ acceptance("Composer Actions", function (needs) {
);
assert.ok(queryAll(".d-editor-input").val().includes(quote));
assert.strictEqual(composerActions.rowByIndex(0).value(), "reply_to_post");
assert.strictEqual(
composerActions.rowByIndex(1).value(),
"reply_as_private_message"
);
assert.strictEqual(composerActions.rowByIndex(2).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(3).value(), "shared_draft");
assert.strictEqual(composerActions.rows().length, 4);
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "shared_draft");
assert.strictEqual(composerActions.rows().length, 3);
});
await composerActions.selectRowByValue("reply_as_private_message");
test("interactions - private message", async function (assert) {
const composerActions = selectKit(".composer-actions");
await visit("/t/internationalization-localization/280");
await click('#post_4 a[data-user-card="shade"]');
await click(".usercard-controls .compose-pm .btn-primary");
await composerActions.expand();
assert.strictEqual(
queryAll(".action-title").text().trim(),
I18n.t("topic.private_message")
);
assert.ok(
queryAll(".d-editor-input").val().indexOf("Continuing the discussion") ===
0
);
assert.strictEqual(
composerActions.rowByIndex(0).value(),
"reply_as_new_topic"
);
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_post");
assert.strictEqual(composerActions.rowByIndex(2).value(), "reply_to_topic");
assert.strictEqual(composerActions.rows().length, 3);
assert.strictEqual(composerActions.rowByIndex(0).value(), "create_topic");
assert.strictEqual(composerActions.rows().length, 1);
});
test("replying to post - toggle_topic_bump", async function (assert) {
@ -409,9 +336,9 @@ acceptance("Composer Actions", function (needs) {
await click("article#post_3 button.reply");
await composerActions.expand();
assert.strictEqual(composerActions.rows().length, 5);
assert.strictEqual(composerActions.rows().length, 4);
assert.strictEqual(
composerActions.rowByIndex(4).value(),
composerActions.rowByIndex(3).value(),
"toggle_topic_bump"
);
});
@ -424,7 +351,7 @@ acceptance("Composer Actions", function (needs) {
await click("article#post_3 button.reply");
await composerActions.expand();
assert.strictEqual(composerActions.rows().length, 3);
assert.strictEqual(composerActions.rows().length, 2);
Array.from(composerActions.rows()).forEach((row) => {
assert.notStrictEqual(
row.value,
@ -442,30 +369,13 @@ acceptance("Composer Actions", function (needs) {
await click("article#post_3 button.reply");
await composerActions.expand();
assert.strictEqual(composerActions.rows().length, 4);
assert.strictEqual(composerActions.rows().length, 3);
assert.strictEqual(
composerActions.rowByIndex(3).value(),
composerActions.rowByIndex(2).value(),
"toggle_topic_bump"
);
});
test("replying to first post - reply_as_private_message", async function (assert) {
const composerActions = selectKit(".composer-actions");
await visit("/t/internationalization-localization/280");
await click("article#post_1 button.reply");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
const privateMessageUsers = selectKit("#private-message-users");
assert.strictEqual(privateMessageUsers.header().value(), "uwe_keim");
assert.ok(
queryAll(".d-editor-input").val().indexOf("Continuing the discussion") >=
0
);
});
test("editing post", async function (assert) {
const composerActions = selectKit(".composer-actions");

View File

@ -701,7 +701,7 @@ acceptance("Composer", function (needs) {
const composerActions = selectKit(".composer-actions");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
await composerActions.selectRowByValue("reply_as_new_topic");
assert.ok(!exists(".modal-body"), "abandon popup shouldn't come");

View File

@ -2825,6 +2825,85 @@ export default {
featured_user_badge_ids: [17],
},
},
"/u/shade/card.json": {
user_badges: [
{
id: 17,
granted_at: "2019-03-06T19:08:28.230Z",
count: 1,
badge_id: 3,
user_id: 5,
granted_by_id: -1,
},
],
badges: [
{
id: 3,
name: "Regular",
description:
'<a href="https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/">Granted</a> recategorize, rename, followed links, wiki, more likes',
grant_count: 3,
allow_title: true,
multiple_grant: false,
icon: "fa-user",
image: null,
listable: true,
enabled: true,
badge_grouping_id: 4,
system: true,
slug: "regular",
manually_grantable: false,
badge_type_id: 2,
},
],
badge_types: [{ id: 2, name: "Silver", sort_order: 8 }],
users: [
{
id: 10,
username: "shade",
name: null,
avatar_template: "/letter_avatar_proxy/v3/letter/s/d6d6ee/{size}.png",
moderator: false,
admin: false,
},
{
id: -1,
username: "system",
name: "system",
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png",
moderator: true,
admin: true,
},
],
user: {
id: 10,
username: "shade",
name: null,
avatar_template: "/letter_avatar_proxy/v3/letter/s/d6d6ee/{size}.png",
last_posted_at: null,
last_seen_at: null,
created_at: "2019-03-06T19:06:20.340Z",
ignored: false,
can_ignore_user: false,
can_send_private_messages: true,
can_send_private_message_to_user: true,
trust_level: 3,
moderator: false,
admin: false,
title: null,
badge_count: 3,
custom_fields: {},
time_read: 0,
recent_time_read: 0,
primary_group_name: null,
flair_name: null,
flair_url: null,
flair_bg_color: null,
flair_color: null,
staged: false,
featured_user_badge_ids: [17],
},
},
"/u/charlie/summary.json": {
topics: [],
badges: [

View File

@ -160,23 +160,6 @@ export default DropdownSelectBoxComponent.extend({
});
}
if (
this.siteSettings.enable_personal_messages &&
this.action !== PRIVATE_MESSAGE &&
!this.isEditing
) {
items.push({
name: I18n.t(
"composer.composer_actions.reply_as_private_message.label"
),
description: I18n.t(
"composer.composer_actions.reply_as_private_message.desc"
),
icon: "envelope",
id: "reply_as_private_message",
});
}
if (
!this.isEditing &&
((this.action !== REPLY && _topicSnapshot) ||

View File

@ -2273,9 +2273,6 @@ en:
reply_as_new_group_message:
label: Reply as new group message
desc: Create new message starting with same recipients
reply_as_private_message:
label: New message
desc: Create a new personal message
reply_to_topic:
label: Reply to topic
desc: Reply to the topic, not any specific post