perf: suppression de répertoire incrémentale au lieu du re-scan complet #BUG-113
CI / lint (push) Successful in 3m9s
CI / security (push) Successful in 1m55s
CI / test (push) Successful in 5m25s
CI / build (push) Successful in 1m48s
CI / e2e (push) Successful in 17m56s

This commit is contained in:
2026-10-14 16:56:56 -04:00
parent 6257adb46b
commit 2ebfe74459
13 changed files with 118 additions and 16 deletions
+36
View File
@@ -340,6 +340,42 @@ class TestDirectoryCRUD:
data = resp.json()
assert data["success"] is True
def test_delete_directory_subtree_clears_index(self, client):
"""BUG-113 : suppression incrémentale — aucun fantôme dans paths ni
dans l'index inversé, sans re-scan complet de la vault."""
# Create files inside the directory
for name in ("alpha.md", "nested/beta.md"):
r = client.post("/api/file/TestVault", json={
"path": f"Projets/{name}",
"content": f"contenu unique {name}",
})
assert r.status_code == 200
# Indexed before deletion
paths_before = client.get("/api/vault/TestVault/paths").json()["results"]
assert any(p["path"] == "Projets/alpha.md" for p in paths_before)
hit = client.get("/api/search", params={"q": "alpha", "vault": "TestVault"}).json()
results = hit.get("results", hit if isinstance(hit, list) else [])
assert any(r["path"] == "Projets/alpha.md" for r in results)
# Delete the whole directory
resp = client.delete("/api/directory/TestVault", params={"path": "Projets"})
assert resp.status_code == 200
data = resp.json()
assert data["success"] is True
assert data["deleted_count"] >= 2
# No ghost in flat paths
paths_after = client.get("/api/vault/TestVault/paths").json()["results"]
ghost_dirs = [p["path"] for p in paths_after if p["path"].startswith("Projets")]
assert ghost_dirs == [], f"fantômes dans paths : {ghost_dirs}"
# No ghost in inverted index (full-text search)
hit = client.get("/api/search", params={"q": "alpha", "vault": "TestVault"}).json()
results = hit.get("results", hit if isinstance(hit, list) else [])
assert all(r["path"] != "Projets/alpha.md" for r in results)
assert all(r["path"] != "Projets/nested/beta.md" for r in results)
# ═══════════════════════════════════════════════════════════════════
# Search & Tags (supplement existing tests)