mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-27 23:35:17 -07:00
fix(plugins): delay card-mined until field grouping and YouTube media
- Hold a sentence card's ready report until field grouping finishes - Report cards waiting on queued YouTube media once it is applied or the download fails - Proxy reports added notes ready right away when auto-update is off - Polling keeps enriching the rest of a batch after one note fails - Update plugin and architecture docs
This commit is contained in:
10 files changed
+210
-24
No files matched your search
@@ -49,3 +49,47 @@ test('polling runner records new cards and reports each ready after enrichment',
|
||||
Date.now = originalDateNow;
|
||||
}
|
||||
});
|
||||
|
||||
test('polling runner keeps going after one note fails to enrich', async () => {
|
||||
const originalDateNow = Date.now;
|
||||
const events: string[] = [];
|
||||
const warnings: unknown[][] = [];
|
||||
let tracked = new Set<number>();
|
||||
const responses = [[10], [10, 12, 13]];
|
||||
try {
|
||||
Date.now = () => 120_000;
|
||||
const runner = new PollingRunner({
|
||||
getDeck: () => undefined,
|
||||
getPollingRate: () => 250,
|
||||
findNotes: async () => responses.shift() ?? [],
|
||||
shouldAutoUpdateNewCards: () => true,
|
||||
processNewCard: async (noteId) => {
|
||||
events.push(`process ${noteId}`);
|
||||
if (noteId === 12) throw new Error('overlay callback failed');
|
||||
},
|
||||
onCardsReady: (noteIds) => {
|
||||
events.push(`ready ${noteIds.join(',')}`);
|
||||
},
|
||||
isUpdateInProgress: () => false,
|
||||
setUpdateInProgress: () => undefined,
|
||||
getTrackedNoteIds: () => tracked,
|
||||
setTrackedNoteIds: (noteIds) => {
|
||||
tracked = noteIds;
|
||||
},
|
||||
showStatusNotification: () => undefined,
|
||||
logDebug: () => undefined,
|
||||
logInfo: () => undefined,
|
||||
logWarn: (...args) => {
|
||||
warnings.push(args);
|
||||
},
|
||||
});
|
||||
|
||||
await runner.pollOnce();
|
||||
await runner.pollOnce();
|
||||
|
||||
assert.deepEqual(events, ['process 12', 'ready 12', 'process 13', 'ready 13']);
|
||||
assert.deepEqual(warnings, [['Failed to auto-enrich note 12:', 'overlay callback failed']]);
|
||||
} finally {
|
||||
Date.now = originalDateNow;
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user