refactor(channels): dedupe transport and gateway test scaffolds

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:15 +00:00
parent f717a13039
commit 93ca0ed54f
95 changed files with 4068 additions and 5221 deletions

View File

@@ -125,6 +125,20 @@ function createErrnoError(code: string) {
return err;
}
function mockWorkspaceStateRead(params: { onboardingCompletedAt?: string; errorCode?: string }) {
mocks.fsReadFile.mockImplementation(async (filePath: string | URL | number) => {
if (String(filePath).endsWith("workspace-state.json")) {
if (params.errorCode) {
throw createErrnoError(params.errorCode);
}
return JSON.stringify({
onboardingCompletedAt: params.onboardingCompletedAt ?? "2026-02-15T14:00:00.000Z",
});
}
throw createEnoentError();
});
}
beforeEach(() => {
mocks.fsReadFile.mockImplementation(async () => {
throw createEnoentError();
@@ -413,14 +427,7 @@ describe("agents.files.list", () => {
});
it("hides BOOTSTRAP.md when workspace onboarding is complete", async () => {
mocks.fsReadFile.mockImplementation(async (filePath: string | URL | number) => {
if (String(filePath).endsWith("workspace-state.json")) {
return JSON.stringify({
onboardingCompletedAt: "2026-02-15T14:00:00.000Z",
});
}
throw createEnoentError();
});
mockWorkspaceStateRead({ onboardingCompletedAt: "2026-02-15T14:00:00.000Z" });
const { respond, promise } = makeCall("agents.files.list", { agentId: "main" });
await promise;
@@ -431,12 +438,7 @@ describe("agents.files.list", () => {
});
it("falls back to showing BOOTSTRAP.md when workspace state cannot be read", async () => {
mocks.fsReadFile.mockImplementation(async (filePath: string | URL | number) => {
if (String(filePath).endsWith("workspace-state.json")) {
throw createErrnoError("EACCES");
}
throw createEnoentError();
});
mockWorkspaceStateRead({ errorCode: "EACCES" });
const { respond, promise } = makeCall("agents.files.list", { agentId: "main" });
await promise;