refactor: extend shared account status snapshot helpers

This commit is contained in:
Peter Steinberger
2026-03-22 20:50:22 +00:00
parent 00b2f10dec
commit 87722d6327
15 changed files with 292 additions and 199 deletions

View File

@@ -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", () => {