Remove the MOVED redirects

MOVED and _moved answered 301 for twelve paths the settings cog moved
off of a few days ago. A browser caches a 301 indefinitely, so a path
reused later would be unreachable through no fault of that page, and
a one-person app has no outstanding bookmark to protect. Drop the
table, the routes, its export from app.web, and the tests that pinned
it; the old paths now answer plain 404. Keep the test that every
section of the Sources page exists, rewritten without MOVED.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet committed 2026-09-29 14:50:18 +02:00
1 parent 706b127bc0
commit 92ff2bc069
5 files changed
+24 -78

No files matched your search

+15 -27
View File
@@ -17,7 +17,7 @@ from fastapi.testclient import TestClient
from app.config import Config, ServerConfig
from app.main import create_app
from app.storage import Store
from app.web import MOVED, SETTINGS, TABS
from app.web import SETTINGS, TABS
from app.web.pages import SECTIONS
from auth import AuthConfig
from desk.models import Item
@@ -575,11 +575,10 @@ def test_every_settings_page_has_the_rail_and_not_the_tab_row(client: TestClient
< rail.index('href="/settings/account"')
def test_a_moved_section_is_one_the_sources_page_shows(client: TestClient) -> None:
"""Every old path that lands on a fragment of Sources names a section of
`SECTIONS` or an element inside one, and each section is a `<section
data-section>` on the page, which is what sources.js shows one of. The
old Messages paths land on `#messages`, the log at the end of Runs."""
def test_every_section_of_the_sources_page_exists(client: TestClient) -> None:
"""Each entry of `SECTIONS["/settings/sources"]` is a `<section
data-section>` on the page, which is what sources.js shows one of, and
the log at the end of Runs still answers `#messages`."""
anchors = [anchor for anchor, _ in SECTIONS["/settings/sources"]]
assert anchors == ["job-boards", "company-boards", "runs"]
page = client.get("/settings/sources").text
@@ -587,12 +586,7 @@ def test_a_moved_section_is_one_the_sources_page_shows(client: TestClient) -> No
for anchor in anchors:
assert f'<section class="card" id="{anchor}" data-section>' in page
runs = page[page.index('id="runs"'):]
for to in MOVED.values():
path, _, anchor = to.partition("#")
if anchor:
assert path == "/settings/sources", to
assert anchor in anchors or f'id="{anchor}"' in runs, to
assert MOVED["/messages"] == MOVED["/settings/messages"] == "/settings/sources#messages"
assert 'id="messages"' in runs
def test_settings_is_search_agents(client: TestClient) -> None:
@@ -600,21 +594,15 @@ def test_settings_is_search_agents(client: TestClient) -> None:
assert res.status_code == 302 and res.headers["location"] == "/settings/agents"
@pytest.mark.parametrize(("old", "new"), sorted(MOVED.items()))
def test_an_old_tab_moves_permanently_and_keeps_its_query(
client: TestClient, old: str, new: str) -> None:
"""A merged page's old path lands on its section: the query goes before
the anchor, or the browser would take `#runs?q=` as one fragment."""
assert {"/agents", "/settings/ranking", "/companies", "/sources", "/jobs",
"/schedules", "/messages", "/settings/searches", "/settings/companies",
"/settings/pulls", "/settings/messages", "/account"} <= set(MOVED)
path, _, anchor = new.partition("#")
res = client.get(old, follow_redirects=False)
assert res.status_code == 301 and res.headers["location"] == new
res = client.get(f"{old}?agent=3&q=a+b", follow_redirects=False)
assert res.status_code == 301
assert res.headers["location"] == f"{path}?agent=3&q=a+b" + (f"#{anchor}" if anchor else "")
assert client.get(old).status_code == 200
@pytest.mark.parametrize("old", ["/agents", "/settings/ranking", "/companies", "/sources",
"/jobs", "/schedules", "/messages", "/settings/searches",
"/settings/companies", "/settings/pulls",
"/settings/messages", "/account"])
def test_an_old_tab_path_is_gone(client: TestClient, old: str) -> None:
"""The paths the settings cog moved off of answer 404 now, not a cached
301: a browser caches a 301 indefinitely, so a path reused later would be
unreachable were the redirect still there."""
assert client.get(old).status_code == 404
def test_each_page_loads_only_its_own_script(client: TestClient) -> None: