Q187: a search hit opens the object itself and marks it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f6ed48549
commit
6bedba850c
23 files changed
+213
-68
No files matched your search
@@ -176,6 +176,10 @@ test("onboards, hires, and creates work in the Electron shell", async () => {
|
||||
await page.getByRole("textbox", { name: "Search query" }).fill("production");
|
||||
await expect(page.getByText("Production deploy").first()).toBeVisible();
|
||||
await page.getByRole("dialog", { name: "Search" }).getByRole("button").filter({ hasText: "Production deploy" }).first().click();
|
||||
// The hit opens the task itself.
|
||||
const deployTask = page.getByRole("dialog", { name: "Production deploy" });
|
||||
await expect(deployTask).toBeVisible();
|
||||
await deployTask.getByRole("button", { name: "Close" }).click();
|
||||
|
||||
await page.getByRole("button", { name: "Approvals" }).click();
|
||||
await expect(page.getByText("Production deploy").first()).toBeVisible();
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { _electron as electron, expect, test } from "@playwright/test";
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { seedBuiltinSkillsFixture } from "./builtin-skills-fixture";
|
||||
import { closeApp, onboard } from "./onboard";
|
||||
|
||||
test("a search hit opens the object itself, not just its page", async () => {
|
||||
const profileDir = join(tmpdir(), `agentcompany-new-e2e-search-${randomUUID()}`);
|
||||
mkdirSync(profileDir, { recursive: true });
|
||||
const builtinDir = seedBuiltinSkillsFixture(join(tmpdir(), `agentcompany-new-e2e-search-builtin-${randomUUID()}`));
|
||||
const app = await electron.launch({
|
||||
args: [resolve("out/main/index.js")],
|
||||
env: { ...process.env, AGENTCOMPANY_NEW_PROFILE_DIR: profileDir, AGENTCOMPANY_NEW_AUTORUN: "0", AGENTCOMPANY_NEW_BUILTIN_SKILLS_DIR: builtinDir },
|
||||
});
|
||||
try {
|
||||
const page = await app.firstWindow();
|
||||
await onboard(page, "Search Co");
|
||||
await page.getByRole("button", { name: "Messages" }).click();
|
||||
await page.getByText("general").first().click();
|
||||
await page.getByRole("textbox", { name: "Message" }).fill("zebra crossing note");
|
||||
await page.getByRole("button", { name: "Send" }).click();
|
||||
await page.evaluate(async () => {
|
||||
const api = (window as unknown as { agentCompany: {
|
||||
loadSnapshot: () => Promise<{ ok: true; data: { activeOrgId: string } }>;
|
||||
createDocument: (input: unknown) => Promise<{ ok: boolean }>;
|
||||
} }).agentCompany;
|
||||
const orgId = (await api.loadSnapshot()).data.activeOrgId;
|
||||
await api.createDocument({ orgId, title: "Walrus pricing memo", docType: "memo", content: "Tiers.", authorAgentId: null, reviewerAgentId: null, projectId: null, goalId: null, taskId: null });
|
||||
});
|
||||
await page.getByRole("button", { name: "Home" }).click();
|
||||
|
||||
const search = async (query: string, title: RegExp) => {
|
||||
await page.locator(".search-kbd").click();
|
||||
await page.getByRole("dialog", { name: "Search" }).getByRole("textbox").fill(query);
|
||||
await page.getByRole("dialog", { name: "Search" }).getByRole("button", { name: title }).first().click();
|
||||
};
|
||||
|
||||
// A message opens its conversation with its thread shown and the message marked.
|
||||
await search("zebra", /zebra crossing note/);
|
||||
await expect(page.getByRole("complementary", { name: "Thread" })).toBeVisible();
|
||||
await expect(page.locator("[data-revealed=true]").first()).toContainText("zebra crossing note");
|
||||
|
||||
// A task opens its detail.
|
||||
await search("Operationalize", /Operationalize goal/);
|
||||
await expect(page.getByRole("dialog", { name: /Operationalize goal/ })).toBeVisible();
|
||||
await page.getByRole("dialog", { name: /Operationalize goal/ }).getByRole("button", { name: "Close" }).click();
|
||||
|
||||
// A document opens in the library, selected and marked.
|
||||
await search("Walrus", /Walrus pricing memo/);
|
||||
await expect(page.locator("[data-revealed=true]")).toContainText("Walrus pricing memo");
|
||||
await expect(page.getByRole("heading", { name: "Walrus pricing memo" })).toBeVisible();
|
||||
} finally {
|
||||
await closeApp(app);
|
||||
}
|
||||
});
|
||||
@@ -92,7 +92,12 @@ describe("search service", () => {
|
||||
});
|
||||
});
|
||||
|
||||
expect(search.search({ orgId, employeeId: ownerId, query: "secret", entityTypes: ["chat_message"] })).toHaveLength(1);
|
||||
const hits = search.search({ orgId, employeeId: ownerId, query: "secret", entityTypes: ["chat_message"] });
|
||||
expect(hits).toHaveLength(1);
|
||||
// A hit names its conversation and thread, so opening it shows the message itself.
|
||||
const message = connection.db.prepare("select space_id, thread_id from chat_messages where id = ?").get(hits[0]!.entityId) as { space_id: string; thread_id: string };
|
||||
expect(hits[0]!.facets).toMatchObject({ space: spaceId, thread: message.thread_id });
|
||||
expect(message.space_id).toBe(spaceId);
|
||||
expect(search.search({ orgId, employeeId: outsiderId, query: "secret", entityTypes: ["chat_message"] })).toHaveLength(0);
|
||||
connection.close();
|
||||
});
|
||||
@@ -126,4 +131,23 @@ describe("search service", () => {
|
||||
expect(entries.map((r) => r.facets.state).sort()).toEqual(["active", "superseded"]);
|
||||
connection.close();
|
||||
});
|
||||
|
||||
test("lists only current file versions, as the Files page does", () => {
|
||||
const connection = createConnection();
|
||||
const organization = new OrganizationService(connection.db);
|
||||
const search = new SearchService(connection.db);
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = organization.createOrganization({ organizationName: "Files Co", 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;
|
||||
const file = (id: string, supersededAt: string | null) => connection.db.prepare(`
|
||||
insert into file_objects(id, org_id, name, kind, size_bytes, sha256, storage_path, owner_type, owner_id, created_at, superseded_at)
|
||||
values (?, ?, 'roadmap.md', 'md', 1, ?, '/tmp/x', 'employee', ?, ?, ?)
|
||||
`).run(id, orgId, id, employeeId, new Date().toISOString(), supersededAt);
|
||||
file("fil_old", new Date().toISOString());
|
||||
file("fil_new", null);
|
||||
expect(search.search({ orgId, employeeId, query: "roadmap", entityTypes: ["file"] }).map((hit) => hit.entityId)).toEqual(["fil_new"]);
|
||||
connection.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user