From e2a487c3cd24589b9d9bd298b79d8efaa9914480 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Wed, 30 Sep 2026 10:41:00 +0200 Subject: feat(hub): search title, description, canonical and noscript in the shell A descriptive , a two-line meta description apart from the short one messengers get, "/" canonical for every shell path, and a <noscript> pitch with the download and doc links for crawlers that do not run app.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- .../meshbay-hub/tests/test_asset_versioning.py | 5 +++- packages/meshbay-hub/tests/test_site_basics.py | 33 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'packages/meshbay-hub/tests') diff --git a/packages/meshbay-hub/tests/test_asset_versioning.py b/packages/meshbay-hub/tests/test_asset_versioning.py index 7057311..2d90a51 100644 --- a/packages/meshbay-hub/tests/test_asset_versioning.py +++ b/packages/meshbay-hub/tests/test_asset_versioning.py @@ -32,7 +32,10 @@ def client(): def _shell_refs(html: str) -> list[str]: - return re.findall(r'(?:src|href)="([^"]+)"', html) + """What the shell loads: script sources and <link> files. Not the canonical + link nor the <noscript> anchors, which name pages rather than fetch them.""" + return (re.findall(r'src="([^"]+)"', html) + + re.findall(r'<link rel="(?!canonical")[^"]+" href="([^"]+)"', html)) def test_every_asset_the_shell_loads_is_versioned(client): diff --git a/packages/meshbay-hub/tests/test_site_basics.py b/packages/meshbay-hub/tests/test_site_basics.py index 5c19aa6..40508a1 100644 --- a/packages/meshbay-hub/tests/test_site_basics.py +++ b/packages/meshbay-hub/tests/test_site_basics.py @@ -93,3 +93,36 @@ def test_the_preview_description_fits_in_a_preview(): nothing.""" from meshbay_hub.api.webapp import PREVIEW_DESCRIPTION assert len(PREVIEW_DESCRIPTION) <= 60 + + +def test_search_engines_get_a_title_and_description_that_say_what_it_is(client): + """The preview description is cut for messengers; a search result has + room for two lines, and a bare "MeshBay" title matches no search.""" + from meshbay_hub.api.webapp import SEARCH_DESCRIPTION, SEARCH_TITLE + html = client.get("/").text + assert f"<title>{SEARCH_TITLE}" in html + assert 50 <= len(SEARCH_TITLE) <= 60 + assert re.search(r'', html).group(1) == SEARCH_DESCRIPTION + assert 110 <= len(SEARCH_DESCRIPTION) <= 160 + + +def test_every_path_to_the_shell_names_the_root_as_canonical(): + from meshbay_hub.config import load_config + cfg = load_config() + cfg.identity.id = "hub.example.org" + client = TestClient(create_app(cfg)) + for path in ("/", "/app", "/app/groups"): + html = client.get(path).text + assert '' in html, path + + +def test_the_shell_has_text_and_links_without_scripts(client): + """A crawler that does not run app.js reads the