diff --git a/src/services/db.test.ts b/src/services/db.test.ts index 88c9d5b..73b36ad 100644 --- a/src/services/db.test.ts +++ b/src/services/db.test.ts @@ -531,11 +531,33 @@ function catchUp(overrides: Partial> } describe("a profile is prepared before the plugin opens it (#390)", () => { + // db.ts writes to the Journal through logService, mocked here. A raw + // console.error or console.warn would reach the Journal too (initLogCapture + // captures both), so none may carry a folder: each test of this block ends + // by refusing such a line (review 27245 of PR #491, R6). + let consoleLines: string[] = []; + let consoleSpies: Array<{ mockRestore: () => void }> = []; + beforeEach(() => { vi.mocked(invoke).mockClear(); vi.mocked(Database.load).mockClear(); vi.mocked(logInfo).mockClear(); vi.mocked(logError).mockClear(); + consoleLines = []; + const text = (a: unknown): string => + typeof a === "string" ? a : a instanceof Error ? a.message : (JSON.stringify(a) ?? String(a)); + const record = (...args: unknown[]) => { + consoleLines.push(args.map(text).join(" ")); + }; + consoleSpies = [ + vi.spyOn(console, "error").mockImplementation(record), + vi.spyOn(console, "warn").mockImplementation(record), + ]; + }); + + afterEach(() => { + consoleSpies.forEach((spy) => spy.mockRestore()); + expect(consoleLines.filter((line) => /[\\/]/.test(line))).toEqual([]); }); it("prepares after the checksum repair and before Database.load", async () => {