- clic sur un repertoire de l'arbre (modes focus vault et All) ouvre un onglet de navigation dedie qui coexiste avec les onglets de fichiers ouverts
- vue: sous-repertoires cliquables, facettes Vaults/Tags/Extensions (meme mecanisme que la recherche), tris Pertinence/Date, bouton Sauver; tags indexes exposes par GET /api/vault/{v}/files
- BUG-100: showWelcome re-injecte la section Raccourcis & Astuces et goHome efface la recherche globale + le filtre de la sidebar
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
# tests/test_nav_files.py — Navigation page listing (#158)
|
|
#
|
|
# The vault home / navigation page lists a directory with its indexed tags so
|
|
# the Vaults · Tags · Extensions facets can filter the listing client-side.
|
|
# The tags must survive the endpoint's response_model.
|
|
from __future__ import annotations
|
|
|
|
|
|
def test_vault_files_expose_indexed_tags(client):
|
|
"""Every entry carries a `tags` list; markdown tags come from the index."""
|
|
resp = client.get("/api/vault/TestVault/files", params={"recursive": False})
|
|
assert resp.status_code == 200
|
|
|
|
data = resp.json()
|
|
files = data["files"]
|
|
assert files, "expected a non-empty listing"
|
|
|
|
# The field is always present (response_model must not strip it)
|
|
assert all("tags" in f for f in files)
|
|
|
|
by_name = {f["name"]: f for f in files}
|
|
assert "note1.md" in by_name
|
|
assert sorted(by_name["note1.md"]["tags"]) == ["python", "tutorial"]
|
|
|
|
# Unindexed / tagless files keep an empty list, never null
|
|
assert sorted(by_name["note2.md"]["tags"]) == ["devops", "docker"]
|
|
for f in files:
|
|
assert isinstance(f["tags"], list)
|
|
|
|
|
|
def test_vault_files_tags_in_subdirectory(client):
|
|
"""Tags are resolved per directory listing, not only at the vault root."""
|
|
resp = client.get(
|
|
"/api/vault/TestVault/files",
|
|
params={"dir": "Projets", "recursive": False},
|
|
)
|
|
assert resp.status_code == 200
|
|
|
|
files = resp.json()["files"]
|
|
by_name = {f["name"]: f for f in files}
|
|
assert "projet.md" in by_name
|
|
assert sorted(by_name["projet.md"]["tags"]) == ["projet", "python"]
|
|
|
|
|
|
def test_indexed_tags_unknown_vault_returns_empty():
|
|
"""Index miss (unknown vault/file) degrades to an empty tag list."""
|
|
from backend.services.vaults import _indexed_tags
|
|
|
|
assert _indexed_tags("NoSuchVault", "ghost.md") == []
|