feat(stats): add chart form pickers to dashboard and profile tiles
Build, Test & Push Frontend / quality-check (push) Successful in 31s
Build, Test & Push Frontend / docker (push) Successful in 23s

This commit is contained in:
lobo committed 2026-10-04 21:06:21 +02:00
1 parent 13b0d5e7e9
commit de199a20b7
19 files changed
+507 -98

No files matched your search

+48
View File
@@ -408,6 +408,54 @@ describe('PublicProfilePage', () => {
}
});
const tasteStats = {pile: null, trend: null, finished: null, habits: null, topGames: null, platforms: null,
taste: {genres: [{name: 'Shooter', games: 2, minutes: 1200}, {name: 'Puzzle', games: 1, minutes: 300}], moods: []}};
it('theOwnerGetsThePickerOnATasteTile', async () => {
localStorage.setItem('tbp_session', '1');
library.stats = tasteStats;
try {
mockBackends({me: {displayName: 'lobo', role: 'USER', settings: {}}, style: {tiles: [{id: 'STATS_TASTE', size: 'M'}]},
extra: {'PUT /api/users/settings/stat-chart': json(204, {})}});
const {container} = renderPage();
fireEvent.click(await screen.findByRole('button', {name: 'STATS.CHART.DONUT'}));
await waitFor(() => expect(container.querySelectorAll('path.stroke-card').length).toBeGreaterThan(0));
const bodies = fetch.mock.calls.filter(([, init]) => init?.method === 'PUT').map(([, init]) => JSON.parse(init.body));
expect(bodies).toEqual([{group: 'TASTE', chart: 'DONUT'}]);
} finally {
delete library.stats;
localStorage.clear();
}
});
const twoGameStats = {...topGamesStats, topGames: {mostLoyal: null, mostPlayed: [
{appid: 620, name: 'Portal 2', imageUrl: null, minutes: 900}, {appid: 220, name: 'Half-Life 2', imageUrl: null, minutes: 300}]}};
it('topGamesPieLinksForTheOwnerAndIsPlainForAVisitor', async () => {
localStorage.setItem('tbp_session', '1');
library.stats = twoGameStats;
try {
const style = {tiles: [{id: 'STATS_TOP_GAMES', size: 'M'}], statCharts: {TOP_GAMES: 'PIE'}};
mockBackends({me: {displayName: 'lobo', role: 'USER', settings: {statCharts: {TOP_GAMES: 'PIE'}}}, style});
const {unmount} = renderPage();
expect((await screen.findByRole('link', {name: /Portal 2/})).getAttribute('href')).toBe('/library/620');
unmount();
cleanup();
localStorage.clear();
mockBackends({style});
renderPage();
await screen.findByText('Portal 2');
expect(screen.queryByRole('link', {name: /Portal 2/})).toBeNull();
expect(screen.queryByRole('button', {name: /Portal 2/})).toBeNull();
} finally {
delete library.stats;
localStorage.clear();
}
});
it('showsBarsForAFormTheProfileDoesNotKnow', async () => {
library.stats = platformStats;
try {