test(db): watch every channel to the Journal in the connectToProfile block
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m21s
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m21s
The pin of 5d26fae refused a folder in raw console.error and console.warn
lines only. Three other channels still let one through with every test
green (review 27373 of PR #496): logWarn, whose lines go with a feedback
report, logInfo (both mocked in this file, so they never reached the
console spies), and console.log, which initLogCapture captures at the info
level. The block now also spies on console.log and reads the calls of the
mocked logInfo, logWarn and logError, and refuses a line holding a `/` or a
`\` whatever its channel.
Applied in the follow-up link by Max's decision of 2026-10-24.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5d26fae932
commit
8b1f3158ac
1 changed files with 14 additions and 7 deletions
|
|
@ -531,33 +531,40 @@ function catchUp(overrides: Partial<NonNullable<ProfilePreparation["catch_up"]>>
|
|||
}
|
||||
|
||||
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).
|
||||
// Every line db.ts writes may reach the Journal: through logInfo, logWarn
|
||||
// and logError (mocked here, so their calls are read), or through a raw
|
||||
// console.log, console.warn or console.error (initLogCapture captures all
|
||||
// three). None may carry a folder: each test of this block ends by refusing
|
||||
// such a line, whatever its channel (reviews 27245 of PR #491 and 27373 of
|
||||
// PR #496).
|
||||
let consoleLines: string[] = [];
|
||||
let consoleSpies: Array<{ mockRestore: () => void }> = [];
|
||||
const text = (a: unknown): string =>
|
||||
typeof a === "string" ? a : a instanceof Error ? a.message : (JSON.stringify(a) ?? String(a));
|
||||
|
||||
beforeEach(() => {
|
||||
vi.mocked(invoke).mockClear();
|
||||
vi.mocked(Database.load).mockClear();
|
||||
vi.mocked(logInfo).mockClear();
|
||||
vi.mocked(logWarn).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),
|
||||
vi.spyOn(console, "log").mockImplementation(record),
|
||||
];
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
consoleSpies.forEach((spy) => spy.mockRestore());
|
||||
expect(consoleLines.filter((line) => /[\\/]/.test(line))).toEqual([]);
|
||||
const journal = [logInfo, logWarn, logError].flatMap((fn) =>
|
||||
vi.mocked(fn).mock.calls.map((call) => call.map(text).join(" ")),
|
||||
);
|
||||
expect([...consoleLines, ...journal].filter((line) => /[\\/]/.test(line))).toEqual([]);
|
||||
});
|
||||
|
||||
it("prepares after the checksum repair and before Database.load", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue