node-tests: Update references to "private message" and "PM".

Updates any use of "private message" and "PM" in the `web/tests`
directory to instead use "direct messages".
This commit is contained in:
Lauryn Menard
2023-06-16 17:37:19 +02:00
committed by Tim Abbott
parent 7c47616ffa
commit 73e5812831
18 changed files with 79 additions and 65 deletions

View File

@@ -183,9 +183,10 @@ test("huddle_data.process_loaded_messages", () => {
{
type: "stream",
},
// direct message to myself
{
type: "private",
display_recipient: [{id: me.user_id}], // PM to myself
display_recipient: [{id: me.user_id}],
},
{
type: "private",
@@ -246,7 +247,7 @@ function buddy_list_add(user_id, $stub) {
$("#user_presences").set_find_results(sel, $stub);
}
test("PM_update_dom_counts", () => {
test("direct_message_update_dom_counts", () => {
const $count = $.create("alice-unread-count");
const pm_key = alice.user_id.toString();
const $li = $.create("alice stub");

View File

@@ -240,7 +240,7 @@ test("compose fade interactions (missing topic)", () => {
assert.equal(faded(), false);
});
test("compose fade interactions (PMs)", () => {
test("compose fade interactions (direct messages)", () => {
people.add_active_user(fred);
set_presence(fred.user_id, "active");
@@ -252,8 +252,8 @@ test("compose fade interactions (PMs)", () => {
// Don't fade if we're not in a narrow.
assert.equal(faded(), false);
// Fade fred if we are narrowed to a PM narrow that does
// not include him.
// Fade fred if we are narrowed to a direct message narrow
// that does not include him.
compose_fade_helper.set_focused_recipient({
type: "private",
to_user_ids: "9999999",

View File

@@ -188,7 +188,7 @@ test("start", ({override, override_rewire, mock_template}) => {
assert.equal(compose_state.topic(), "");
stream_data.clear_subscriptions();
// Start PM
// Start direct message
compose_defaults = {
private_message_recipient: "foo@example.com",
};
@@ -251,7 +251,7 @@ test("respond_to_message", ({override, override_rewire, mock_template}) => {
mock_template("inline_decorated_stream_name.hbs", false, () => {});
mock_stream_header_colorblock();
// Test PM
// Test direct message
const person = {
user_id: 22,
email: "alice@example.com",

View File

@@ -204,7 +204,7 @@ run_test("compute_placeholder_text", () => {
$t({defaultMessage: "Message #all > Test"}),
);
// PM Narrows
// direct message narrows
opts = {
message_type: "private",
stream: "",
@@ -233,7 +233,7 @@ run_test("compute_placeholder_text", () => {
});
assert.equal(compose_ui.compute_placeholder_text(opts), $t({defaultMessage: "Message Alice"}));
// Group PM
// group direct message
opts.private_message_recipient = "alice@zulip.com,bob@zulip.com";
assert.equal(
compose_ui.compute_placeholder_text(opts),

View File

@@ -175,7 +175,7 @@ test_ui("validate", ({override_rewire, mock_template}) => {
$("#compose-textarea").val("foobarfoobar");
}
// test validating private messages
// test validating direct messages
compose_state.set_message_type("private");
initialize_pm_pill();

View File

@@ -72,7 +72,7 @@ run_test("verify wildcard mentions typeahead for stream message", () => {
assert.equal(mention_stream.special_item_text, "stream (translated: Notify stream)");
});
run_test("verify wildcard mentions typeahead for private message", () => {
run_test("verify wildcard mentions typeahead for direct message", () => {
compose_state.set_message_type("private");
assert.equal(ct.broadcast_mentions().length, 2);
const mention_all = ct.broadcast_mentions()[0];
@@ -1720,8 +1720,8 @@ test("message people", ({override, override_rewire}) => {
});
test("muted users excluded from results", () => {
// This logic is common to PM recipients as well as
// mentions typeaheads, so we need only test once.
// This logic is common to direct message recipients as
// well as mentions typeaheads, so we need only test once.
let results;
const opts = {
want_broadcast: true,
@@ -1743,11 +1743,13 @@ test("muted users excluded from results", () => {
assert.deepEqual(results, [mention_all, call_center]);
});
test("PM recipients sorted according to stream / topic being viewed", ({override_rewire}) => {
// This tests that PM recipient results are sorted with subscribers of
// the stream / topic being viewed being given priority. If no stream
// is being viewed, the sort is alphabetical (for testing, since we do not
// simulate PM history)
test("direct message recipients sorted according to stream / topic being viewed", ({
override_rewire,
}) => {
// This tests that direct message recipient results are sorted with
// subscribers of the stream / topic being viewed being given priority.
// If no stream is being viewed, the sort is alphabetical (for testing,
// since we do not simulate direct message history)
let results;
// Simulating just cordelia being subscribed to denmark.

View File

@@ -78,7 +78,7 @@ const draft_2 = {
private_message_recipient: "aaron@zulip.com",
reply_to: "aaron@zulip.com",
type: "private",
content: "Test private message",
content: "Test direct message",
};
const short_msg = {
stream: "stream",
@@ -238,7 +238,7 @@ test("remove_old_drafts", () => {
private_message_recipient: "aaron@zulip.com",
reply_to: "aaron@zulip.com",
type: "private",
content: "Test private message",
content: "Test direct message",
updatedAt: new Date().setDate(-30),
};
const draft_model = drafts.draft_model;
@@ -507,7 +507,7 @@ test("format_drafts", ({override_rewire, mock_template}) => {
private_message_recipient: "aaron@zulip.com",
reply_to: "aaron@zulip.com",
type: "private",
content: "Test private message",
content: "Test direct message",
updatedAt: date(-1),
};
const draft_3 = {
@@ -521,14 +521,14 @@ test("format_drafts", ({override_rewire, mock_template}) => {
private_message_recipient: "aaron@zulip.com",
reply_to: "iago@zulip.com",
type: "private",
content: "Test private message 2",
content: "Test direct message 2",
updatedAt: date(-5),
};
const draft_5 = {
private_message_recipient: "aaron@zulip.com",
reply_to: "zoe@zulip.com",
type: "private",
content: "Test private message 3",
content: "Test direct message 3",
updatedAt: date(-2),
};
@@ -550,21 +550,21 @@ test("format_drafts", ({override_rewire, mock_template}) => {
draft_id: "id2",
is_stream: false,
recipients: "Aaron",
raw_content: "Test private message",
raw_content: "Test direct message",
time_stamp: "Jan 30",
},
{
draft_id: "id5",
is_stream: false,
recipients: "Aaron",
raw_content: "Test private message 3",
raw_content: "Test direct message 3",
time_stamp: "Jan 29",
},
{
draft_id: "id4",
is_stream: false,
recipients: "Aaron",
raw_content: "Test private message 2",
raw_content: "Test direct message 2",
time_stamp: "Jan 26",
},
{
@@ -656,7 +656,7 @@ test("filter_drafts", ({override_rewire, mock_template}) => {
private_message_recipient: "aaron@zulip.com",
reply_to: "aaron@zulip.com",
type: "private",
content: "Test private message",
content: "Test direct message",
updatedAt: date(-1),
};
const stream_draft_2 = {
@@ -670,14 +670,14 @@ test("filter_drafts", ({override_rewire, mock_template}) => {
private_message_recipient: "aaron@zulip.com",
reply_to: "iago@zulip.com",
type: "private",
content: "Test private message 2",
content: "Test direct message 2",
updatedAt: date(-5),
};
const pm_draft_3 = {
private_message_recipient: "aaron@zulip.com",
reply_to: "zoe@zulip.com",
type: "private",
content: "Test private message 3",
content: "Test direct message 3",
updatedAt: date(-2),
};
@@ -686,21 +686,21 @@ test("filter_drafts", ({override_rewire, mock_template}) => {
draft_id: "id2",
is_stream: false,
recipients: "Aaron",
raw_content: "Test private message",
raw_content: "Test direct message",
time_stamp: "Jan 30",
},
{
draft_id: "id5",
is_stream: false,
recipients: "Aaron",
raw_content: "Test private message 3",
raw_content: "Test direct message 3",
time_stamp: "Jan 29",
},
{
draft_id: "id4",
is_stream: false,
recipients: "Aaron",
raw_content: "Test private message 2",
raw_content: "Test direct message 2",
time_stamp: "Jan 26",
},
];

View File

@@ -249,7 +249,7 @@ run_test("insert_local_message streams", ({override, override_rewire}) => {
assert.ok(insert_message_called);
});
run_test("insert_local_message PM", ({override, override_rewire}) => {
run_test("insert_local_message direct message", ({override, override_rewire}) => {
const local_id_float = 102.01;
page_params.user_id = 123;

View File

@@ -7,9 +7,9 @@ const {run_test} = require("./lib/test");
const {page_params} = require("./lib/zpage_params");
// In the Zulip app you can narrow your message stream by topic, by
// sender, by PM recipient, by search keywords, etc. We will discuss
// narrows more broadly, but first let's test out a core piece of
// code that makes things work.
// sender, by direct message recipient, by search keywords, etc.
// We will discuss narrows more broadly, but first let's test out a
// core piece of code that makes things work.
const {Filter} = zrequire("../src/filter");
const stream_data = zrequire("stream_data");

View File

@@ -73,7 +73,7 @@ run_test("typing_events.render_notifications_for_narrow", ({override, mock_templ
// All typists are rendered in `#typing_notifications`.
const $typing_notifications = $("#typing_notifications");
// Narrow to a PM group with four users.
// Narrow to a group direct message with four users.
override(page_params, "user_id", anna.user_id);
const group = [anna.user_id, vronsky.user_id, levin.user_id, kitty.user_id];
const group_emails = `${anna.email},${vronsky.email},${levin.email},${kitty.email}`;

View File

@@ -235,7 +235,7 @@ run_test("stream_and_topic_exist_in_edit_history", () => {
// A non-stream message (object has no stream_id or topic)
// with content edit history, should return false.
const private_message = {
edit_history: [{prev_content: "content edit to PM"}],
edit_history: [{prev_content: "content edit to direct message"}],
};
assert.equal(
message_edit.stream_and_topic_exist_in_edit_history(private_message, 1, "topic match"),

View File

@@ -133,15 +133,22 @@ run_test("muting", () => {
const msgs = [
{id: 1, type: "stream", stream_id: 1, topic: "muted"},
{id: 2, type: "stream", stream_id: 1, topic: "whatever"},
{id: 3, type: "stream", stream_id: 1, topic: "muted", mentioned: true}, // mentions override muting
// mentions override muting
{id: 3, type: "stream", stream_id: 1, topic: "muted", mentioned: true},
// 10 = muted user, 9 = non-muted user, 11 = you
{id: 4, type: "private", to_user_ids: "9,10,11", sender_id: 10}, // muted to huddle
{id: 5, type: "private", to_user_ids: "9,10,11", sender_id: 9}, // non-muted to huddle
{id: 6, type: "private", to_user_ids: "11", sender_id: 10}, // muted to 1:1 PM
{id: 7, type: "private", to_user_ids: "11", sender_id: 9}, // non-muted to 1:1 PM
{id: 8, type: "private", to_user_ids: "10", sender_id: 11}, // 1:1 PM to muted
{id: 9, type: "private", to_user_ids: "9", sender_id: 11}, // 1:1 PM to non-muted
// muted to group direct message
{id: 4, type: "private", to_user_ids: "9,10,11", sender_id: 10},
// non-muted to group direct message
{id: 5, type: "private", to_user_ids: "9,10,11", sender_id: 9},
// muted to 1:1 direct message
{id: 6, type: "private", to_user_ids: "11", sender_id: 10},
// non-muted to 1:1 direct message
{id: 7, type: "private", to_user_ids: "11", sender_id: 9},
// 1:1 direct message to muted
{id: 8, type: "private", to_user_ids: "10", sender_id: 11},
// 1:1 direct message to non-muted
{id: 9, type: "private", to_user_ids: "9", sender_id: 11},
];
user_topics.update_user_topics(1, "muted", user_topics.all_visibility_policies.MUTED);
@@ -151,8 +158,8 @@ run_test("muting", () => {
// messages if `excludes_muted_topics` is false.
assert.deepEqual(mld.messages_filtered_for_topic_mutes(msgs), msgs);
// If we are in a 1:1 PM narrow, `messages_filtered_for_user_mutes` should skip
// filtering messages.
// If we are in a 1:1 direct message narrow, `messages_filtered_for_user_mutes`
// should skip filtering messages.
assert.deepEqual(mld.messages_filtered_for_user_mutes(msgs), msgs);
// Test actual behaviour of `messages_filtered_for_*` methods.
@@ -163,7 +170,7 @@ run_test("muting", () => {
{id: 2, type: "stream", stream_id: 1, topic: "whatever"},
{id: 3, type: "stream", stream_id: 1, topic: "muted", mentioned: true}, // mentions override muting
// `messages_filtered_for_topic_mutes` does not affect private messages
// `messages_filtered_for_topic_mutes` does not affect direct messages
{id: 4, type: "private", to_user_ids: "9,10,11", sender_id: 10},
{id: 5, type: "private", to_user_ids: "9,10,11", sender_id: 9},
{id: 6, type: "private", to_user_ids: "11", sender_id: 10},
@@ -178,11 +185,14 @@ run_test("muting", () => {
{id: 1, type: "stream", stream_id: 1, topic: "muted"},
{id: 2, type: "stream", stream_id: 1, topic: "whatever"},
{id: 3, type: "stream", stream_id: 1, topic: "muted", mentioned: true},
{id: 4, type: "private", to_user_ids: "9,10,11", sender_id: 10}, // muted to huddle
{id: 5, type: "private", to_user_ids: "9,10,11", sender_id: 9}, // non-muted to huddle
{id: 7, type: "private", to_user_ids: "11", sender_id: 9}, // non-muted to 1:1 PM
{id: 9, type: "private", to_user_ids: "9", sender_id: 11}, // 1:1 PM to non-muted
// muted to group direct message
{id: 4, type: "private", to_user_ids: "9,10,11", sender_id: 10},
// non-muted to group direct message
{id: 5, type: "private", to_user_ids: "9,10,11", sender_id: 9},
// non-muted to 1:1 direct message
{id: 7, type: "private", to_user_ids: "11", sender_id: 9},
// 1:1 direct message to non-muted
{id: 9, type: "private", to_user_ids: "9", sender_id: 11},
]);
// Output filtered based on both topic and user muting.

View File

@@ -58,7 +58,8 @@ test("insert_recent_private_message", () => {
// Insert new messages (which should rearrange these entries).
pmc.recent.insert([1], 1000);
pmc.recent.insert([1, 2, 3], 999);
pmc.recent.insert([], 101); // Self-PM
// direct message to oneself
pmc.recent.insert([], 101);
// Try to backdate user1's latest message.
pmc.recent.insert([1], 555);
@@ -91,7 +92,7 @@ test("muted_users", () => {
muted_users.add_muted_user(2);
// We should now get back only those messages which are either-
// 1:1 PMs in which the other user hasn't been muted.
// 1:1 direct messages in which the other user hasn't been muted.
// Huddles where there's at least one non-muted participant.
assert.deepEqual(pmc.recent.get(), [
{user_ids_string: "3", max_message_id: 99},

View File

@@ -248,7 +248,7 @@ test("get_list_info_unread_messages", ({override}) => {
"Bob",
]);
// Narrowing to private messages with Alice adds older
// Narrowing to direct messages with Alice adds older
// one-on-one conversation with her to the list and one
// unread is removed from more_conversations_unread_count.
set_pm_with_filter("alice@zulip.com");
@@ -325,7 +325,7 @@ test("get_list_info_no_unread_messages", ({override}) => {
"Bob",
]);
// Narrowing to private messages with Alice adds older
// Narrowing to direct messages with Alice adds older
// one-on-one conversation with her to the list.
set_pm_with_filter("alice@zulip.com");
list_info = pm_list_data.get_list_info(false);

View File

@@ -340,7 +340,7 @@ test("process_pms", () => {
participants: [1, 3, 2],
non_participants: [4],
});
// PM doesn't exist.
// Direct message doesn't exist.
assert.deepEqual(rs.get_pm_recent_senders("1000,2000"), {
participants: [],
non_participants: [],

View File

@@ -871,7 +871,7 @@ test("basic assertions", ({mock_template, override_rewire}) => {
"4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
);
// Process private message
// Process direct message
rt_data.process_message({
type: "private",
to_user_ids: "6,7,8",

View File

@@ -334,7 +334,7 @@ test("sort_recipients", () => {
"a_bot@zulip.com",
]);
// Typeahead for private message [query, "", ""]
// Typeahead for direct message [query, "", ""]
assert.deepEqual(get_typeahead_result("a", "", ""), [
"a_user@zulip.org",
"a_bot@zulip.com",
@@ -352,7 +352,7 @@ test("sort_recipients", () => {
peer_data.add_subscriber(1, people.get_user_id(subscriber_email_2));
peer_data.add_subscriber(1, people.get_user_id(subscriber_email_3));
// For splitting based on whether a PM was sent
// For splitting based on whether a direct message was sent
pm_conversations.set_partner(5);
pm_conversations.set_partner(6);
pm_conversations.set_partner(2);
@@ -524,7 +524,7 @@ test("sort_recipients dup alls", () => {
assertSameEmails(recipients, expected);
});
test("sort_recipients dup alls private", () => {
test("sort_recipients dup alls direct message", () => {
compose_state.set_message_type("private");
const all_obj = ct.broadcast_mentions()[0];
@@ -597,7 +597,7 @@ test("sort broadcast mentions for stream message type", () => {
);
});
test("sort broadcast mentions for private message type", () => {
test("sort broadcast mentions for direct message type", () => {
compose_state.set_message_type("private");
const results = th.sort_people_for_relevance(ct.broadcast_mentions().reverse(), "", "");
@@ -630,7 +630,7 @@ test("test compare directly for stream message type", () => {
assert.equal(th.compare_people_for_relevance(zman, all_obj), 1);
});
test("test compare directly for private message", () => {
test("test compare directly for direct message", () => {
compose_state.set_message_type("private");
const all_obj = ct.broadcast_mentions()[0];

View File

@@ -50,7 +50,7 @@ function test(label, f) {
}
test("edge_cases", () => {
// private messages
// direct messages
assert.ok(!user_topics.is_topic_muted(undefined, undefined));
});