mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 20:12:54 -07:00
fix: address PR #57 CodeRabbit feedback
- Acquire AniList post-watch in-flight lock before async gating to prevent duplicate writes - Isolate manual watched mark result from AniList post-watch callback failures - Report known-word cache clears as mutations during immediate append when state existed - Add regression tests for each fix
This commit is contained in:
@@ -326,6 +326,38 @@ test('registerIpcHandlers runs AniList update after manual mark watched succeeds
|
||||
assert.deepEqual(calls, ['mark', 'anilist']);
|
||||
});
|
||||
|
||||
test('registerIpcHandlers isolates AniList update failures after manual mark watched succeeds', async () => {
|
||||
const { registrar, handlers } = createFakeIpcRegistrar();
|
||||
const calls: string[] = [];
|
||||
const originalWarn = console.warn;
|
||||
console.warn = () => undefined;
|
||||
|
||||
try {
|
||||
registerIpcHandlers(
|
||||
createRegisterIpcDeps({
|
||||
immersionTracker: createFakeImmersionTracker({
|
||||
markActiveVideoWatched: async () => {
|
||||
calls.push('mark');
|
||||
return true;
|
||||
},
|
||||
}),
|
||||
runAnilistPostWatchUpdateOnManualMark: async () => {
|
||||
calls.push('anilist');
|
||||
throw new Error('post-watch failed');
|
||||
},
|
||||
}),
|
||||
registrar,
|
||||
);
|
||||
|
||||
const result = await handlers.handle.get(IPC_CHANNELS.command.markActiveVideoWatched)?.({});
|
||||
|
||||
assert.equal(result, true);
|
||||
assert.deepEqual(calls, ['mark', 'anilist']);
|
||||
} finally {
|
||||
console.warn = originalWarn;
|
||||
}
|
||||
});
|
||||
|
||||
test('registerIpcHandlers skips AniList update when manual mark watched has no active session', async () => {
|
||||
const { registrar, handlers } = createFakeIpcRegistrar();
|
||||
const calls: string[] = [];
|
||||
|
||||
@@ -390,7 +390,14 @@ export function registerIpcHandlers(deps: IpcServiceDeps, ipc: IpcMainRegistrar
|
||||
ipc.handle(IPC_CHANNELS.command.markActiveVideoWatched, async () => {
|
||||
const marked = (await deps.immersionTracker?.markActiveVideoWatched()) ?? false;
|
||||
if (marked) {
|
||||
await deps.runAnilistPostWatchUpdateOnManualMark?.();
|
||||
try {
|
||||
await deps.runAnilistPostWatchUpdateOnManualMark?.();
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
'Failed to run AniList post-watch update after manual watched mark:',
|
||||
(error as Error).message,
|
||||
);
|
||||
}
|
||||
}
|
||||
return marked;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user