Q32: documents and knowledge appear in global search
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c8233d258
commit
cb464c3ee4
5 files changed
+58
No files matched your search
@@ -6,6 +6,8 @@ import { DatabaseConnection } from "../../src/main/database/connection";
|
||||
import { ChatService } from "../../src/main/services/chat-service";
|
||||
import { OrganizationService } from "../../src/main/services/organization-service";
|
||||
import { SearchService } from "../../src/main/services/search-service";
|
||||
import { DocumentService } from "../../src/main/services/document-service";
|
||||
import { KnowledgeService } from "../../src/main/services/knowledge-service";
|
||||
import { TASK_STATUS } from "../../src/shared/domain";
|
||||
import { createId } from "../../src/shared/ids";
|
||||
|
||||
@@ -94,4 +96,34 @@ describe("search service", () => {
|
||||
expect(search.search({ orgId, employeeId: outsiderId, query: "secret", entityTypes: ["chat_message"] })).toHaveLength(0);
|
||||
connection.close();
|
||||
});
|
||||
|
||||
test("finds documents and knowledge by their bodies, with state facets", () => {
|
||||
const connection = createConnection();
|
||||
const organization = new OrganizationService(connection.db);
|
||||
const search = new SearchService(connection.db);
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = organization.createOrganization({ organizationName: "Lib", employeeName: "Dana Lee", mission: "m", goal: "g" });
|
||||
});
|
||||
const employeeId = (connection.db.prepare("select id from employees where org_id = ?").get(orgId) as { id: string }).id;
|
||||
new DocumentService(connection.db).create({
|
||||
orgId, title: "Pricing memo", docType: "memo", content: "Enterprise tier costs twelve hundred dollars.",
|
||||
authorAgentId: null, reviewerAgentId: null, projectId: null, goalId: null, taskId: null,
|
||||
});
|
||||
const knowledge = new KnowledgeService(connection.db);
|
||||
const oldId = knowledge.create({
|
||||
orgId, topic: "Refund window", category: "policy", content: "Refunds within fourteen days.", importance: "normal",
|
||||
sourceType: "employee", sourceId: null, scopeType: "organization", scopeId: null, validUntil: null, supersedesId: null,
|
||||
});
|
||||
knowledge.create({
|
||||
orgId, topic: "Refund window", category: "policy", content: "Refunds within thirty days.", importance: "normal",
|
||||
sourceType: "employee", sourceId: null, scopeType: "organization", scopeId: null, validUntil: null, supersedesId: oldId,
|
||||
});
|
||||
|
||||
const docs = search.search({ orgId, employeeId, query: "twelve hundred" });
|
||||
expect(docs.map((r) => [r.entityType, r.title, r.facets.kind])).toEqual([["document", "Pricing memo", "memo"]]);
|
||||
const entries = search.search({ orgId, employeeId, query: "refunds", entityTypes: ["knowledge"] });
|
||||
expect(entries.map((r) => r.facets.state).sort()).toEqual(["active", "superseded"]);
|
||||
connection.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user