refactor(test): dedupe agent and status command fixtures

This commit is contained in:
Peter Steinberger
2026-02-16 16:48:28 +00:00
parent 44ef045614
commit ac5f6e7c9d
5 changed files with 168 additions and 211 deletions

View File

@@ -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()],
},
],
},