Configure lefthook formatter checks (#231)

* Add lefthook formatter checks

* Fix SDK mode hydration

* Stabilize SDK mode integration test
This commit is contained in:
Nathan Flurry 2026-03-10 23:03:11 -07:00 committed by GitHub
parent 0471214d65
commit d2346bafb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
282 changed files with 5840 additions and 8399 deletions

View file

@ -7,7 +7,7 @@ import type { ChildProcess } from "node:child_process";
const { spawnMock, execFileSyncMock } = vi.hoisted(() => ({
spawnMock: vi.fn(),
execFileSyncMock: vi.fn()
execFileSyncMock: vi.fn(),
}));
vi.mock("node:child_process", async () => {
@ -15,7 +15,7 @@ vi.mock("node:child_process", async () => {
return {
...actual,
spawn: spawnMock,
execFileSync: execFileSyncMock
execFileSync: execFileSyncMock,
};
});
@ -37,16 +37,16 @@ function healthyMetadataResponse(): { ok: boolean; json: () => Promise<unknown>
json: async () => ({
runtime: "rivetkit",
actorNames: {
workspace: {}
}
})
workspace: {},
},
}),
};
}
function unhealthyMetadataResponse(): { ok: boolean; json: () => Promise<unknown> } {
return {
ok: false,
json: async () => ({})
json: async () => ({}),
};
}
@ -66,11 +66,11 @@ describe("backend manager", () => {
opencode_poll_interval: 2,
github_poll_interval: 30,
backup_interval_secs: 3600,
backup_retention_days: 7
backup_retention_days: 7,
},
providers: {
daytona: { image: "ubuntu:24.04" }
}
daytona: { image: "ubuntu:24.04" },
},
});
beforeEach(() => {
@ -116,7 +116,7 @@ describe("backend manager", () => {
const fakeChild = Object.assign(new EventEmitter(), {
pid: process.pid,
unref: vi.fn()
unref: vi.fn(),
}) as unknown as ChildProcess;
spawnMock.mockReturnValue(fakeChild);
@ -125,14 +125,8 @@ describe("backend manager", () => {
expect(spawnMock).toHaveBeenCalledTimes(1);
const launchCommand = spawnMock.mock.calls[0]?.[0];
const launchArgs = spawnMock.mock.calls[0]?.[1] as string[] | undefined;
expect(
launchCommand === "pnpm" ||
launchCommand === "bun" ||
(typeof launchCommand === "string" && launchCommand.endsWith("/bun"))
).toBe(true);
expect(launchArgs).toEqual(
expect.arrayContaining(["start", "--host", config.backend.host, "--port", String(config.backend.port)])
);
expect(launchCommand === "pnpm" || launchCommand === "bun" || (typeof launchCommand === "string" && launchCommand.endsWith("/bun"))).toBe(true);
expect(launchArgs).toEqual(expect.arrayContaining(["start", "--host", config.backend.host, "--port", String(config.backend.port)]));
if (launchCommand === "pnpm") {
expect(launchArgs).toEqual(expect.arrayContaining(["exec", "bun", "src/index.ts"]));
}
@ -148,9 +142,7 @@ describe("backend manager", () => {
mkdirSync(stateDir, { recursive: true });
writeFileSync(versionPath, "test-build", "utf8");
const fetchMock = vi
.fn<() => Promise<{ ok: boolean; json: () => Promise<unknown> }>>()
.mockResolvedValue(healthyMetadataResponse());
const fetchMock = vi.fn<() => Promise<{ ok: boolean; json: () => Promise<unknown> }>>().mockResolvedValue(healthyMetadataResponse());
globalThis.fetch = fetchMock as unknown as typeof fetch;
await ensureBackendRunning(config);

View file

@ -23,4 +23,3 @@ with more detail
expect(value).toBe("");
});
});

View file

@ -29,11 +29,11 @@ describe("resolveTuiTheme", () => {
opencode_poll_interval: 2,
github_poll_interval: 30,
backup_interval_secs: 3600,
backup_retention_days: 7
backup_retention_days: 7,
},
providers: {
daytona: { image: "ubuntu:24.04" }
}
daytona: { image: "ubuntu:24.04" },
},
});
afterEach(() => {
@ -64,11 +64,7 @@ describe("resolveTuiTheme", () => {
withEnv("XDG_STATE_HOME", stateHome);
withEnv("XDG_CONFIG_HOME", configHome);
mkdirSync(join(stateHome, "opencode"), { recursive: true });
writeFileSync(
join(stateHome, "opencode", "kv.json"),
JSON.stringify({ theme: "gruvbox", theme_mode: "dark" }),
"utf8"
);
writeFileSync(join(stateHome, "opencode", "kv.json"), JSON.stringify({ theme: "gruvbox", theme_mode: "dark" }), "utf8");
const resolution = resolveTuiTheme(baseConfig, tempDir);
@ -85,11 +81,7 @@ describe("resolveTuiTheme", () => {
withEnv("XDG_STATE_HOME", stateHome);
withEnv("XDG_CONFIG_HOME", configHome);
mkdirSync(join(stateHome, "opencode"), { recursive: true });
writeFileSync(
join(stateHome, "opencode", "kv.json"),
JSON.stringify({ theme: "orng", theme_mode: "dark" }),
"utf8"
);
writeFileSync(join(stateHome, "opencode", "kv.json"), JSON.stringify({ theme: "orng", theme_mode: "dark" }), "utf8");
const resolution = resolveTuiTheme(baseConfig, tempDir);

View file

@ -23,8 +23,8 @@ const sample: HandoffRecord = {
switchTarget: "daytona://sandbox-1",
cwd: null,
createdAt: 1,
updatedAt: 1
}
updatedAt: 1,
},
],
agentType: null,
prSubmitted: false,
@ -38,7 +38,7 @@ const sample: HandoffRecord = {
hasUnpushed: null,
parentBranch: null,
createdAt: 1,
updatedAt: 1
updatedAt: 1,
};
describe("formatRows", () => {
@ -60,7 +60,7 @@ describe("formatRows", () => {
it("pins footer to the last terminal row", () => {
const output = formatRows([sample], 0, "default", "ready", "", false, {
width: 80,
height: 12
height: 12,
});
const lines = output.split("\n");
expect(lines).toHaveLength(12);
@ -83,8 +83,8 @@ describe("search", () => {
handoffId: "handoff-2",
branchName: "docs/update-intro",
title: "Docs Intro Refresh",
status: "idle"
}
status: "idle",
},
];
expect(filterHandoffs(rows, "doc")).toHaveLength(1);
expect(filterHandoffs(rows, "h2")).toHaveLength(1);

View file

@ -15,11 +15,11 @@ describe("cli workspace resolution", () => {
opencode_poll_interval: 2,
github_poll_interval: 30,
backup_interval_secs: 3600,
backup_retention_days: 7
backup_retention_days: 7,
},
providers: {
daytona: { image: "ubuntu:24.04" }
}
daytona: { image: "ubuntu:24.04" },
},
});
expect(resolveWorkspace(undefined, config)).toBe("team");