user_settings: Automate 'Include realm name in message email subject'.

Currently, there is a checkbox setting for whether to
"Include realm name in subject of message notification emails".

This commit replaces the checkbox setting with a dropdown
having values: Automatic [default], Always, Never.

The Automatic option includes the realm name if, and only if,
there are multiple Zulip realms associated with the user's email.

Tests are added and(or) modified.

Fixes: #19905.
This commit is contained in:
Prakhar Pratyush
2023-01-15 01:06:37 +05:30
committed by Tim Abbott
parent ab8222c4ae
commit ae72777c77
20 changed files with 346 additions and 44 deletions

View File

@@ -1837,6 +1837,7 @@ class NormalActionsTest(BaseAction):
"notification_sound",
"desktop_icon_count_display",
"presence_enabled",
"realm_name_in_email_notifications_policy",
]:
# These settings are tested in their own tests.
continue
@@ -1926,6 +1927,27 @@ class NormalActionsTest(BaseAction):
check_user_settings_update("events[0]", events[0])
check_update_global_notifications("events[1]", events[1], 1)
def test_change_realm_name_in_email_notifications_policy(self) -> None:
notification_setting = "realm_name_in_email_notifications_policy"
events = self.verify_action(
lambda: do_change_user_setting(
self.user_profile, notification_setting, 3, acting_user=self.user_profile
),
num_events=2,
)
check_user_settings_update("events[0]", events[0])
check_update_global_notifications("events[1]", events[1], 3)
events = self.verify_action(
lambda: do_change_user_setting(
self.user_profile, notification_setting, 2, acting_user=self.user_profile
),
num_events=2,
)
check_user_settings_update("events[0]", events[0])
check_update_global_notifications("events[1]", events[1], 2)
def test_realm_update_org_type(self) -> None:
realm = self.user_profile.realm
@@ -2690,6 +2712,7 @@ class RealmPropertyActionTest(BaseAction):
notification_sound=["zulip", "ding"],
email_notifications_batching_period_seconds=[120, 300],
email_address_visibility=UserProfile.EMAIL_ADDRESS_VISIBILITY_TYPES,
realm_name_in_email_notifications_policy=UserProfile.REALM_NAME_IN_EMAIL_NOTIFICATIONS_POLICY_CHOICES,
)
vals = test_values.get(name)