fix(library): seed-pass flip guard, manga null-sentinel, mangadex resolve
- comic/manga sync(): a note's first-ever observed issue/chapter number (no prior latest_issue/latest_chapter) now seeds the baseline without flipping read_status or notifying. Previously `prev === null` counted as "newer", so a Read note with no stored baseline flipped to Unread on its very first real sync. Flips now require a prior value AND a strictly greater candidate AND read_status Read, mirroring the watchlist build.ts `prevLast &&` guard. - manga rss/last_chapter_date: quotedOrNull renders an unset value as the literal `null` token; on the next parse that string came back truthy, so an unset rss field was fetched as the URL "null" and isActive treated it as "has rss -> active" forever. Sentinel is now stripped back to '' everywhere it's read from frontmatter. - manga resolve(): best-effort MangaDex id lookup by title (unique-exact match against attributes.title + altTitles) runs alongside the existing MAL lookup when the note has no mangadex_id yet. Any failure (no match, ambiguous, network error) is logged and skipped, leaving the mal_id patch intact.
This commit is contained in:
parent
1d5537742f
commit
ea5ddd9454
4 changed files with 254 additions and 11 deletions
|
|
@ -462,3 +462,26 @@ describe('comicSpec.sync — issue flip', () => {
|
|||
expect(result!.content).toContain('latest_issue: 10');
|
||||
});
|
||||
});
|
||||
|
||||
describe('comicSpec.sync — seed pass (I3): no stored latest_issue never flips even when Read', () => {
|
||||
test('Read comic, no stored latest_issue, API issue 10 -> seeds latest_issue, read_status stays Read, no notify', async () => {
|
||||
const deps = makeDeps({ http: async () => comicvineFixture, getKey: () => 'cvkey' });
|
||||
const fm = { comicvine_id: '195824', read_status: 'Read' };
|
||||
const result = await comicSpec.sync(ctxFor(fm), deps);
|
||||
expect(result!.flipped).toBe(false);
|
||||
expect(result!.content).toContain('latest_issue: 10');
|
||||
expect(result!.content).toContain('read_status: Read');
|
||||
expect(deps.notifyCalls).toEqual([]);
|
||||
});
|
||||
|
||||
test('subsequent sync with a higher issue number -> flip + notify (baseline now present)', async () => {
|
||||
const cvNext = { results: { ...CV_RESULT, last_issue: { issue_number: '11', name: 'Next Issue' } } };
|
||||
const deps = makeDeps({ http: async () => cvNext, getKey: () => 'cvkey' });
|
||||
const fm = { comicvine_id: '195824', read_status: 'Read', latest_issue: '10' };
|
||||
const result = await comicSpec.sync(ctxFor(fm), deps);
|
||||
expect(result!.flipped).toBe(true);
|
||||
expect(result!.content).toContain('latest_issue: 11');
|
||||
expect(result!.content).toContain('read_status: Unread');
|
||||
expect(deps.notifyCalls).toEqual(['«Absolute Batman» issue 11 out']);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue