fix: normalize path prefix in wiki search so tenant filtering matches
get_wikijs_namespace() returns '/users/{user}' with a leading slash while
Wiki.js search results carry paths without one, so the prefix filter in
search_pages rejected every result - wiki search returned empty for every
tenant. Found by cross-repo integration verification; the librarian now
gets real search results. Compare slash-normalized on both sides.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ These tests mock the GraphQL layer.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from src.clients.wikijs_client import WikiJSClient
|
||||
|
||||
@@ -125,3 +126,22 @@ class TestListPagesLimitAfterFilter:
|
||||
pages = await client.list_pages(limit=10)
|
||||
|
||||
assert pages[0]["tags"] == []
|
||||
|
||||
|
||||
class TestSearchPagesPrefixNormalization:
|
||||
"""search_pages must match Wiki.js paths (no leading slash) against
|
||||
get_wikijs_namespace prefixes (leading slash)."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_slashed_prefix_matches_unslashed_paths(self):
|
||||
client = WikiJSClient("http://wiki.test", "k")
|
||||
client._execute_query = AsyncMock(return_value={
|
||||
"pages": {"search": {"results": [
|
||||
{"id": "399", "path": "users/llm_tester/docker-guide",
|
||||
"title": "Docker Guide", "description": ""},
|
||||
{"id": "1", "path": "users/jpmschweitzer/other",
|
||||
"title": "Other", "description": ""},
|
||||
]}}
|
||||
})
|
||||
results = await client.search_pages("docker", path_prefix="/users/llm_tester")
|
||||
assert [r["id"] for r in results] == ["399"]
|
||||
|
||||
Reference in New Issue
Block a user