test: dedupe session restart mock reads · openclaw/openclaw@f2b560f
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -107,6 +107,10 @@ function restartCommandParams(overrides?: Partial<HandleCommandsParams>): Handle
|
107 | 107 | } as HandleCommandsParams; |
108 | 108 | } |
109 | 109 | |
| 110 | +function firstRestartSentinelPayload() { |
| 111 | +return mocks.writeRestartSentinel.mock.calls[0]?.[0]; |
| 112 | +} |
| 113 | + |
110 | 114 | describe("handleRestartCommand", () => { |
111 | 115 | beforeEach(() => { |
112 | 116 | mocks.isRestartEnabled.mockReset(); |
@@ -128,7 +132,7 @@ describe("handleRestartCommand", () => {
|
128 | 132 | |
129 | 133 | expect(result?.shouldContinue).toBe(false); |
130 | 134 | expect(mocks.writeRestartSentinel).toHaveBeenCalledOnce(); |
131 | | -const sentinelPayload = mocks.writeRestartSentinel.mock.calls.at(0)?.[0]; |
| 135 | +const sentinelPayload = firstRestartSentinelPayload(); |
132 | 136 | expect(sentinelPayload?.kind).toBe("restart"); |
133 | 137 | expect(sentinelPayload?.status).toBe("ok"); |
134 | 138 | expect(typeof sentinelPayload?.ts).toBe("number"); |
@@ -166,7 +170,7 @@ describe("handleRestartCommand", () => {
|
166 | 170 | await scheduledArgs?.emitHooks?.beforeEmit?.(); |
167 | 171 | |
168 | 172 | expect(mocks.writeRestartSentinel).toHaveBeenCalledOnce(); |
169 | | -const sentinelPayload = mocks.writeRestartSentinel.mock.calls.at(0)?.[0]; |
| 173 | +const sentinelPayload = firstRestartSentinelPayload(); |
170 | 174 | expect(sentinelPayload?.kind).toBe("restart"); |
171 | 175 | expect(sentinelPayload?.status).toBe("ok"); |
172 | 176 | expect(sentinelPayload?.sessionKey).toBe("agent:main:telegram:direct:123:thread:thread-1"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。