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.

test_docs: Remove help specific tests and port rest over to /api.

Shubham Padia5f9860776f54
diff --git a/zerver/lib/markdown/help_emoticon_translations_table.py b/zerver/lib/markdown/help_emoticon_translations_table.py
index def19a066a0..701e863f3df 100644
--- a/zerver/lib/markdown/help_emoticon_translations_table.py
+++ b/zerver/lib/markdown/help_emoticon_translations_table.py
@@ -53,7 +53,7 @@ class EmoticonTranslationsHelpExtension(Extension):
class EmoticonTranslation(Preprocessor):
@override
- def run(self, lines: list[str]) -> list[str]:
+ def run(self, lines: list[str]) -> list[str]: # nocoverage
for loc, line in enumerate(lines):
match = REGEXP.search(line)
if match:
@@ -62,7 +62,7 @@ class EmoticonTranslation(Preprocessor):
break
return lines
- def handleMatch(self, match: Match[str]) -> list[str]:
+ def handleMatch(self, match: Match[str]) -> list[str]: # nocoverage
rows = [
ROW_HTML.format(
emoticon=emoticon,
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py
index a89abb11ca5..b06416810ed 100644
--- a/zerver/tests/test_docs.py
+++ b/zerver/tests/test_docs.py
@@ -48,7 +48,6 @@ class DocPageTest(ZulipTestCase):
"/devtools/",
"/emails/",
"/errors/",
- "/help/",
"/integrations/",
]:
if url.startswith(prefix):
@@ -428,79 +427,26 @@ class DocPageTest(ZulipTestCase):
self.assertTrue('data-platform="ZulipElectron"' in result.content.decode())
-class HelpTest(ZulipTestCase):
- def test_help_settings_links(self) -> None:
- result = self.client_get("/help/change-the-time-format")
- self.assertEqual(result.status_code, 200)
- self.assertIn('Go to <a href="/#settings/preferences">Preferences</a>', str(result.content))
- # Check that the sidebar was rendered properly.
- self.assertIn("Getting started with Zulip", str(result.content))
-
- with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
- result = self.client_get("/help/change-the-time-format", subdomain="")
- self.assertEqual(result.status_code, 200)
- self.assertIn("<strong>Preferences</strong>", str(result.content))
- self.assertNotIn("/#settings", str(result.content))
-
- def test_help_relative_links_for_gear(self) -> None:
- result = self.client_get("/help/analytics")
- self.assertIn(
- '<a href="/stats"><i class="zulip-icon zulip-icon-bar-chart"></i> Usage statistics</a>',
- str(result.content),
- )
- self.assertEqual(result.status_code, 200)
-
- with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
- result = self.client_get("/help/analytics", subdomain="")
- self.assertEqual(result.status_code, 200)
- self.assertIn(
- '<strong><i class="zulip-icon zulip-icon-bar-chart"></i> Usage statistics</strong>',
- str(result.content),
- )
- self.assertNotIn("/stats", str(result.content))
-
- def test_help_relative_gear_billing_links(self) -> None:
- result = self.client_get("/help/zulip-cloud-billing")
- self.assertIn(
- '<a href="/plans/"><i class="zulip-icon zulip-icon-rocket"></i> Plans and pricing</a>',
- str(result.content),
- )
- self.assertEqual(result.status_code, 200)
-
- with self.settings(CORPORATE_ENABLED=False):
- result = self.client_get("/help/zulip-cloud-billing")
- self.assertEqual(result.status_code, 200)
- self.assertIn(
- '<strong><i class="zulip-icon zulip-icon-rocket"></i> Plans and pricing</strong>',
- str(result.content),
- )
- self.assertNotIn('<a href="/plans/">', str(result.content))
-
- with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
- result = self.client_get("/help/zulip-cloud-billing", subdomain="")
+class CustomShorthandLinksTest(ZulipTestCase):
+ # We do not test relative links here since relative links were only
+ # used in the old help pages. We should probably remove the logic
+ # for relative links after we have done the official cutover to the
+ # starlight help center: https://github.com/zulip/zulip/issues/35654.
+ def test_settings_links(self) -> None:
+ result = self.client_get("/api/api-keys")
self.assertEqual(result.status_code, 200)
self.assertIn(
- '<strong><i class="zulip-icon zulip-icon-rocket"></i> Plans and pricing</strong>',
+ 'Go to <a href="/#settings/account-and-privacy">Account &amp; privacy</a>',
str(result.content),
)
- self.assertNotIn('a href="/plans/">', str(result.content))
-
- def test_help_relative_links_for_stream(self) -> None:
- result = self.client_get("/help/message-a-channel-by-email")
- self.assertIn(
- '<a href="/#channels/subscribed"><i class="zulip-icon zulip-icon-hash"></i> Channel settings</a>',
- str(result.content),
- )
- self.assertEqual(result.status_code, 200)
+ # Check that the sidebar was rendered properly.
+ self.assertIn("API documentation home", str(result.content))
with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
- result = self.client_get("/help/message-a-channel-by-email", subdomain="")
+ result = self.client_get("/api/api-keys", subdomain="")
self.assertEqual(result.status_code, 200)
- self.assertIn(
- '<strong><i class="zulip-icon zulip-icon-hash"></i> Channel settings</strong>',
- str(result.content),
- )
- self.assertNotIn("/#channels", str(result.content))
+ self.assertIn("<strong>Account &amp; privacy</strong>", str(result.content))
+ self.assertNotIn("/#settings", str(result.content))
class IntegrationTest(ZulipTestCase):
diff --git a/zerver/views/documentation.py b/zerver/views/documentation.py
index fbcda7e3c3c..94771bc6596 100644
--- a/zerver/views/documentation.py
+++ b/zerver/views/documentation.py
@@ -100,7 +100,10 @@ class MarkdownDirectoryView(ApiURLView):
http_status = 200
if article == "":
article = "index"
- elif article == "include/sidebar_index":
+ # Only help center has this article nested inside an include,
+ # after switching to the new help center, we should remove this
+ # elif block.
+ elif article == "include/sidebar_index": # nocoverage.
pass
elif article == "api-doc-template":
# This markdown template shouldn't be accessed directly.
@@ -190,7 +193,10 @@ class MarkdownDirectoryView(ApiURLView):
settings.DEPLOY_ROOT, "templates", documentation_article.article_path
)
- if self.help_view:
+ # The nocoverage blocks here are very temporary since this
+ # whole block will be removed once we switch to the new help
+ # center.
+ if self.help_view: # nocoverage
context["page_is_help_center"] = True
context["doc_root"] = "/help/"
context["doc_root_title"] = "Help center"