|
7 | 7 | executeSqliteQueryTakeFirstSync, |
8 | 8 | getNodeSqliteKysely, |
9 | 9 | } from "../infra/kysely-sync.js"; |
| 10 | +import { resetLogger, setLoggerOverride } from "../logging/logger.js"; |
| 11 | +import { loggingState } from "../logging/state.js"; |
10 | 12 | import { createWarnLogCapture } from "../logging/test-helpers/warn-log-capture.js"; |
11 | 13 | import type { DB as OpenClawStateKyselyDatabase } from "../state/openclaw-state-db.generated.js"; |
12 | 14 | import { |
@@ -113,6 +115,9 @@ describe("task-registry store runtime", () => { |
113 | 115 | ORIGINAL_ENV.restore(); |
114 | 116 | resetTaskRegistryForTests(); |
115 | 117 | resetTaskFlowRegistryForTests({ persist: false }); |
| 118 | + loggingState.rawConsole = null; |
| 119 | + setLoggerOverride(null); |
| 120 | + resetLogger(); |
116 | 121 | }); |
117 | 122 |
|
118 | 123 | it("uses the configured task store for restore and save", () => { |
@@ -177,6 +182,34 @@ describe("task-registry store runtime", () => { |
177 | 182 | } |
178 | 183 | }); |
179 | 184 |
|
| 185 | + it("includes restore parser failures in compact console warnings", () => { |
| 186 | + const warn = vi.fn(); |
| 187 | + const invalidValue = "future-invalid-status"; |
| 188 | + setLoggerOverride({ level: "silent", consoleLevel: "warn", consoleStyle: "compact" }); |
| 189 | + loggingState.rawConsole = { |
| 190 | + log: vi.fn(), |
| 191 | + info: vi.fn(), |
| 192 | + warn, |
| 193 | + error: vi.fn(), |
| 194 | + }; |
| 195 | + configureTaskRegistryRuntime({ |
| 196 | + store: { |
| 197 | + loadSnapshot: () => { |
| 198 | + throw new Error( |
| 199 | + `Invalid persisted task delivery status: ${JSON.stringify(invalidValue)}`, |
| 200 | + ); |
| 201 | + }, |
| 202 | + saveSnapshot: () => {}, |
| 203 | + }, |
| 204 | + }); |
| 205 | + |
| 206 | + expect(findTaskByRunId("run-restored")).toBeUndefined(); |
| 207 | + expect(warn).toHaveBeenCalledTimes(1); |
| 208 | + expect(String(warn.mock.calls[0]?.[0])).toContain( |
| 209 | + `Failed to restore task registry: Invalid persisted task delivery status: "${invalidValue}"`, |
| 210 | + ); |
| 211 | + }); |
| 212 | + |
180 | 213 | it("uses scoped owner lookups for fresh owner task reads", () => { |
181 | 214 | const storedTask = createStoredTask(); |
182 | 215 | const loadSnapshot = vi.fn(() => ({ |
|
0 commit comments