updates on catalog search and suggestions in backend
This commit is contained in:
@@ -87,5 +87,23 @@ def test_openapi_schema_lists_all_routers(client) -> None:
|
||||
resp = client.get("/openapi.json")
|
||||
assert resp.status_code == 200
|
||||
paths = resp.json()["paths"]
|
||||
for expected in ("/api/health", "/api/brands", "/api/search", "/api/chat", "/api/catalog/generate"):
|
||||
for expected in ("/api/health", "/api/brands", "/api/search", "/api/suggest",
|
||||
"/api/chat", "/api/catalog/generate"):
|
||||
assert expected in paths, f"missing route: {expected}"
|
||||
|
||||
|
||||
def test_suggest_works_without_a_database(client) -> None:
|
||||
"""Autocomplete must degrade, not 500, when the catalog is unreachable.
|
||||
|
||||
This suite runs with no reachable database, so this pins that the search
|
||||
box keeps suggesting from the static brand table instead of erroring - a
|
||||
failing suggest call must never block someone from typing and searching.
|
||||
"""
|
||||
resp = client.get("/api/suggest", params={"q": "cavin"})
|
||||
assert resp.status_code == 200
|
||||
labels = [s["label"] for s in resp.json()["suggestions"]]
|
||||
assert "Cavinkare" in labels
|
||||
|
||||
|
||||
def test_suggest_requires_a_query(client) -> None:
|
||||
assert client.get("/api/suggest").status_code == 422
|
||||
|
||||
Reference in New Issue
Block a user