mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 15:58:27 +00:00
refactor(test): dedupe agent and status command fixtures
This commit is contained in:
@@ -2,6 +2,23 @@ import { describe, expect, it } from "vitest";
|
||||
import type { StatusSummary } from "./status.types.js";
|
||||
import { redactSensitiveStatusSummary } from "./status.summary.js";
|
||||
|
||||
function createRecentSessionRow() {
|
||||
return {
|
||||
key: "main",
|
||||
kind: "direct" as const,
|
||||
sessionId: "sess-1",
|
||||
updatedAt: 1,
|
||||
age: 2,
|
||||
totalTokens: 3,
|
||||
totalTokensFresh: true,
|
||||
remainingTokens: 4,
|
||||
percentUsed: 5,
|
||||
model: "gpt-5",
|
||||
contextTokens: 200_000,
|
||||
flags: ["id:sess-1"],
|
||||
};
|
||||
}
|
||||
|
||||
describe("redactSensitiveStatusSummary", () => {
|
||||
it("removes sensitive session and path details while preserving summary structure", () => {
|
||||
const input: StatusSummary = {
|
||||
@@ -15,43 +32,13 @@ describe("redactSensitiveStatusSummary", () => {
|
||||
paths: ["/tmp/openclaw/sessions.json"],
|
||||
count: 1,
|
||||
defaults: { model: "gpt-5", contextTokens: 200_000 },
|
||||
recent: [
|
||||
{
|
||||
key: "main",
|
||||
kind: "direct",
|
||||
sessionId: "sess-1",
|
||||
updatedAt: 1,
|
||||
age: 2,
|
||||
totalTokens: 3,
|
||||
totalTokensFresh: true,
|
||||
remainingTokens: 4,
|
||||
percentUsed: 5,
|
||||
model: "gpt-5",
|
||||
contextTokens: 200_000,
|
||||
flags: ["id:sess-1"],
|
||||
},
|
||||
],
|
||||
recent: [createRecentSessionRow()],
|
||||
byAgent: [
|
||||
{
|
||||
agentId: "main",
|
||||
path: "/tmp/openclaw/main-sessions.json",
|
||||
count: 1,
|
||||
recent: [
|
||||
{
|
||||
key: "main",
|
||||
kind: "direct",
|
||||
sessionId: "sess-1",
|
||||
updatedAt: 1,
|
||||
age: 2,
|
||||
totalTokens: 3,
|
||||
totalTokensFresh: true,
|
||||
remainingTokens: 4,
|
||||
percentUsed: 5,
|
||||
model: "gpt-5",
|
||||
contextTokens: 200_000,
|
||||
flags: ["id:sess-1"],
|
||||
},
|
||||
],
|
||||
recent: [createRecentSessionRow()],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user