feat(library): rating line, manga finish-flip notify, game links, dedupe
- render **Rating:** line in manga/book/game/comic body (after read/play status, gated on rating != '0' + stars non-empty), matching watchlist's render.ts convention - manga finish-flip now notifies user (final chapters out), matching chapter-flip's existing notify path - game renderGame emits ## Links (Steam by appid, RAWG by url) — fixes latent owned-heading strip where user-added Links sections silently vanished since games never re-rendered the heading - move duplicated deriveReadStatus/deriveRating/parseNumOrNull into library/convert.ts, import across specs; zero behavior change
This commit is contained in:
parent
d2a6940270
commit
c14da19c47
13 changed files with 140 additions and 83 deletions
|
|
@ -196,6 +196,39 @@ describe('renderGame golden', () => {
|
|||
expect(out).toContain('## My Notes\n\nplayed co-op with a friend');
|
||||
});
|
||||
|
||||
test('rating line present when rating set', () => {
|
||||
expect(renderGame(RECORD, '')).toContain('**Rating:** ⭐️⭐️⭐️⭐️ (4/5)');
|
||||
});
|
||||
|
||||
test('rating 0 -> Rating line absent', () => {
|
||||
const r = { ...RECORD, rating: '0', ratingStars: '' };
|
||||
expect(renderGame(r, '')).not.toContain('**Rating:**');
|
||||
});
|
||||
|
||||
test('links present w/ steam appid', () => {
|
||||
expect(renderGame(RECORD, '')).toContain('- [Steam](https://store.steampowered.com/app/792100/)');
|
||||
});
|
||||
|
||||
test('links absent when no ids', () => {
|
||||
const r = { ...RECORD, steamAppid: '', rawgId: '', url: '' };
|
||||
const out = renderGame(r, '');
|
||||
expect(out).not.toContain('## Links');
|
||||
});
|
||||
|
||||
test('rawg link uses url field verbatim when rawg_id set', () => {
|
||||
const r = { ...RECORD, steamAppid: '', rawgId: '4200', url: 'https://rawg.io/games/4200' };
|
||||
const out = renderGame(r, '');
|
||||
expect(out).toContain('- [RAWG](https://rawg.io/games/4200)');
|
||||
expect(out).not.toContain('[Steam]');
|
||||
});
|
||||
|
||||
test('both ids set -> both Steam and RAWG links present', () => {
|
||||
const r = { ...RECORD, rawgId: '4200', url: 'https://rawg.io/games/4200' };
|
||||
const out = renderGame(r, '');
|
||||
expect(out).toContain('- [Steam](https://store.steampowered.com/app/792100/)');
|
||||
expect(out).toContain('- [RAWG](https://rawg.io/games/4200)');
|
||||
});
|
||||
|
||||
test('no poster -> poster line omitted', () => {
|
||||
const r = { ...RECORD, poster: null };
|
||||
expect(renderGame(r, '')).not.toContain('\n\n## Collection\nPart of [[Games]]\n\n## My Notes\n\n';
|
||||
const result = await gameSpec.sync(ctxFor({ steam_appid: '792100' }, body), deps);
|
||||
const content = result!.content;
|
||||
expect((content.match(/## Links/g) ?? []).length).toBe(1);
|
||||
expect(content).toContain('- [Steam](https://store.steampowered.com/app/792100/)');
|
||||
expect(content).not.toContain('Old link');
|
||||
expect(content).toContain('## Collection\nPart of [[Games]]\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('gameSpec.sync — rawg enrich', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue