feat(backlog): save only the changed fields

This commit is contained in:
lobo committed 2026-09-30 07:57:52 +02:00
1 parent 9ddc50f819
commit 628920a006
6 files changed
+133 -83

No files matched your search

+6 -5
View File
@@ -14,7 +14,8 @@ const renderHint = (props) => render(<MemoryRouter><PlayingHint game={game} onCh
describe('PlayingHint', () => {
beforeEach(() => {
localStorage.setItem('tbp_session', '1');
fetchRoutes({'PUT /api/library/games/220/backlog': (url, init) => json(200, JSON.parse(init.body))});
// Core changes only the status and answers the whole entry.
fetchRoutes({'PUT /api/library/games/220/status': (url, init) => json(200, {...game, ...JSON.parse(init.body)})});
});
afterEach(() => {
@@ -31,15 +32,15 @@ describe('PlayingHint', () => {
expect(screen.queryByRole('button')).toBeNull();
});
it('sets the game to PLAYING and keeps the other fields', async () => {
it('sends only the status, so Core keeps the other fields', async () => {
const onChanged = vi.fn();
renderHint({onChanged});
fireEvent.click(screen.getByRole('button', {name: 'GAME_DETAIL.SET_PLAYING'}));
await waitFor(() => expect(onChanged).toHaveBeenCalledWith({status: 'PLAYING', rating: 3, notes: 'keep', priority: 'HIGH'}));
await waitFor(() => expect(onChanged).toHaveBeenCalledWith(expect.objectContaining({status: 'PLAYING'})));
const [url, init] = fetch.mock.calls[0];
expect(url).toMatch(/\/api\/library\/games\/220\/backlog$/);
expect(JSON.parse(init.body)).toEqual({status: 'PLAYING', rating: 3, notes: 'keep', priority: 'HIGH'});
expect(url).toMatch(/\/api\/library\/games\/220\/status$/);
expect(JSON.parse(init.body)).toEqual({status: 'PLAYING'});
});
});