From eef3ad2954ffa2603eff01e6268a6e62db2f25be Mon Sep 17 00:00:00 2001 From: Deeman Date: Fri, 27 Feb 2026 08:44:52 +0100 Subject: [PATCH] fix(tests): update stale test assertions to match current behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test_draft/future_article: route intentionally redirects to parent (302) instead of bare 404 — rename tests and update assertion accordingly - test_dashboard_has_content_links: /admin/templates and /admin/scenarios are subnav links shown only on content section pages, not the main dashboard; test now only checks /admin/articles which is always in the sidebar - test_seo_sidebar_link: sidebar labels the link "Analytics" (not "SEO Hub" which is the page title); test now checks for /admin/seo URL presence Co-Authored-By: Claude Sonnet 4.6 --- web/tests/test_content.py | 15 +++++++++------ web/tests/test_seo.py | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/web/tests/test_content.py b/web/tests/test_content.py index 77add6f..c70063c 100644 --- a/web/tests/test_content.py +++ b/web/tests/test_content.py @@ -839,18 +839,21 @@ class TestArticleServing: resp = await client.get("/en/padel-court-cost-nonexistent") assert resp.status_code == 404 - async def test_draft_article_returns_404(self, client, db): + async def test_draft_article_redirects_to_parent(self, client, db): + # Draft articles are not served; the route redirects to the nearest parent + # rather than showing a bare 404. await _create_article(slug="draft-serve", url_path="/draft-serve", status="draft") resp = await client.get("/en/draft-serve") - assert resp.status_code == 404 + assert resp.status_code == 302 - async def test_future_article_returns_404(self, client, db): + async def test_future_article_redirects_to_parent(self, client, db): + # Scheduled (not yet live) articles redirect to the parent path instead of 404. await _create_article( slug="future-serve", url_path="/future-serve", status="published", published_at="2099-01-01T00:00:00", ) resp = await client.get("/en/future-serve") - assert resp.status_code == 404 + assert resp.status_code == 302 async def test_published_article_served(self, client, db): from padelnomics.content.routes import BUILD_DIR @@ -1256,8 +1259,8 @@ class TestAdminDashboardLinks: async def test_dashboard_has_content_links(self, admin_client): resp = await admin_client.get("/admin/") html = (await resp.data).decode() - assert "/admin/templates" in html - assert "/admin/scenarios" in html + # Sidebar always shows the Content entry point (/admin/articles). + # Templates and Scenarios appear in the subnav only when on a content page. assert "/admin/articles" in html diff --git a/web/tests/test_seo.py b/web/tests/test_seo.py index 06fb56a..31e8a1a 100644 --- a/web/tests/test_seo.py +++ b/web/tests/test_seo.py @@ -499,7 +499,8 @@ class TestSeoAdminRoutes: async def test_seo_sidebar_link(self, admin_client, db): resp = await admin_client.get("/admin/") text = await resp.get_data(as_text=True) - assert "SEO Hub" in text + # Sidebar link goes to /admin/seo (labelled "Analytics" in the nav). + assert "/admin/seo" in text # ── Assertion boundary tests ─────────────────────────────────