user_profile: Show streams to subscribe for user's own profile.

We did not show the streams to subscribe in dropdown in user
profile modal when user is not allowed to subscribe others
even in the user's own profile modal which is not correct.

This commit fixes it to show the streams in dropdown for
user's own profile irrespective of whether user is allowed
to subscribe others or not.
This commit is contained in:
Sahil Batra
2023-10-18 13:34:05 +05:30
committed by Tim Abbott
parent 8c45e1dfed
commit 180ed2e50f
2 changed files with 34 additions and 3 deletions

View File

@@ -237,7 +237,16 @@ test("get_streams_for_user", () => {
history_public_to_subscribers: false,
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
};
const subs = [denmark, social, test, world];
const errors = {
color: "green",
name: "errors",
stream_id: 5,
is_muted: false,
invite_only: false,
history_public_to_subscribers: false,
stream_post_policy: settings_config.stream_post_policy_values.admins.code,
};
const subs = [denmark, social, test, world, errors];
for (const sub of subs) {
stream_data.add_sub(sub);
}
@@ -247,6 +256,10 @@ test("get_streams_for_user", () => {
peer_data.set_subscribers(test.stream_id, [test_user.user_id]);
peer_data.set_subscribers(world.stream_id, [me.user_id]);
page_params.realm_invite_to_stream_policy =
settings_config.common_policy_values.by_admins_only.code;
assert.deepEqual(stream_data.get_streams_for_user(me.user_id).can_subscribe, [social, errors]);
// test_user is subscribed to all three streams, but current user (me)
// gets only two because of subscriber visibility policy of stream:
// #denmark: current user is subscribed to it so he can see its subscribers.
@@ -261,8 +274,18 @@ test("get_streams_for_user", () => {
assert.deepEqual(stream_data.get_streams_for_user(test_user.user_id).can_subscribe, []);
// Verify can subscribe if we're an administrator.
page_params.is_admin = true;
assert.deepEqual(stream_data.get_streams_for_user(test_user.user_id).can_subscribe, [world]);
assert.deepEqual(stream_data.get_streams_for_user(test_user.user_id).can_subscribe, [
world,
errors,
]);
page_params.is_admin = false;
page_params.realm_invite_to_stream_policy =
settings_config.common_policy_values.by_members.code;
assert.deepEqual(stream_data.get_streams_for_user(test_user.user_id).can_subscribe, [
world,
errors,
]);
});
test("renames", () => {