From ed6140af9ee9546f4e3e19c3c534cbc4dec5ab81 Mon Sep 17 00:00:00 2001 From: James Long Date: Fri, 8 May 2026 11:02:57 -0400 Subject: [PATCH] fix tests --- .../cmd/tui/dialog-workspace-create.test.ts | 19 ------- .../test/control-plane/workspace.test.ts | 50 ++++++++++--------- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/packages/opencode/test/cli/cmd/tui/dialog-workspace-create.test.ts b/packages/opencode/test/cli/cmd/tui/dialog-workspace-create.test.ts index c2811494bf..00b480ca00 100644 --- a/packages/opencode/test/cli/cmd/tui/dialog-workspace-create.test.ts +++ b/packages/opencode/test/cli/cmd/tui/dialog-workspace-create.test.ts @@ -25,23 +25,4 @@ describe("recentConnectedWorkspaces", () => { expect(recent.map((workspace) => workspace.id)).toEqual(["wrk_a", "wrk_d", "wrk_e"]) }) - - test("omits the active workspace before limiting recent workspaces", () => { - const workspaces = [ - { id: "wrk_a", name: "alpha", timeUsed: 400 }, - { id: "wrk_b", name: "beta", timeUsed: 300 }, - { id: "wrk_c", name: "gamma", timeUsed: 200 }, - { id: "wrk_d", name: "delta", timeUsed: 100 }, - ] - - const { recent, hasMore } = recentConnectedWorkspaces({ - workspaces, - status: () => "connected", - limit: 3, - omitWorkspaceID: "wrk_a", - }) - - expect(recent.map((workspace) => workspace.id)).toEqual(["wrk_b", "wrk_c", "wrk_d"]) - expect(hasMore).toBe(false) - }) }) diff --git a/packages/opencode/test/control-plane/workspace.test.ts b/packages/opencode/test/control-plane/workspace.test.ts index b5ff8f66c5..c29a09eb14 100644 --- a/packages/opencode/test/control-plane/workspace.test.ts +++ b/packages/opencode/test/control-plane/workspace.test.ts @@ -469,7 +469,15 @@ describe("workspace CRUD", () => { expect(recorded.calls.configure).toHaveLength(1) expect(recorded.calls.configure[0]).toMatchObject({ id: workspaceID, type, directory: null }) expect(recorded.calls.create).toHaveLength(1) - expect(recorded.calls.create[0].info).toEqual(info) + expect(recorded.calls.create[0].info).toEqual({ + id: workspaceID, + type, + branch: "configured-branch", + name: "Configured Name", + directory: targetDir, + extra: { configured: true }, + projectID: Instance.project.id, + }) expect(JSON.parse(recorded.calls.create[0].env.OPENCODE_AUTH_CONTENT ?? "{}")).toEqual({ test: { type: "api", key: "secret" }, }) @@ -953,35 +961,29 @@ describe("workspace sync state", () => { }) }) - test("startWorkspaceSyncing starts only workspaces with sessions", async () => { + test("startWorkspaceSyncing starts all workspaces", async () => { await withInstance(async (dir) => { - const withSessionType = unique("with-session") - const withoutSessionType = unique("without-session") - const withSession = workspaceInfo(Instance.project.id, withSessionType) - const withoutSession = workspaceInfo(Instance.project.id, withoutSessionType) - const withSessionDir = path.join(dir, "with-session") - const withoutSessionDir = path.join(dir, "without-session") - await fs.mkdir(withSessionDir, { recursive: true }) - await fs.mkdir(withoutSessionDir, { recursive: true }) - insertWorkspace(withSession) - insertWorkspace(withoutSession) - registerAdapter(Instance.project.id, withSessionType, localAdapter(withSessionDir).adapter) - registerAdapter(Instance.project.id, withoutSessionType, localAdapter(withoutSessionDir).adapter) - attachSessionToWorkspace( - (await AppRuntime.runPromise(SessionNs.Service.use((svc) => svc.create({})))).id, - withSession.id, - ) + const firstType = unique("first") + const secondType = unique("second") + const first = workspaceInfo(Instance.project.id, firstType) + const second = workspaceInfo(Instance.project.id, secondType) + await fs.mkdir(path.join(dir, "first"), { recursive: true }) + await fs.mkdir(path.join(dir, "second"), { recursive: true }) + insertWorkspace(first) + insertWorkspace(second) + registerAdapter(Instance.project.id, firstType, localAdapter(path.join(dir, "first")).adapter) + registerAdapter(Instance.project.id, secondType, localAdapter(path.join(dir, "second")).adapter) startWorkspaceSyncing(Instance.project.id) await eventually(() => - workspaceStatus().then((status) => - expect(status.find((item) => item.workspaceID === withSession.id)?.status).toBe("connected"), - ), + workspaceStatus().then((status) => { + expect(status.find((item) => item.workspaceID === first.id)?.status).toBe("connected") + expect(status.find((item) => item.workspaceID === second.id)?.status).toBe("connected") + }), ) - expect((await workspaceStatus()).find((item) => item.workspaceID === withoutSession.id)?.status).toBeUndefined() - await removeWorkspace(withSession.id) - await removeWorkspace(withoutSession.id) + await removeWorkspace(first.id) + await removeWorkspace(second.id) }) })