Public Access
feat(ui): add people lists for game owners and community stats
This commit is contained in:
1 parent
b213b067dc
commit
3aed243e35
22 files changed
+425
-12
No files matched your search
@@ -6,7 +6,8 @@ import LandingPage from './LandingPage.jsx';
|
||||
import {fetchRoutes, json} from '../test/fetchRoutes.js';
|
||||
|
||||
vi.mock('react-i18next', () => import('../test/i18n-mock.js'));
|
||||
vi.mock('../hooks/useSession.js', () => ({default: () => ({active: false})}));
|
||||
const session = vi.hoisted(() => ({active: false}));
|
||||
vi.mock('../hooks/useSession.js', () => ({default: () => session}));
|
||||
|
||||
// Auth and Core answer the same path; one object serves both shapes.
|
||||
const answer = (core) => fetchRoutes({'GET /api/stats/public': json(200, {topPlayedGames: [], topOwnedGames: [], ...core})});
|
||||
@@ -14,7 +15,10 @@ const answer = (core) => fetchRoutes({'GET /api/stats/public': json(200, {topPla
|
||||
const renderPage = () => render(<MemoryRouter><LandingPage/></MemoryRouter>);
|
||||
|
||||
describe('LandingPage', () => {
|
||||
afterEach(cleanup);
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
session.active = false;
|
||||
});
|
||||
|
||||
it('shows games per platform, top genres and finished per year', async () => {
|
||||
answer({
|
||||
@@ -76,4 +80,24 @@ describe('LandingPage', () => {
|
||||
|
||||
expect(screen.queryByRole('button', {name: /LANDING\.TOTAL_GAMES/})).toBeNull();
|
||||
});
|
||||
|
||||
it('opensTheUserListOnlyWithASession', async () => {
|
||||
fetchRoutes({
|
||||
'GET /api/stats/public': json(200, {topPlayedGames: [], topOwnedGames: [], totalUsers: 4, usersWithSteamLinked: 2}),
|
||||
'GET /api/stats/users': json(200, {listed: [{displayName: 'Lobo'}], listedTotal: 1, privateCount: 3,
|
||||
includesYou: false, page: 0, totalPages: 1}),
|
||||
});
|
||||
const {unmount} = renderPage();
|
||||
await screen.findByText('LANDING.TOTAL_USERS');
|
||||
expect(screen.queryByRole('button', {name: /LANDING\.TOTAL_USERS/})).toBeNull();
|
||||
unmount();
|
||||
|
||||
session.active = true;
|
||||
renderPage();
|
||||
fireEvent.click(await screen.findByRole('button', {name: /LANDING\.TOTAL_USERS/}));
|
||||
|
||||
expect(await screen.findByRole('link', {name: 'Lobo'})).toBeTruthy();
|
||||
expect(screen.getByText('PEOPLE.PRIVATE:3')).toBeTruthy();
|
||||
expect(fetch.mock.calls.at(-1)[0]).toContain('/api/stats/users?key=TOTAL_USERS&page=0');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user