Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

custom_profile_fields: Extract `display_in_profile_summary` tests.

Shubham Padiacf75007ed3fa
diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py
index 5304aa6b256..a01b33e8a69 100644
--- a/zerver/tests/test_custom_profile_data.py
+++ b/zerver/tests/test_custom_profile_data.py
@@ -500,15 +500,6 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
msg = "hint is too long (limit: 80 characters)"
self.assert_json_error(result, msg)
- result = self.client_patch(
- f"/json/realm/profile_fields/{field.id}",
- info={
- "display_in_profile_summary": "invalid value",
- },
- )
- msg = 'Argument "display_in_profile_summary" is not valid JSON.'
- self.assert_json_error(result, msg)
-
result = self.client_patch(
f"/json/realm/profile_fields/{field.id}",
info={
@@ -550,11 +541,44 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
result = self.client_patch(
f"/json/realm/profile_fields/{field.id}",
- info={"name": "Name ", "display_in_profile_summary": "true"},
+ info={"name": "Name "},
)
self.assert_json_success(result)
field.refresh_from_db()
self.assertEqual(field.name, "Name")
+
+ # Empty string for hint should set it to an empty string
+ result = self.client_patch(
+ f"/json/realm/profile_fields/{field.id}",
+ info={"hint": ""},
+ )
+ self.assert_json_success(result)
+ field.refresh_from_db()
+ self.assertEqual(field.hint, "")
+
+ def test_update_display_in_profile_summary(self) -> None:
+ self.login("iago")
+ realm = get_realm("zulip")
+
+ field = CustomProfileField.objects.get(name="Phone number", realm=realm)
+
+ result = self.client_patch(
+ f"/json/realm/profile_fields/{field.id}",
+ info={
+ "display_in_profile_summary": "invalid value",
+ },
+ )
+ msg = 'Argument "display_in_profile_summary" is not valid JSON.'
+ self.assert_json_error(result, msg)
+
+ result = self.client_patch(
+ f"/json/realm/profile_fields/{field.id}",
+ info={
+ "display_in_profile_summary": "true",
+ },
+ )
+ self.assert_json_success(result)
+ field.refresh_from_db()
self.assertEqual(field.display_in_profile_summary, True)
# Not sending display_in_profile_summary should not set it to false.
@@ -594,15 +618,6 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase):
result, "Only 2 custom profile fields can be displayed in the profile summary."
)
- # Empty string for hint should set it to an empty string
- result = self.client_patch(
- f"/json/realm/profile_fields/{field.id}",
- info={"hint": ""},
- )
- self.assert_json_success(result)
- field.refresh_from_db()
- self.assertEqual(field.hint, "")
-
def test_update_field_data(self) -> None:
self.login("iago")
realm = get_realm("zulip")