Q190: search finds Chinese and other non-English words inside text, in any case
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc7e214b65
commit
32c712f86f
3 files changed
+63
-17
No files matched your search
@@ -71,6 +71,20 @@ test("a search hit opens the object itself, not just its page", async () => {
|
||||
await expect(searchDialog.getByRole("button", { name: "Show more" })).toHaveCount(0);
|
||||
await searchDialog.getByRole("textbox").fill("qqzzxx");
|
||||
await expect(searchDialog.getByText("Nothing matches “qqzzxx”.")).toBeVisible();
|
||||
// Chinese words are found inside longer text.
|
||||
await page.evaluate(async () => {
|
||||
const api = (window as unknown as { agentCompany: {
|
||||
loadSnapshot: () => Promise<{ ok: true; data: { activeOrgId: string } }>;
|
||||
createTask: (input: unknown) => Promise<{ ok: boolean }>;
|
||||
} }).agentCompany;
|
||||
const orgId = (await api.loadSnapshot()).data.activeOrgId;
|
||||
await api.createTask({
|
||||
orgId, title: "季度复盘会议", description: "d", status: "backlog", assigneeAgentId: null, risk: "low",
|
||||
projectId: null, goalId: null, workspaceId: null, priority: "normal", requiresFilesystem: false,
|
||||
});
|
||||
});
|
||||
await searchDialog.getByRole("textbox").fill("复盘");
|
||||
await expect(searchDialog.getByRole("button", { name: /季度复盘会议/ })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
// A message opens its conversation with its thread shown and the message marked.
|
||||
|
||||
@@ -176,4 +176,32 @@ describe("search service", () => {
|
||||
expect(search.search({ orgId, employeeId, query: "nothinglikethis", limit: 12 })).toEqual({ results: [], total: 0 });
|
||||
connection.close();
|
||||
});
|
||||
|
||||
test("finds Chinese words inside text, alone or with English words", () => {
|
||||
const connection = createConnection();
|
||||
const organization = new OrganizationService(connection.db);
|
||||
const search = new SearchService(connection.db);
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = organization.createOrganization({ organizationName: "中文公司", employeeName: "Dana Lee", mission: "m", goal: "g" });
|
||||
for (const title of ["数据迁移计划", "数据迁移 rollout plan", "Quarterly rollout", "100%_完成", "CAFÉ migration"]) {
|
||||
organization.createTask({
|
||||
orgId, title, description: "d", status: TASK_STATUS.BACKLOG, assigneeAgentId: null, risk: "low",
|
||||
projectId: null, goalId: null, workspaceId: null, priority: "normal", requiresFilesystem: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
const employeeId = (connection.db.prepare("select id from employees where org_id = ?").get(orgId) as { id: string }).id;
|
||||
const titles = (query: string) => search.search({ orgId, employeeId, query, entityTypes: ["task"] }).results.map((hit) => hit.title).sort();
|
||||
expect(titles("迁移")).toEqual(["数据迁移 rollout plan", "数据迁移计划"]);
|
||||
expect(titles("迁移 rollout")).toEqual(["数据迁移 rollout plan"]);
|
||||
expect(titles("rollout")).toEqual(["Quarterly rollout", "数据迁移 rollout plan"]);
|
||||
// LIKE wildcards in the words are taken literally.
|
||||
expect(titles("%_完")).toEqual(["100%_完成"]);
|
||||
// Letters outside ASCII match whatever their case.
|
||||
expect(titles("café")).toEqual(["CAFÉ migration"]);
|
||||
expect(titles("CAFÉ")).toEqual(["CAFÉ migration"]);
|
||||
expect(search.search({ orgId, employeeId, query: "!!", entityTypes: ["task"] })).toEqual({ results: [], total: 0 });
|
||||
connection.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user