mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:00:43 +00:00
test: use synthetic status session fixtures
This commit is contained in:
@@ -188,8 +188,8 @@ describe("getCronChannelOptions", () => {
|
||||
});
|
||||
|
||||
it("lists discovered channel plugin ids when plugins are available", () => {
|
||||
hoisted.listChannelPluginsMock.mockReturnValue([{ id: "telegram" }, { id: "signal" }]);
|
||||
expect(getCronChannelOptions()).toBe("last|telegram|signal");
|
||||
hoisted.listChannelPluginsMock.mockReturnValue([{ id: "quietchat" }, { id: "forum" }]);
|
||||
expect(getCronChannelOptions()).toBe("last|quietchat|forum");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -300,8 +300,8 @@ describe("deliverAgentCommandResult", () => {
|
||||
opts: {
|
||||
message: "hello",
|
||||
deliver: false,
|
||||
lane: "nested:agent:ebao-next:discord:channel:1",
|
||||
sessionKey: "agent:ebao-next:discord:channel:1",
|
||||
lane: "nested:agent:ebao-next:quietchat:channel:1",
|
||||
sessionKey: "agent:ebao-next:quietchat:channel:1",
|
||||
runId: "run-announce",
|
||||
messageChannel: "webchat",
|
||||
},
|
||||
@@ -311,7 +311,7 @@ describe("deliverAgentCommandResult", () => {
|
||||
expect(runtime.log).toHaveBeenCalledTimes(1);
|
||||
const line = String((runtime.log as ReturnType<typeof vi.fn>).mock.calls[0]?.[0]);
|
||||
expect(line).toContain("[agent:nested]");
|
||||
expect(line).toContain("session=agent:ebao-next:discord:channel:1");
|
||||
expect(line).toContain("session=agent:ebao-next:quietchat:channel:1");
|
||||
expect(line).toContain("ANNOUNCE_SKIP");
|
||||
});
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ describe("agents delete command", () => {
|
||||
cfg,
|
||||
sessions: {
|
||||
"agent:ops:main": { sessionId: "sess-ops-main", updatedAt: 1 },
|
||||
"agent:ops:discord:direct:u1": { sessionId: "sess-ops-direct", updatedAt: 2 },
|
||||
"agent:ops:quietchat:direct:u1": { sessionId: "sess-ops-direct", updatedAt: 2 },
|
||||
"agent:main:main": { sessionId: "sess-main", updatedAt: 3 },
|
||||
},
|
||||
});
|
||||
@@ -119,8 +119,8 @@ describe("agents delete command", () => {
|
||||
cfg,
|
||||
sessions: {
|
||||
"agent:main:main": { sessionId: "sess-default-alias", updatedAt: 1 },
|
||||
"agent:ops:discord:direct:u1": { sessionId: "sess-ops-direct", updatedAt: 2 },
|
||||
"agent:main:discord:direct:u2": { sessionId: "sess-stale-main", updatedAt: 3 },
|
||||
"agent:ops:quietchat:direct:u1": { sessionId: "sess-ops-direct", updatedAt: 2 },
|
||||
"agent:main:quietchat:direct:u2": { sessionId: "sess-stale-main", updatedAt: 3 },
|
||||
global: { sessionId: "sess-global", updatedAt: 4 },
|
||||
},
|
||||
});
|
||||
@@ -129,7 +129,7 @@ describe("agents delete command", () => {
|
||||
|
||||
expect(runtime.exit).not.toHaveBeenCalled();
|
||||
expectSessionStore(storePath, {
|
||||
"agent:main:discord:direct:u2": { sessionId: "sess-stale-main", updatedAt: 3 },
|
||||
"agent:main:quietchat:direct:u2": { sessionId: "sess-stale-main", updatedAt: 3 },
|
||||
global: { sessionId: "sess-global", updatedAt: 4 },
|
||||
});
|
||||
});
|
||||
@@ -151,9 +151,9 @@ describe("agents delete command", () => {
|
||||
cfg,
|
||||
sessions: {
|
||||
main: { sessionId: "sess-main", updatedAt: 1 },
|
||||
"discord:direct:u1": { sessionId: "sess-main-direct", updatedAt: 2 },
|
||||
"quietchat:direct:u1": { sessionId: "sess-main-direct", updatedAt: 2 },
|
||||
"agent:ops:main": { sessionId: "sess-ops-main", updatedAt: 3 },
|
||||
"agent:ops:discord:direct:u2": { sessionId: "sess-ops-direct", updatedAt: 4 },
|
||||
"agent:ops:quietchat:direct:u2": { sessionId: "sess-ops-direct", updatedAt: 4 },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -162,7 +162,7 @@ describe("agents delete command", () => {
|
||||
expect(runtime.exit).not.toHaveBeenCalled();
|
||||
expectSessionStore(storePath, {
|
||||
main: { sessionId: "sess-main", updatedAt: 1 },
|
||||
"discord:direct:u1": { sessionId: "sess-main-direct", updatedAt: 2 },
|
||||
"quietchat:direct:u1": { sessionId: "sess-main-direct", updatedAt: 2 },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ describe("sessionsCommand", () => {
|
||||
|
||||
it("shows placeholder rows when tokens are missing", async () => {
|
||||
const store = writeStore({
|
||||
"discord:group:demo": {
|
||||
"quietchat:group:demo": {
|
||||
sessionId: "xyz",
|
||||
updatedAt: Date.now() - 5 * 60_000,
|
||||
thinkingLevel: "high",
|
||||
@@ -65,7 +65,7 @@ describe("sessionsCommand", () => {
|
||||
|
||||
fs.rmSync(store);
|
||||
|
||||
const row = logs.find((line) => line.includes("discord:group:demo")) ?? "";
|
||||
const row = logs.find((line) => line.includes("quietchat:group:demo")) ?? "";
|
||||
expect(row).toContain("unknown/32k (?%)");
|
||||
expect(row).toContain("think:high");
|
||||
expect(row).toContain("5m ago");
|
||||
@@ -82,7 +82,7 @@ describe("sessionsCommand", () => {
|
||||
totalTokensFresh: true,
|
||||
model: "pi:opus",
|
||||
},
|
||||
"discord:group:demo": {
|
||||
"quietchat:group:demo": {
|
||||
sessionId: "xyz",
|
||||
updatedAt: Date.now() - 5 * 60_000,
|
||||
inputTokens: 20,
|
||||
@@ -99,7 +99,7 @@ describe("sessionsCommand", () => {
|
||||
}>;
|
||||
}>(sessionsCommand, store);
|
||||
const main = payload.sessions?.find((row) => row.key === "main");
|
||||
const group = payload.sessions?.find((row) => row.key === "discord:group:demo");
|
||||
const group = payload.sessions?.find((row) => row.key === "quietchat:group:demo");
|
||||
expect(main?.totalTokens).toBe(2000);
|
||||
expect(main?.totalTokensFresh).toBe(true);
|
||||
expect(group?.totalTokens).toBeNull();
|
||||
|
||||
@@ -39,7 +39,7 @@ describe("buildStatusCommandReportData", () => {
|
||||
);
|
||||
expect(result.pluginCompatibilityLines).toEqual([" warn(WARN) legacy"]);
|
||||
expect(result.pairingRecoveryLines[0]).toBe("warn(Gateway pairing approval required.)");
|
||||
expect(result.channelsRows[0]?.Channel).toBe("Discord");
|
||||
expect(result.channelsRows[0]?.Channel).toBe("QuietChat");
|
||||
expect(result.sessionsRows[0]?.Cache).toBe("cache ok");
|
||||
expect(result.healthRows?.[0]).toEqual({
|
||||
Item: "Gateway",
|
||||
|
||||
@@ -116,11 +116,11 @@ describe("status.command-sections", () => {
|
||||
const rows = buildStatusHealthRows({
|
||||
health: { durationMs: 42 } as HealthSummary,
|
||||
formatHealthChannelLines: () => [
|
||||
"Telegram: OK · ready",
|
||||
"Slack: failed · auth",
|
||||
"Discord: not configured",
|
||||
"QuietChat: OK · ready",
|
||||
"WorkChat: failed · auth",
|
||||
"Forum: not configured",
|
||||
"Matrix: linked",
|
||||
"Signal: not linked",
|
||||
"Pager: not linked",
|
||||
],
|
||||
ok: (value) => `ok(${value})`,
|
||||
warn: (value) => `warn(${value})`,
|
||||
@@ -129,11 +129,11 @@ describe("status.command-sections", () => {
|
||||
|
||||
expect(rows).toEqual([
|
||||
{ Item: "Gateway", Status: "ok(reachable)", Detail: "42ms" },
|
||||
{ Item: "Telegram", Status: "ok(OK)", Detail: "OK · ready" },
|
||||
{ Item: "Slack", Status: "warn(WARN)", Detail: "failed · auth" },
|
||||
{ Item: "Discord", Status: "muted(OFF)", Detail: "not configured" },
|
||||
{ Item: "QuietChat", Status: "ok(OK)", Detail: "OK · ready" },
|
||||
{ Item: "WorkChat", Status: "warn(WARN)", Detail: "failed · auth" },
|
||||
{ Item: "Forum", Status: "muted(OFF)", Detail: "not configured" },
|
||||
{ Item: "Matrix", Status: "ok(LINKED)", Detail: "linked" },
|
||||
{ Item: "Signal", Status: "warn(UNLINKED)", Detail: "not linked" },
|
||||
{ Item: "Pager", Status: "warn(UNLINKED)", Detail: "not linked" },
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ describe("collectStatusScanOverview", () => {
|
||||
skipColdStartNetworkChecks: false,
|
||||
});
|
||||
mocks.callGateway.mockResolvedValue({ channelAccounts: {} });
|
||||
mocks.collectChannelStatusIssues.mockReturnValue([{ channel: "signal", message: "boom" }]);
|
||||
mocks.collectChannelStatusIssues.mockReturnValue([{ channel: "quietchat", message: "boom" }]);
|
||||
mocks.buildChannelsTable.mockResolvedValue({ rows: [], details: [] });
|
||||
});
|
||||
|
||||
@@ -117,7 +117,7 @@ describe("collectStatusScanOverview", () => {
|
||||
sourceConfig: { session: {} },
|
||||
}),
|
||||
);
|
||||
expect(result.channelIssues).toEqual([{ channel: "signal", message: "boom" }]);
|
||||
expect(result.channelIssues).toEqual([{ channel: "quietchat", message: "boom" }]);
|
||||
});
|
||||
|
||||
it("skips channels.status when the gateway is unreachable", async () => {
|
||||
|
||||
@@ -36,9 +36,9 @@ describe("status.scan.config-shared", () => {
|
||||
});
|
||||
|
||||
it("skips read/resolve on fast-json cold-start outside tests", async () => {
|
||||
const readBestEffortConfig = vi.fn(async () => ({ channels: { telegram: {} } }));
|
||||
const readBestEffortConfig = vi.fn(async () => ({ channels: { quietchat: {} } }));
|
||||
const resolveConfig = vi.fn(async () => ({
|
||||
resolvedConfig: { channels: { telegram: {} } },
|
||||
resolvedConfig: { channels: { quietchat: {} } },
|
||||
diagnostics: ["resolved"],
|
||||
}));
|
||||
|
||||
@@ -61,8 +61,8 @@ describe("status.scan.config-shared", () => {
|
||||
});
|
||||
|
||||
it("still reads and resolves during tests even when the config path is missing", async () => {
|
||||
const sourceConfig = { channels: { telegram: {} } };
|
||||
const resolvedConfig = { channels: { telegram: {} } };
|
||||
const sourceConfig = { channels: { quietchat: {} } };
|
||||
const resolvedConfig = { channels: { quietchat: {} } };
|
||||
const readBestEffortConfig = vi.fn(async () => sourceConfig);
|
||||
const resolveConfig = vi.fn(async () => ({
|
||||
resolvedConfig,
|
||||
|
||||
@@ -141,7 +141,7 @@ export function createStatusLastHeartbeat(): HeartbeatEventPayload {
|
||||
return {
|
||||
ts: Date.now() - 30_000,
|
||||
status: "ok-token",
|
||||
channel: "discord",
|
||||
channel: "quietchat",
|
||||
accountId: "acct",
|
||||
};
|
||||
}
|
||||
@@ -179,7 +179,7 @@ export const statusTestFormatting = {
|
||||
formatKTokens: (value: number) => `${Math.round(value / 1000)}k`,
|
||||
formatTokensCompact: () => "12k",
|
||||
formatPromptCacheCompact: () => "cache ok",
|
||||
formatHealthChannelLines: () => ["Discord: OK · ready"],
|
||||
formatHealthChannelLines: () => ["QuietChat: OK · ready"],
|
||||
formatPluginCompatibilityNotice: (notice: { message?: unknown }) => String(notice.message),
|
||||
formatUpdateAvailableHint: () => "update available",
|
||||
};
|
||||
@@ -244,9 +244,9 @@ export function createStatusCommandReportDataParams(
|
||||
lastHeartbeat: createStatusLastHeartbeat(),
|
||||
agentStatus: baseStatusAgentStatus,
|
||||
channels: {
|
||||
rows: [{ id: "discord", label: "Discord", enabled: true, state: "ok", detail: "ready" }],
|
||||
rows: [{ id: "quietchat", label: "QuietChat", enabled: true, state: "ok", detail: "ready" }],
|
||||
},
|
||||
channelIssues: [{ channel: "discord", message: "warn msg" }],
|
||||
channelIssues: [{ channel: "quietchat", message: "warn msg" }],
|
||||
memory: baseStatusMemory,
|
||||
memoryPlugin: baseStatusMemoryPlugin,
|
||||
pluginCompatibility: baseStatusPluginCompatibility,
|
||||
|
||||
@@ -1341,7 +1341,7 @@ describe("agent event handler", () => {
|
||||
seq: 1,
|
||||
stream: "assistant",
|
||||
ts: Date.now(),
|
||||
data: { text: "Reply from imessage" },
|
||||
data: { text: "Reply from quietchat" },
|
||||
});
|
||||
emitLifecycleEnd(handler, "run-hidden", 2);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ describe("buildSessionEntry", () => {
|
||||
});
|
||||
|
||||
it("strips inbound metadata envelope from user messages before normalization", async () => {
|
||||
// Real Telegram inbound envelope: Conversation info + Sender blocks prepended
|
||||
// Representative inbound envelope: Conversation info + Sender blocks prepended
|
||||
// to the actual user text. Without stripping, the JSON envelope dominates
|
||||
// the corpus entry and the user's real words get truncated by the
|
||||
// SESSION_INGESTION_MAX_SNIPPET_CHARS cap downstream.
|
||||
|
||||
@@ -383,7 +383,7 @@ describe("message-normalizer", () => {
|
||||
it("preserves top-level sender labels", () => {
|
||||
const result = normalizeMessage({
|
||||
role: "user",
|
||||
content: "Hello from Telegram",
|
||||
content: "Hello from QuietChat",
|
||||
senderLabel: "Iris",
|
||||
});
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ describe("executeSlashCommand /kill", () => {
|
||||
spawnedBy: "agent:main:subagent:mine",
|
||||
}),
|
||||
row("agent:main:subagent:other-root", {
|
||||
spawnedBy: "agent:main:discord:dm:alice",
|
||||
spawnedBy: "agent:main:quietchat:dm:alice",
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user