Q184: the page, its sections, filters and selections survive page switches and restarts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2790d88186
commit
72cf57ce3a
27 files changed
+235
-38
No files matched your search
@@ -0,0 +1,67 @@
|
||||
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("the page, its section and its view survive page switches and a restart", async () => {
|
||||
const profileDir = join(tmpdir(), `agentcompany-new-e2e-view-${randomUUID()}`);
|
||||
mkdirSync(profileDir, { recursive: true });
|
||||
const builtinDir = seedBuiltinSkillsFixture(join(tmpdir(), `agentcompany-new-e2e-view-builtin-${randomUUID()}`));
|
||||
const launch = () => 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 },
|
||||
});
|
||||
|
||||
let app = await launch();
|
||||
let page = await app.firstWindow();
|
||||
await onboard(page, "View Co");
|
||||
await page.getByRole("button", { name: "Work" }).click();
|
||||
await page.locator(".segment", { hasText: "List" }).click();
|
||||
await page.getByRole("button", { name: "Settings" }).click();
|
||||
await page.getByRole("button", { name: "Providers" }).click();
|
||||
// Coming back to a page returns to where it was left.
|
||||
await page.getByRole("button", { name: "Work" }).click();
|
||||
await expect(page.locator(".segment.active")).toHaveText("List");
|
||||
await page.getByRole("button", { name: "Settings" }).click();
|
||||
await expect(page.getByRole("button", { name: "Providers" })).toHaveClass(/active/);
|
||||
// A link to a workspace still lands on General, where the workspace is shown.
|
||||
const folder = join(tmpdir(), `agentcompany-new-e2e-view-ws-${randomUUID()}`);
|
||||
mkdirSync(folder, { recursive: true });
|
||||
await page.evaluate(async (localPath) => {
|
||||
const api = (window as unknown as { agentCompany: {
|
||||
loadSnapshot: () => Promise<{ ok: true; data: { activeOrgId: string; workspaces: Array<{ id: string; name: string }> } }>;
|
||||
createWorkspace: (input: unknown) => Promise<{ ok: boolean }>;
|
||||
createTask: (input: unknown) => Promise<{ ok: boolean }>;
|
||||
} }).agentCompany;
|
||||
const orgId = (await api.loadSnapshot()).data.activeOrgId;
|
||||
await api.createWorkspace({ orgId, name: "Linked repo", localPath, projectId: null });
|
||||
const workspaceId = (await api.loadSnapshot()).data.workspaces.find((workspace) => workspace.name === "Linked repo")!.id;
|
||||
await api.createTask({
|
||||
orgId, title: "Uses the linked repo", description: "d", status: "backlog", assigneeAgentId: null, risk: "low",
|
||||
projectId: null, goalId: null, workspaceId, priority: "normal", requiresFilesystem: false,
|
||||
});
|
||||
}, folder);
|
||||
await page.getByRole("button", { name: "Work" }).click();
|
||||
await page.getByRole("button", { name: /Uses the linked repo/ }).first().click();
|
||||
await page.getByRole("button", { name: "Open workspace Linked repo" }).click();
|
||||
await expect(page.getByRole("button", { name: "General" })).toHaveClass(/active/);
|
||||
await expect(page.getByRole("group", { name: "Linked repo" })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Providers" }).click();
|
||||
await expect.poll(() => page.evaluate(async () => {
|
||||
const api = (window as unknown as { agentCompany: { loadSnapshot: () => Promise<{ ok: true; data: { viewState: Record<string, unknown> } }> } }).agentCompany;
|
||||
return (await api.loadSnapshot()).data.viewState.route;
|
||||
})).toBe("settings");
|
||||
await closeApp(app);
|
||||
|
||||
// A restart opens the same page and section, and the view the work was left in.
|
||||
app = await launch();
|
||||
page = await app.firstWindow();
|
||||
await expect(page.getByRole("button", { name: "Providers" })).toHaveClass(/active/);
|
||||
await expect(page.getByRole("button", { name: "Settings" })).toHaveAttribute("aria-current", "page");
|
||||
await page.getByRole("button", { name: "Work" }).click();
|
||||
await expect(page.locator(".segment.active")).toHaveText("List");
|
||||
await closeApp(app);
|
||||
});
|
||||
@@ -35,7 +35,7 @@ describe("domain services", () => {
|
||||
const connection = createConnection();
|
||||
|
||||
const rows = connection.db.prepare("select version from schema_migrations order by version asc").all() as Array<{ version: number }>;
|
||||
expect(rows.map((row) => row.version)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105]);
|
||||
expect(rows.map((row) => row.version)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106]);
|
||||
connection.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { DatabaseConnection } from "../../src/main/database/connection";
|
||||
import { loadViewState, saveViewState } from "../../src/main/services/view-state";
|
||||
|
||||
describe("view state", () => {
|
||||
test("keeps each key's latest value, including keys with dots and colons, and forgets on null", () => {
|
||||
const connection = new DatabaseConnection(join(tmpdir(), `ac-view-state-${randomUUID()}.db`));
|
||||
const db = connection.db;
|
||||
expect(loadViewState(db)).toEqual({});
|
||||
saveViewState(db, "route", "work");
|
||||
saveViewState(db, "org_1:work.view", "list");
|
||||
saveViewState(db, "org_1:work.scope", { kind: "goal", id: "gol_1" });
|
||||
saveViewState(db, "route", "settings");
|
||||
expect(loadViewState(db)).toEqual({ route: "settings", "org_1:work.view": "list", "org_1:work.scope": { kind: "goal", id: "gol_1" } });
|
||||
saveViewState(db, "org_1:work.scope", null);
|
||||
expect(loadViewState(db)).toEqual({ route: "settings", "org_1:work.view": "list" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user