Public Access
fix(stats): open game detail pages from stat lists, perfect games clickable
Add perfect games click-through on the dashboard. Remove Steam store links from game lists. Stat numbers with count 0 are not clickable. Tests cover the perfect-games click, zero guards, and owner versus visitor behavior.
This commit is contained in:
1 parent
777ba87fd6
commit
8b94a25844
27 files changed
+270
-51
No files matched your search
@@ -1,8 +1,10 @@
|
||||
// @vitest-environment jsdom
|
||||
import {afterEach, describe, expect, it, vi} from 'vitest';
|
||||
import {cleanup, render, screen} from '@testing-library/react';
|
||||
import {cleanup, fireEvent, render, screen} from '@testing-library/react';
|
||||
import {MemoryRouter} from 'react-router-dom';
|
||||
import AchievementsCard from './AchievementsCard.jsx';
|
||||
import {StatDrillProvider} from './stats/StatDrill.jsx';
|
||||
import {fetchRoutes, json} from '../test/fetchRoutes.js';
|
||||
|
||||
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
|
||||
|
||||
@@ -49,4 +51,22 @@ describe('AchievementsCard', () => {
|
||||
|
||||
expect(screen.getByText('DASHBOARD.ACHIEVEMENTS.NONE')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('opensThePerfectGamesInTheOwnLibrary', async () => {
|
||||
fetchRoutes({'GET /api/library/stats/games': json(200, {
|
||||
content: [{appid: -7, name: 'Manual Game'}], page: 0, size: 40, totalElements: 1, totalPages: 1})});
|
||||
render(<MemoryRouter><StatDrillProvider source="own"><AchievementsCard summary={summary()}/></StatDrillProvider></MemoryRouter>);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', {name: 'DASHBOARD.ACHIEVEMENTS.PERFECT: 2'}));
|
||||
|
||||
const link = await screen.findByRole('link', {name: /Manual Game/});
|
||||
expect(fetch.mock.calls[0][0]).toContain('key=PERFECT&page=0');
|
||||
expect(link.getAttribute('href')).toBe('/library/-7');
|
||||
});
|
||||
|
||||
it('perfectGamesAreNotClickableAtZero', () => {
|
||||
render(<MemoryRouter><StatDrillProvider source="own"><AchievementsCard summary={summary({perfectGames: 0})}/></StatDrillProvider></MemoryRouter>);
|
||||
|
||||
expect(screen.queryByRole('button')).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user