mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
test: add batch state isolation and cancellation tests
Verify that two concurrent BatchRunState objects don't interfere with each other (cancelling one doesn't affect the other), and that stats accumulate correctly when processing is stopped mid-iteration. Change-Id: Id32b27307beafe49594cfde6fa818b2f22b87c66
This commit is contained in:
parent
593817734b
commit
cfdd985f78
1 changed files with 21 additions and 0 deletions
|
|
@ -303,6 +303,27 @@ assert.strictEqual(batchState.cancelled, true, 'batch cancellation flag is set')
|
|||
assert.strictEqual(t.requestBatchCancel(batchState), false, 'duplicate batch cancellation request is ignored');
|
||||
assert.strictEqual(t.requestBatchCancel(null), false, 'missing batch state cannot be cancelled');
|
||||
|
||||
// Batch state isolation: two concurrent batches don't interfere
|
||||
const batchA = t.createBatchRunState();
|
||||
const batchB = t.createBatchRunState();
|
||||
t.markBatchFileRunning(batchA, 'folderA/note.md');
|
||||
t.markBatchFileRunning(batchB, 'folderB/note.md');
|
||||
assert.strictEqual(batchA.currentPath, 'folderA/note.md', 'batch A tracks its own file');
|
||||
assert.strictEqual(batchB.currentPath, 'folderB/note.md', 'batch B tracks its own file');
|
||||
t.requestBatchCancel(batchA);
|
||||
assert.strictEqual(batchA.cancelled, true, 'batch A cancelled');
|
||||
assert.strictEqual(batchB.cancelled, false, 'batch B unaffected by A cancellation');
|
||||
|
||||
// Batch cancellation mid-iteration: stats accumulate correctly
|
||||
const midCancelStats = t.createBatchStats(5);
|
||||
const s1 = t.recordBatchProcessed(midCancelStats);
|
||||
const s2 = t.recordBatchSkip(s1);
|
||||
// "cancelled" at this point — no more processing, stats frozen
|
||||
assert.strictEqual(s2.processed, 2, 'two files processed before cancel');
|
||||
assert.strictEqual(s2.skipped, 1, 'one skipped before cancel');
|
||||
assert.strictEqual(s2.errors, 0, 'no errors before cancel');
|
||||
assert.strictEqual(s2.total, 5, 'total unchanged by partial processing');
|
||||
|
||||
// ── i18n.ts ──
|
||||
|
||||
assert.strictEqual(t.translate({ uiLanguage: 'zh' }, 'appTitle'), '对照阅读笔记', 'zh translation');
|
||||
|
|
|
|||
Loading…
Reference in a new issue