


























@@ -93,6 +93,10 @@ function getRuntimeLog(index: number): string {
9393return String(call[0]);
9494}
959596+function getLastRuntimeLog(): string {
97+return getRuntimeLog(runtimeLogMock.mock.calls.length - 1);
98+}
99+96100function getJoinedRuntimeLogs() {
97101return getRuntimeLogs().join("\n");
98102}
@@ -1025,7 +1029,7 @@ describe("statusCommand", () => {
10251029const allPayload = JSON.parse(getRuntimeLog(0));
10261030expect(allPayload.securityAudit.summary.critical).toBe(1);
10271031expect(allPayload.securityAudit.summary.warn).toBe(1);
1028-const auditParams = mocks.runSecurityAudit.mock.calls.at(0)?.[0];
1032+const auditParams = mocks.runSecurityAudit.mock.calls[0]?.[0];
10291033expect(auditParams?.includeFilesystem).toBe(true);
10301034expect(auditParams?.includeChannelSecurity).toBe(true);
10311035});
@@ -1038,7 +1042,7 @@ describe("statusCommand", () => {
1038104210391043await statusCommand({ usage: true, timeoutMs: 1234 }, runtime as never);
104010441041-const params = snapshotMock.mock.calls.at(-1)?.[0] as
1045+const params = snapshotMock.mock.calls[snapshotMock.mock.calls.length - 1]?.[0] as
10421046| {
10431047config: unknown;
10441048timeoutMs?: number;
@@ -1083,7 +1087,7 @@ describe("statusCommand", () => {
10831087await withUnknownUsageStore(async () => {
10841088runtimeLogMock.mockClear();
10851089await statusCommand({ json: true }, runtime as never);
1086-const payload = JSON.parse(String(runtimeLogMock.mock.calls.at(-1)?.[0]));
1090+const payload = JSON.parse(getLastRuntimeLog());
10871091expect(payload.sessions.recent[0].totalTokens).toBeNull();
10881092expect(payload.sessions.recent[0].totalTokensFresh).toBe(false);
10891093expect(payload.sessions.recent[0].percentUsed).toBeNull();
@@ -1103,7 +1107,7 @@ describe("statusCommand", () => {
11031107});
11041108runtimeLogMock.mockClear();
11051109await statusCommand({ json: true }, runtime as never);
1106-const payload = JSON.parse(String(runtimeLogMock.mock.calls.at(-1)?.[0]));
1110+const payload = JSON.parse(getLastRuntimeLog());
11071111expect(payload.sessions.recent[0].totalTokens).toBe(5000);
11081112expect(payload.sessions.recent[0].totalTokensFresh).toBe(false);
11091113expect(payload.sessions.recent[0].percentUsed).toBe(50);
@@ -1278,7 +1282,7 @@ describe("statusCommand", () => {
12781282});
1279128312801284await statusCommand({ json: true }, runtime as never);
1281-const payload = JSON.parse(String(runtimeLogMock.mock.calls.at(-1)?.[0]));
1285+const payload = JSON.parse(getLastRuntimeLog());
12821286const gatewayAuthMessage = payload.gateway.error ?? payload.gateway.authWarning;
12831287expect(typeof gatewayAuthMessage).toBe("string");
12841288expect(gatewayAuthMessage.trim().length).toBeGreaterThan(0);
@@ -1448,7 +1452,7 @@ describe("statusCommand", () => {
14481452});
1449145314501454await statusCommand({ json: true }, runtime as never);
1451-const payload = JSON.parse(String(runtimeLogMock.mock.calls.at(-1)?.[0]));
1455+const payload = JSON.parse(getLastRuntimeLog());
14521456expect(payload.sessions.count).toBe(2);
14531457expect(payload.sessions.paths.length).toBe(2);
14541458expect(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。