From c727f1f65d90313e4000cfae84a63303487bccae Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Thu, 7 Jul 2022 12:25:09 -0400 Subject: [PATCH] test_support_views: Add get_check_query_result helper. This is a prep commit for a refactoring that fixes an issue with plan data not being displayed when the realm is displayed by the query result of users or confirmation objects. Signed-off-by: Zixuan James Li --- analytics/tests/test_support_views.py | 35 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py index 874421f662..6a742c542f 100644 --- a/analytics/tests/test_support_views.py +++ b/analytics/tests/test_support_views.py @@ -176,6 +176,13 @@ class TestSupportEndpoint(ZulipTestCase): result, ) + def get_check_query_result( + query: str, count: int, subdomain: str = "zulip" + ) -> "TestHttpResponse": + result = self.client_get("/activity/support", {"q": query}, subdomain=subdomain) + self.assertEqual(result.content.decode().count("support-query-result"), count) + return result + self.login("cordelia") result = self.client_get("/activity/support") @@ -214,39 +221,39 @@ class TestSupportEndpoint(ZulipTestCase): ['"}) + result = get_check_query_result("lear, Hamlet ", 2) check_hamlet_user_query_result(result) check_zulip_realm_query_result(result) check_lear_realm_query_result(result) @@ -257,7 +264,7 @@ class TestSupportEndpoint(ZulipTestCase): ): self.client_post("/accounts/home/", {"email": self.nonreg_email("test")}) self.login("iago") - result = self.client_get("/activity/support", {"q": self.nonreg_email("test")}) + result = get_check_query_result(self.nonreg_email("test"), 1) check_preregistration_user_query_result(result, self.nonreg_email("test")) check_zulip_realm_query_result(result) @@ -273,13 +280,13 @@ class TestSupportEndpoint(ZulipTestCase): "invite_as": PreregistrationUser.INVITE_AS["MEMBER"], }, ) - result = self.client_get("/activity/support", {"q": self.nonreg_email("test1")}) + result = get_check_query_result(self.nonreg_email("test1"), 1) check_preregistration_user_query_result(result, self.nonreg_email("test1"), invite=True) check_zulip_realm_query_result(result) email = self.nonreg_email("alice") self.client_post("/new/", {"email": email}) - result = self.client_get("/activity/support", {"q": email}) + result = get_check_query_result(email, 1) check_realm_creation_query_result(result, email) do_create_multiuse_invite_link( @@ -287,13 +294,13 @@ class TestSupportEndpoint(ZulipTestCase): invited_as=1, invite_expires_in_minutes=invite_expires_in_minutes, ) - result = self.client_get("/activity/support", {"q": "zulip"}) + result = get_check_query_result("zulip", 2) check_multiuse_invite_link_query_result(result) check_zulip_realm_query_result(result) MultiuseInvite.objects.all().delete() do_send_realm_reactivation_email(get_realm("zulip"), acting_user=None) - result = self.client_get("/activity/support", {"q": "zulip"}) + result = get_check_query_result("zulip", 2) check_realm_reactivation_link_query_result(result) check_zulip_realm_query_result(result)