test(db): refuse any raw console line that carries a folder in connectToProfile
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m19s
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m19s
The test of the migration repair line (B1 of PR #491) only watched the mocked logService: a raw console.error of the same error, added next to the cleaned line, would put the full path back in the Journal (initLogCapture captures console.error and console.warn) with every test green (mutation R6 of review 27245). Each test of the connectToProfile block now spies on both and refuses a line that holds a `/` or a `\`. Pinned in the follow-up link at Max's request (2026-10-24, preamble of /pr-brief 491), like R3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b998fd7c14
commit
5d26fae932
1 changed files with 22 additions and 0 deletions
|
|
@ -531,11 +531,33 @@ function catchUp(overrides: Partial<NonNullable<ProfilePreparation["catch_up"]>>
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("a profile is prepared before the plugin opens it (#390)", () => {
|
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(() => {
|
beforeEach(() => {
|
||||||
vi.mocked(invoke).mockClear();
|
vi.mocked(invoke).mockClear();
|
||||||
vi.mocked(Database.load).mockClear();
|
vi.mocked(Database.load).mockClear();
|
||||||
vi.mocked(logInfo).mockClear();
|
vi.mocked(logInfo).mockClear();
|
||||||
vi.mocked(logError).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 () => {
|
it("prepares after the checksum repair and before Database.load", async () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue