test: stop requiring retired archive entrypoints in Python contracts
Independent Staging Quality Gate / validate (push) Successful in 11m24s
Independent Staging Quality Gate / publish (push) Successful in 3m45s

Flip archive tokens to must-not-appear on the session row and session hook only. Keep writeChatSession POST/PATCH and assert delete still uses DELETE. Grep tests/ before deleting frontend symbols.
This commit is contained in:
jesse-ux
2026-09-21 19:20:45 +08:00
parent d3e0edfd1b
commit d2cec17995
6 changed files with 85 additions and 22 deletions
+20 -15
View File
@@ -42,9 +42,6 @@ def test_chat_history_management_actions_are_exposed() -> None:
"确认删除",
"session-delete-overlay",
"togglePinnedSession",
"toggleArchivedSession",
"showArchivedSessions",
"已归档,可在左侧归档中恢复。",
"shareSession",
"share_payload_version",
"messages.map",
@@ -54,13 +51,22 @@ def test_chat_history_management_actions_are_exposed() -> None:
"focus-within",
"收藏",
"重命名",
"归档",
"恢复",
"删除",
"转发",
'fetch(`/api/sessions/${encodeURIComponent(session.id)}`',
):
assert expected in source
row = SESSION_ROW.read_text(encoding="utf-8")
management = (_FRONTEND_SRC / "hooks" / "use-session-management.ts").read_text(encoding="utf-8")
for retired in (
"toggleArchivedSession",
"showArchivedSessions",
"已归档,可在左侧归档中恢复。",
"归档",
"恢复",
):
assert retired not in row
assert retired not in management
def test_chat_session_delete_is_server_controlled_and_granted() -> None:
@@ -74,16 +80,15 @@ def test_chat_session_delete_is_server_controlled_and_granted() -> None:
assert 'using ((select auth.uid()) = user_id)' in migration.lower()
def test_archiving_never_calls_the_delete_endpoint() -> None:
def test_session_archive_is_retired_and_write_helper_still_patches() -> None:
source = _home_surface()
write_contract = SESSION_WRITE_CONTRACT.read_text(encoding="utf-8")
start = source.index("function toggleArchivedSession")
end = source.index("async function shareSession", start)
archive_action = source[start:end]
# Former tokens: setArchivedSessionIds and no `/api/sessions/` in the slice.
# Archive is now a metadata PATCH; the write helper uses PATCH for update.
assert 'writeChatSession(sessionId, { archived_at: nextArchivedAt }, "update")' in archive_action
assert "archived_at: nextArchivedAt" in archive_action
assert 'method: "DELETE"' not in archive_action
assert "DELETE" not in archive_action
assert "function toggleArchivedSession" not in source
assert "toggleArchivedView" not in source
assert 'writeChatSession(sessionId, { archived_at: nextArchivedAt }, "update")' not in source
assert "archived_at: nextArchivedAt" not in source
assert 'method: mode === "create" ? "POST" : "PATCH"' in write_contract
start = source.index("async function deleteSession")
end = source.index("function togglePinnedSession", start)
delete_action = source[start:end]
assert 'method: "DELETE"' in delete_action