Public Access
feat(points): show points result on every status save
Core now settles on GET /api/rewards/games/{appid}. The Frontend
shows a toast, refreshes the header balance, and lists the paid
rows and reasons on the game page. Deploy Core first.
This commit is contained in:
1 parent
9adc606c57
commit
814decc781
20 files changed
+429
-12
No files matched your search
@@ -8,7 +8,7 @@ import {PreferencesProvider} from '../context/PreferencesContext.jsx';
|
||||
import {fetchRoutes, json} from '../test/fetchRoutes.js';
|
||||
|
||||
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
|
||||
vi.mock('sonner', () => ({toast: {success: vi.fn(), error: vi.fn()}}));
|
||||
vi.mock('sonner', () => ({toast: Object.assign(vi.fn(), {success: vi.fn(), error: vi.fn()})}));
|
||||
|
||||
const game = (appid, extra = {}) => ({
|
||||
appid, name: `Game ${appid}`, playtimeMinutes: 0, status: 'BACKLOG', rating: null, priority: null,
|
||||
@@ -33,6 +33,9 @@ function mockBackend(answer, routes = {}) {
|
||||
fetchRoutes({
|
||||
'GET /api/library/picker': (url) => json(200, {categories: answer(new URL(url, 'http://x').searchParams)}),
|
||||
'PUT /api/library/games/7/status': (url, init) => json(200, JSON.parse(init.body)),
|
||||
'GET /api/rewards/games/7': json(200, {balance: 5, missing: {}, paid: [
|
||||
{kind: 'STARTED', appid: 7, points: 5, paidAt: '2026-10-09T10:00:00Z', bookedNow: true}]}),
|
||||
'GET /api/rewards/wallet': json(200, {balance: 5, catalog: [], owned: [], equipped: {}, history: []}),
|
||||
...routes,
|
||||
});
|
||||
}
|
||||
@@ -323,6 +326,17 @@ describe('PlayNextPage', () => {
|
||||
expect(JSON.parse(puts[0][1].body)).toEqual({status: 'PLAYING'});
|
||||
});
|
||||
|
||||
it('shows the points toast after Start', async () => {
|
||||
mockRows([row('NEXT_UP', game(7))]);
|
||||
renderPage();
|
||||
await screen.findByText('Game 7');
|
||||
|
||||
fireEvent.click(screen.getByRole('button', {name: 'PLAY_NEXT.START_PLAYING'}));
|
||||
|
||||
await waitFor(() => expect(toast.success).toHaveBeenCalledWith('POINTS.GAME.TOAST_BOOKED:5'));
|
||||
expect(globalThis.fetch.mock.calls.filter(([url]) => url.includes('/api/rewards/games/7'))).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('lets the user try again when saving fails', async () => {
|
||||
mockBackend(() => [row('NEXT_UP', game(7))], {'PUT /api/library/games/7/status': json(500, {})});
|
||||
renderPage();
|
||||
|
||||
Reference in new issue
Block a user