`,
);
});
run_test("uris", () => {
people.add_active_user(ray);
people.add_active_user(alice);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
let uri = hash_util.pm_with_uri(ray.email);
assert.equal(uri, "#narrow/pm-with/22-ray");
uri = hash_util.huddle_with_uri("22,23");
assert.equal(uri, "#narrow/pm-with/22,23-group");
uri = hash_util.by_sender_uri(ray.email);
assert.equal(uri, "#narrow/sender/22-ray");
let emails = hash_util.decode_operand("pm-with", "22,23-group");
assert.equal(emails, "alice@example.com,ray@example.com");
emails = hash_util.decode_operand("pm-with", "5,22,23-group");
assert.equal(emails, "alice@example.com,ray@example.com");
emails = hash_util.decode_operand("pm-with", "5-group");
assert.equal(emails, "me@example.com");
});
run_test("show_empty_narrow_message", ({mock_template}) => {
page_params.stop_words = [];
mock_template("empty_feed_notice.hbs", true, (data, html) => html);
narrow_state.reset_current_filter();
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: Nothing's been sent here yet!",
'translated HTML: Why not start the conversation?',
),
);
// for non-existent or private stream
set_filter([["stream", "Foo"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: This stream does not exist or is private."),
);
// for non sub public stream
stream_data.add_sub({name: "ROME", stream_id: 99});
set_filter([["stream", "Rome"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You aren't subscribed to this stream and nobody has talked about that yet!",
'translated HTML: ',
),
);
set_filter([["is", "starred"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You haven't starred anything yet!",
'translated HTML: Learn more about starring messages here.',
),
);
set_filter([["is", "mentioned"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You haven't been mentioned yet!",
'translated HTML: Learn more about mentions here.',
),
);
set_filter([["is", "private"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You have no private messages yet!",
'translated HTML: Why not start the conversation?',
),
);
set_filter([["is", "unread"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: You have no unread messages!"),
);
set_filter([["is", "resolved"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: No topics are marked as resolved."),
);
set_filter([["pm-with", ["Yo"]]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: This user does not exist!"),
);
people.add_active_user(alice);
set_filter([["pm-with", ["alice@example.com", "Yo"]]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: One or more of these users do not exist!"),
);
set_filter([["pm-with", "alice@example.com"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You have no private messages with this person yet!",
'translated HTML: Why not start the conversation?',
),
);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
set_filter([["pm-with", me.email]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You have not sent any private messages to yourself yet!",
'translated HTML: Why not start a conversation with yourself?',
),
);
set_filter([["pm-with", me.email + "," + alice.email]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You have no private messages with these people yet!",
'translated HTML: Why not start the conversation?',
),
);
set_filter([["group-pm-with", "alice@example.com"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: You have no group private messages with this person yet!",
'translated HTML: Why not start the conversation?',
),
);
set_filter([["sender", "ray@example.com"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: You haven't received any messages sent by this user yet!"),
);
set_filter([["sender", "sinwar@example.com"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: This user does not exist!"),
);
set_filter([
["sender", "alice@example.com"],
["stream", "Rome"],
]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: Nothing's been sent here yet!",
'translated HTML: Why not start the conversation?',
),
);
set_filter([["is", "invalid"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: Nothing's been sent here yet!",
'translated HTML: Why not start the conversation?',
),
);
const my_stream = {
name: "my stream",
stream_id: 103,
};
stream_data.add_sub(my_stream);
stream_data.subscribe_myself(my_stream);
set_filter([["stream", "my stream"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html(
"translated: Nothing's been sent here yet!",
'translated HTML: Why not start the conversation?',
),
);
set_filter([["stream", ""]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.equal(
$(".empty_feed_notice_main").html(),
empty_narrow_html("translated: This stream does not exist or is private."),
);
});
run_test("show_empty_narrow_message_with_search", ({mock_template}) => {
page_params.stop_words = [];
mock_template("empty_feed_notice.hbs", true, (data, html) => html);
narrow_state.reset_current_filter();
set_filter([["search", "grail"]]);
hide_all_empty_narrow_messages();
narrow_banner.show_empty_narrow_message();
assert.match($(".empty_feed_notice_main").html(), /grail<\/span>/);
});
run_test("hide_empty_narrow_message", () => {
$(".empty_feed_notice_main").html("