feat(ticket): 列表支持按标题/正文搜索

手机端工单列表要能像任务、知识一样搜。与知识列表同一套 ilike 匹配,标题记不清时正文关键词也能命中;补测试覆盖标题命中、正文命中、无结果三种情况。
This commit is contained in:
Steven
2026-11-10 16:33:54 +08:00
parent e127d5bd40
commit d58cf7922e
2 changed files with 64 additions and 0 deletions
+58
View File
@@ -315,6 +315,64 @@ async def test_ticket_list_scopes(client: AsyncClient) -> None:
assert empty["tickets"] == []
@pytest.mark.asyncio
async def test_ticket_list_search(client: AsyncClient) -> None:
"""手机端工单列表的搜索框:标题和正文都能命中,不相关的不出现。"""
owner = await login(client)
ws = await create_workspace(client, owner, "工单搜索")
helper = await _member(client, owner, ws)
task = await _task(client, owner, ws["id"], "支付回调重复")
unwrap(
await client.patch(
f"{V1}/workspaces/{ws['id']}/items/{task['id']}",
json={"body_md": "网关在 23:00 之后重复回调了三次", "version": task["version"]},
headers=owner["headers"],
)
)
unwrap(
await client.post(
f"{V1}/workspaces/{ws['id']}/items/{task['id']}/promote",
json={"assignee_id": helper["user_id"]},
headers=owner["headers"],
)
)
other = await _task(client, owner, ws["id"], "登录页白屏")
unwrap(
await client.post(
f"{V1}/workspaces/{ws['id']}/items/{other['id']}/promote",
json={"assignee_id": helper["user_id"]},
headers=owner["headers"],
)
)
by_title = unwrap(
await client.get(
f"{V1}/workspaces/{ws['id']}/tickets",
params={"role": "all", "q": "支付"},
headers=helper["headers"],
)
)
assert [t["title"] for t in by_title["tickets"]] == ["支付回调重复"]
by_body = unwrap(
await client.get(
f"{V1}/workspaces/{ws['id']}/tickets",
params={"role": "all", "q": "网关"},
headers=helper["headers"],
)
)
assert [t["title"] for t in by_body["tickets"]] == ["支付回调重复"]
miss = unwrap(
await client.get(
f"{V1}/workspaces/{ws['id']}/tickets",
params={"role": "all", "q": "不存在的关键词"},
headers=helper["headers"],
)
)
assert miss["tickets"] == []
@pytest.mark.asyncio
async def test_cross_tenant_ticket_invisible(client: AsyncClient) -> None:
alice = await login(client)