

























@@ -3,16 +3,16 @@ import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
33import type { ClawdbotConfig } from "./bot-runtime-api.js";
44import { resolveFeishuReasoningPreviewEnabled } from "./reasoning-preview.js";
556-const { loadSessionStoreMock } = vi.hoisted(() => ({
7-loadSessionStoreMock: vi.fn(),
6+const { getSessionEntryMock } = vi.hoisted(() => ({
7+getSessionEntryMock: vi.fn(),
88}));
991010vi.mock("./bot-runtime-api.js", async () => {
1111const actual =
1212await vi.importActual<typeof import("./bot-runtime-api.js")>("./bot-runtime-api.js");
1313return {
1414 ...actual,
15-loadSessionStore: loadSessionStoreMock,
15+getSessionEntry: getSessionEntryMock,
1616};
1717});
1818@@ -29,9 +29,12 @@ describe("resolveFeishuReasoningPreviewEnabled", () => {
2929});
30303131it("enables previews only for stream reasoning sessions", () => {
32-loadSessionStoreMock.mockReturnValue({
33-"agent:main:feishu:dm:ou_sender_1": { reasoningLevel: "stream" },
34-"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "on" },
32+getSessionEntryMock.mockImplementation(({ sessionKey }) => {
33+const entries = {
34+"agent:main:feishu:dm:ou_sender_1": { reasoningLevel: "stream" },
35+"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "on" },
36+};
37+return entries[sessionKey as keyof typeof entries];
3538});
36393740expect(
@@ -50,10 +53,15 @@ describe("resolveFeishuReasoningPreviewEnabled", () => {
5053sessionKey: "agent:main:feishu:dm:ou_sender_2",
5154}),
5255).toBe(false);
56+expect(getSessionEntryMock).toHaveBeenCalledWith({
57+storePath: "/tmp/feishu-sessions.json",
58+sessionKey: "agent:main:feishu:dm:ou_sender_1",
59+readConsistency: "latest",
60+});
5361});
54625563it("returns false for missing sessions or load failures", () => {
56-loadSessionStoreMock.mockImplementationOnce(() => {
64+getSessionEntryMock.mockImplementationOnce(() => {
5765throw new Error("disk unavailable");
5866});
5967@@ -75,9 +83,12 @@ describe("resolveFeishuReasoningPreviewEnabled", () => {
7583});
76847785it("falls back to configured stream defaults", () => {
78-loadSessionStoreMock.mockReturnValue({
79-"agent:main:feishu:dm:ou_sender_1": {},
80-"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "off" },
86+getSessionEntryMock.mockImplementation(({ sessionKey }) => {
87+const entries = {
88+"agent:main:feishu:dm:ou_sender_1": {},
89+"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "off" },
90+};
91+return entries[sessionKey as keyof typeof entries];
8192});
82938394const cfg: ClawdbotConfig = {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。