

























@@ -67,15 +67,17 @@ vi.mock("./gateway.js", () => ({
6767}));
68686969function requireRestartSentinelPayload(): RestartSentinelPayload {
70-const payload = writeRestartSentinelMock.mock.calls.at(-1)?.[0];
70+const calls = writeRestartSentinelMock.mock.calls;
71+const payload = calls[calls.length - 1]?.[0];
7172if (!payload) {
7273throw new Error("expected restart sentinel payload");
7374}
7475return payload;
7576}
76777778function requireScheduledRestartArgs(): NonNullable<ScheduleGatewayRestartArgs> {
78-const args = scheduleGatewaySigusr1RestartMock.mock.calls.at(-1)?.[0];
79+const calls = scheduleGatewaySigusr1RestartMock.mock.calls;
80+const args = calls[calls.length - 1]?.[0];
7981if (!args) {
8082throw new Error("expected scheduled restart args");
8183}
@@ -138,8 +140,7 @@ describe("gateway tool restart continuation", () => {
138140});
139141140142expect(writeRestartSentinelMock).not.toHaveBeenCalled();
141-const scheduledArgs = scheduleGatewaySigusr1RestartMock.mock.calls.at(-1)?.[0];
142-await scheduledArgs?.emitHooks?.beforeEmit?.();
143+await requireScheduledRestartArgs().emitHooks?.beforeEmit?.();
143144144145const payload = requireRestartSentinelPayload();
145146expect(payload.kind).toBe("restart");
@@ -176,8 +177,7 @@ describe("gateway tool restart continuation", () => {
176177continuationMessage: "Reply after restart",
177178});
178179179-const scheduledArgs = scheduleGatewaySigusr1RestartMock.mock.calls.at(-1)?.[0];
180-await scheduledArgs?.emitHooks?.beforeEmit?.();
180+await requireScheduledRestartArgs().emitHooks?.beforeEmit?.();
181181182182expect(requireRestartSentinelPayload().continuation).toEqual({
183183kind: "agentTurn",
@@ -199,8 +199,7 @@ describe("gateway tool restart continuation", () => {
199199reason: "restart requested",
200200});
201201202-const scheduledArgs = scheduleGatewaySigusr1RestartMock.mock.calls.at(-1)?.[0];
203-await scheduledArgs?.emitHooks?.beforeEmit?.();
202+await requireScheduledRestartArgs().emitHooks?.beforeEmit?.();
204203205204const payload = requireRestartSentinelPayload();
206205expect(payload.sessionKey).toBe("agent:main:main");
@@ -220,9 +219,9 @@ describe("gateway tool restart continuation", () => {
220219action: "restart",
221220});
222221223-const scheduledArgs = scheduleGatewaySigusr1RestartMock.mock.calls.at(-1)?.[0];
224-await scheduledArgs?.emitHooks?.beforeEmit?.();
225-await scheduledArgs?.emitHooks?.afterEmitRejected?.();
222+const scheduledArgs = requireScheduledRestartArgs();
223+await scheduledArgs.emitHooks?.beforeEmit?.();
224+await scheduledArgs.emitHooks?.afterEmitRejected?.();
226225227226expect(removeRestartSentinelFileMock).toHaveBeenCalledWith("/tmp/restart");
228227});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。