perf: suppression de répertoire incrémentale au lieu du re-scan complet #BUG-113
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user