feat: complete public wiki and embedded previews

This commit is contained in:
吉鑫升 committed 2026-08-24 20:40:44 +08:00
1 parent bc49df4561
commit 30943159bf
18 files changed
+926 -48

No files matched your search

@@ -117,6 +117,23 @@ def test_weknora_url_rejects_credentials_and_non_http_schemes() -> None:
LlmWikiConfig.model_validate({"weknora": {"api_base_url": "http://user:pass@weknora.local"}})
def test_weknora_embed_follows_only_protected_binary_redirects() -> None:
from app.gateway.routers import llmwiki as llmwiki_router
assert llmwiki_router._should_follow_weknora_binary_redirect(
"/api/v1/knowledge/doc-one/preview"
)
assert llmwiki_router._should_follow_weknora_binary_redirect(
"/api/v1/knowledge-bases/kb-one/files"
)
assert not llmwiki_router._should_follow_weknora_binary_redirect(
"/api/v1/knowledge/doc-one"
)
assert not llmwiki_router._should_follow_weknora_binary_redirect(
"/api/v1/knowledge-bases/kb-one"
)
def test_agent_config_tracks_allowed_llmwiki_knowledge_bases() -> None:
config = AgentConfig(
name="Research agent",
@@ -547,6 +564,42 @@ async def test_weknora_client_imports_url_manual_content_and_lists_wiki_pages()
assert pages["pages"][0]["slug"] == "guide"
@pytest.mark.asyncio
async def test_weknora_client_reads_ordered_wiki_index_groups() -> None:
async def handler(request: httpx.Request) -> httpx.Response:
assert request.url.path == "/api/v1/knowledgebase/kb-one/wiki/index"
assert request.url.params["types"] == "entity,concept"
assert request.url.params["limit"] == "50"
assert request.url.params["cursor"] == "next-page"
return httpx.Response(
200,
json={
"data": {
"intro": "# Wiki Index",
"version": 2,
"groups": [
{
"type": "entity",
"total": 1,
"items": [{"slug": "entity/one", "title": "实体一"}],
}
],
}
},
)
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
client = WeKnoraClient(base_url="http://weknora.local:8080", http_client=http_client)
index = await client.get_wiki_index(
"kb-one",
types=["entity", "concept"],
limit=50,
cursor="next-page",
)
assert index["groups"][0]["items"][0]["slug"] == "entity/one"
@pytest.mark.asyncio
async def test_weknora_client_creates_updates_and_deletes_wiki_pages() -> None:
seen: list[tuple[str, str]] = []