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

@@ -36,6 +36,17 @@ describe("runBootOnce", () => {
sendMessageIMessage: vi.fn(),
});
const mockAgentUpdatesMainSession = (storePath: string, sessionKey: string) => {
agentCommand.mockImplementation(async (opts: { sessionId?: string }) => {
const current = loadSessionStore(storePath, { skipCache: true });
current[sessionKey] = {
sessionId: String(opts.sessionId),
updatedAt: Date.now(),
};
await saveSessionStore(storePath, current);
});
};
it("skips when BOOT.md is missing", async () => {
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-boot-"));
await expect(runBootOnce({ cfg: {}, deps: makeDeps(), workspaceDir })).resolves.toEqual({
@@ -149,14 +160,7 @@ describe("runBootOnce", () => {
},
});
agentCommand.mockImplementation(async (opts: { sessionId?: string }) => {
const current = loadSessionStore(storePath, { skipCache: true });
current[sessionKey] = {
sessionId: String(opts.sessionId),
updatedAt: Date.now(),
};
await saveSessionStore(storePath, current);
});
mockAgentUpdatesMainSession(storePath, sessionKey);
await expect(runBootOnce({ cfg, deps: makeDeps(), workspaceDir })).resolves.toEqual({
status: "ran",
});
@@ -174,14 +178,7 @@ describe("runBootOnce", () => {
const cfg = {};
const { sessionKey, storePath } = resolveMainStore(cfg);
agentCommand.mockImplementation(async (opts: { sessionId?: string }) => {
const current = loadSessionStore(storePath, { skipCache: true });
current[sessionKey] = {
sessionId: String(opts.sessionId),
updatedAt: Date.now(),
};
await saveSessionStore(storePath, current);
});
mockAgentUpdatesMainSession(storePath, sessionKey);
await expect(runBootOnce({ cfg, deps: makeDeps(), workspaceDir })).resolves.toEqual({
status: "ran",