mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 18:30:22 +00:00
refactor: extend shared account status snapshot helpers
This commit is contained in:
@@ -88,6 +88,34 @@ describe("buildBaseAccountStatusSnapshot", () => {
|
||||
lastOutboundAt: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("merges extra snapshot fields after the shared account shape", () => {
|
||||
expect(
|
||||
buildBaseAccountStatusSnapshot(
|
||||
{
|
||||
account: { accountId: "default", configured: true },
|
||||
},
|
||||
{
|
||||
connected: true,
|
||||
mode: "polling",
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
accountId: "default",
|
||||
name: undefined,
|
||||
enabled: undefined,
|
||||
configured: true,
|
||||
running: false,
|
||||
lastStartAt: null,
|
||||
lastStopAt: null,
|
||||
lastError: null,
|
||||
probe: undefined,
|
||||
lastInboundAt: null,
|
||||
lastOutboundAt: null,
|
||||
connected: true,
|
||||
mode: "polling",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildComputedAccountStatusSnapshot", () => {
|
||||
@@ -112,6 +140,33 @@ describe("buildComputedAccountStatusSnapshot", () => {
|
||||
lastOutboundAt: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("merges computed extras after the shared fields", () => {
|
||||
expect(
|
||||
buildComputedAccountStatusSnapshot(
|
||||
{
|
||||
accountId: "default",
|
||||
configured: true,
|
||||
},
|
||||
{
|
||||
connected: true,
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
accountId: "default",
|
||||
name: undefined,
|
||||
enabled: undefined,
|
||||
configured: true,
|
||||
running: false,
|
||||
lastStartAt: null,
|
||||
lastStopAt: null,
|
||||
lastError: null,
|
||||
probe: undefined,
|
||||
lastInboundAt: null,
|
||||
lastOutboundAt: null,
|
||||
connected: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildRuntimeAccountStatusSnapshot", () => {
|
||||
@@ -124,6 +179,17 @@ describe("buildRuntimeAccountStatusSnapshot", () => {
|
||||
probe: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("merges extra fields into runtime snapshots", () => {
|
||||
expect(buildRuntimeAccountStatusSnapshot({}, { port: 3978 })).toEqual({
|
||||
running: false,
|
||||
lastStartAt: null,
|
||||
lastStopAt: null,
|
||||
lastError: null,
|
||||
probe: undefined,
|
||||
port: 3978,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildTokenChannelStatusSummary", () => {
|
||||
|
||||
Reference in New Issue
Block a user