7.77.0 — corbeille réparée (FK favorites/recents) + MCP workspaces
- detach_page_references : nettoyage des références NO ACTION avant toute suppression définitive (unitaire, Empty Trash, purge 30 j) - MCP : list_workspaces / get_workspace ; descriptions collections clarifiées (bases de données, pas des workspaces) - 96 tests verts sur le périmètre (MCP, trash, cohérence)
This commit is contained in:
@@ -68,11 +68,35 @@ def test_mcp_handshake_et_outils(client, jeton):
|
||||
assert r.json()["result"]["serverInfo"]["name"] == "flowdeck"
|
||||
r = _rpc(client, jeton, 2, "tools/list")
|
||||
noms = [t["name"] for t in r.json()["result"]["tools"]]
|
||||
assert noms == ["list_collections", "get_collection", "get_page",
|
||||
assert noms == ["list_workspaces", "get_workspace",
|
||||
"list_collections", "get_collection", "get_page",
|
||||
"search_pages", "list_repos", "create_page",
|
||||
"update_page", "create_collection"]
|
||||
|
||||
|
||||
def test_mcp_workspaces(client, jeton):
|
||||
with get_conn() as conn:
|
||||
conn.execute("INSERT OR IGNORE INTO users (id, login) VALUES (1, 'tester')")
|
||||
cur = conn.execute(
|
||||
"INSERT INTO workspaces (name, owner_id) VALUES ('Techno', 1)")
|
||||
wid = cur.lastrowid
|
||||
conn.execute(
|
||||
"INSERT INTO pages (workspace, workspace_id, title, parent_section) "
|
||||
"VALUES ('Techno', ?, 'Page racine', 'Private')", (wid,))
|
||||
conn.execute(
|
||||
"INSERT INTO pages (workspace, workspace_id, title, parent_section, deleted_at) "
|
||||
"VALUES ('Techno', ?, 'Page corbeille', 'Private', '2026-10-11 10:00:00')", (wid,))
|
||||
conn.commit()
|
||||
ws = _appel(client, jeton, 70, "list_workspaces")
|
||||
techno = [w for w in ws if w["name"] == "Techno"]
|
||||
assert techno and techno[0]["page_count"] == 1 # la corbeille ne compte pas
|
||||
detail = _appel(client, jeton, 71, "get_workspace", {"id": wid})
|
||||
assert detail["workspace"]["name"] == "Techno"
|
||||
assert [p["title"] for p in detail["pages"]] == ["Page racine"]
|
||||
res = _appel(client, jeton, 72, "get_workspace", {"id": 99999})
|
||||
assert "introuvable" in res["erreur"]
|
||||
|
||||
|
||||
def test_mcp_collections_et_pages(client, jeton, donnees):
|
||||
cols = _appel(client, jeton, 1, "list_collections")
|
||||
alpha = [c for c in cols if c["name"] == "Projet Alpha"]
|
||||
|
||||
@@ -32,6 +32,32 @@ def _row(page_id):
|
||||
).fetchone()
|
||||
|
||||
|
||||
def test_permanent_delete_page_referenced_by_favorites_and_recents(client):
|
||||
"""Régression 7.77.0 (cas réel de Bruno, 2026-10-22) : une page
|
||||
réelle — ouverte (recents) et/ou favorite — ne pouvait plus être
|
||||
supprimée définitivement : favorites.page_id et recents.page_id
|
||||
référencent pages(id) sans CASCADE, PRAGMA foreign_keys=ON →
|
||||
IntegrityError → 500 « Delete failed », et Empty Trash (une seule
|
||||
transaction) échouait en bloc. Les pages synthétiques des anciens
|
||||
tests n'avaient ni favori ni récent : elles passaient."""
|
||||
from app.db import get_conn
|
||||
|
||||
login_test_client(client)
|
||||
pid = _mk_page(title="Page réelle de Bruno")
|
||||
with get_conn() as conn:
|
||||
conn.execute("INSERT INTO favorites (user_id, page_id, position) VALUES (1, ?, 0)", (pid,))
|
||||
conn.execute("INSERT INTO recents (user_id, page_id, workspace) VALUES (1, ?, 'x')", (pid,))
|
||||
conn.commit()
|
||||
r = client.post(f"/api/pages/{pid}/trash")
|
||||
assert r.status_code == 200
|
||||
r = client.delete(f"/board/api/trash/{pid}")
|
||||
assert r.status_code == 200, r.text
|
||||
assert _row(pid) is None
|
||||
with get_conn() as conn:
|
||||
assert conn.execute("SELECT COUNT(*) FROM favorites WHERE page_id=?", (pid,)).fetchone()[0] == 0
|
||||
assert conn.execute("SELECT COUNT(*) FROM recents WHERE page_id=?", (pid,)).fetchone()[0] == 0
|
||||
|
||||
|
||||
def test_trash_requires_session(client):
|
||||
pid = _mk_page()
|
||||
anon_csrf(client) # anonyme mais CSRF valide → on veut le 401, pas le 403
|
||||
|
||||
Reference in New Issue
Block a user