mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:30:43 +00:00
test: share sessions list details helper
This commit is contained in:
@@ -30,6 +30,27 @@ vi.mock("./sessions-helpers.js", async (importActual) => {
|
||||
};
|
||||
});
|
||||
|
||||
type SessionsListDetails = {
|
||||
sessions?: Array<{
|
||||
deliveryContext?: {
|
||||
accountId?: string;
|
||||
channel?: string;
|
||||
threadId?: string | number;
|
||||
to?: string;
|
||||
};
|
||||
elevatedLevel?: string;
|
||||
fastMode?: boolean;
|
||||
reasoningLevel?: string;
|
||||
responseUsage?: string;
|
||||
thinkingLevel?: string;
|
||||
verboseLevel?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
function getSessionsListDetails(result: { details?: unknown }): SessionsListDetails {
|
||||
return result.details as SessionsListDetails;
|
||||
}
|
||||
|
||||
describe("sessions-list-tool", () => {
|
||||
let createSessionsListTool: typeof import("./sessions-list-tool.js").createSessionsListTool;
|
||||
|
||||
@@ -89,16 +110,7 @@ describe("sessions-list-tool", () => {
|
||||
const tool = createSessionsListTool({ config: {} as never });
|
||||
|
||||
const result = await tool.execute("call-1", {});
|
||||
const details = result.details as {
|
||||
sessions?: Array<{
|
||||
deliveryContext?: {
|
||||
channel?: string;
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
threadId?: string | number;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
const details = getSessionsListDetails(result);
|
||||
|
||||
expect(details.sessions?.[0]?.deliveryContext).toEqual({
|
||||
channel: "discord",
|
||||
@@ -140,16 +152,7 @@ describe("sessions-list-tool", () => {
|
||||
const tool = createSessionsListTool({ config: {} as never });
|
||||
|
||||
const result = await tool.execute("call-2", {});
|
||||
const details = result.details as {
|
||||
sessions?: Array<{
|
||||
deliveryContext?: {
|
||||
channel?: string;
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
threadId?: string | number;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
const details = getSessionsListDetails(result);
|
||||
|
||||
expect(details.sessions?.[0]?.deliveryContext).toEqual({
|
||||
channel: "telegram",
|
||||
@@ -185,16 +188,7 @@ describe("sessions-list-tool", () => {
|
||||
const tool = createSessionsListTool({ config: {} as never });
|
||||
|
||||
const result = await tool.execute("call-3", {});
|
||||
const details = result.details as {
|
||||
sessions?: Array<{
|
||||
thinkingLevel?: string;
|
||||
fastMode?: boolean;
|
||||
verboseLevel?: string;
|
||||
reasoningLevel?: string;
|
||||
elevatedLevel?: string;
|
||||
responseUsage?: string;
|
||||
}>;
|
||||
};
|
||||
const details = getSessionsListDetails(result);
|
||||
|
||||
expect(details.sessions?.[0]).toMatchObject({
|
||||
thinkingLevel: "high",
|
||||
|
||||
Reference in New Issue
Block a user