fancive_obsidian-parallel-r.../tests/plugin-batch.test.js
wujunchen 39ddd4289e fix: count batch generation failures
Change-Id: Ie6b29cb3efc22fe72250e9c63c1e82c71b24a356
2026-04-29 13:51:33 +08:00

34 lines
880 B
JavaScript

const { assert, t } = require('./test-setup');
const plugin = new t.ParallelReaderPlugin();
const failedFile = { path: 'failed.md' };
const originalConsoleError = console.error;
plugin.cacheManager = { get: () => null };
plugin.jobs = {
isRunning: () => false,
start: async () => {
throw new Error('backend down');
},
};
plugin.t = (key) => key;
(async () => {
console.error = () => {};
try {
await assert.doesNotReject(
() => plugin.runForFile(failedFile, false),
'single-file UI path should keep handling errors internally',
);
await assert.rejects(
() => plugin.runForFile(failedFile, false, { rethrowErrors: true }),
/backend down/,
'batch path should be able to count failed generation attempts',
);
} finally {
console.error = originalConsoleError;
}
console.log('plugin batch tests passed');
})();