fix: resolve SABnzbd history matching asymmetry and unify search helpers (#74)
Build and Push Docker Image / build (push) Successful in 40s
CI / Security audit (push) Successful in 1m0s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m6s
CI / Swagger Validation & Coverage (push) Successful in 1m36s
CI / Tests & coverage (push) Has been cancelled

This commit is contained in:
2026-05-29 14:35:02 +01:00
parent 6c4aedf60e
commit 87387aaebe
2 changed files with 102 additions and 86 deletions
@@ -226,6 +226,43 @@ describe('DownloadMatcher', () => {
expect(result).toHaveLength(1);
expect(result[0].arrQueueId).toBe(101);
});
it('falls back to title matching against Sonarr queue records when downloadId is absent/unmatched', async () => {
const testContext = {
...context,
sonarrHistoryRecords: [],
sonarrQueueRecords: [
{ id: 201, seriesId: 1, title: 'My.Cool.Show.S01E01.720p-Group' }
],
seriesMap: new Map([[1, { id: 1, title: 'My Cool Show', tags: [1] }]])
};
const slots = [{ id: null, name: 'My_Cool_Show_S01E01_720p-Group.nzb', status: 'Completed', mb: 1000 }];
const result = await DownloadMatcher.matchSabHistory(slots, testContext);
expect(result).toHaveLength(1);
expect(result[0].arrQueueId).toBe(201);
expect(result[0].arrType).toBe('sonarr');
});
it('falls back to title matching against Radarr queue records when downloadId is absent/unmatched', async () => {
const testContext = {
...context,
radarrHistoryRecords: [],
radarrQueueRecords: [
{ id: 301, movieId: 2, title: 'Awesome Movie 2026 1080p' }
],
moviesMap: new Map([[2, { id: 2, title: 'Awesome Movie', tags: [1] }]]),
radarrTagMap: new Map([[1, 'alice']])
};
const slots = [{ id: null, name: 'Awesome.Movie.2026.1080p.nzb', status: 'Completed', mb: 1000 }];
const result = await DownloadMatcher.matchSabHistory(slots, testContext);
expect(result).toHaveLength(1);
expect(result[0].arrQueueId).toBe(301);
expect(result[0].arrType).toBe('radarr');
});
});
describe('titleMatches helper', () => {