feat(ui): add people lists for game owners and community stats
Build, Test & Push Frontend / quality-check (push) Successful in 47s
Build, Test & Push Frontend / docker (push) Successful in 22s

This commit is contained in:
lobo committed 2026-10-06 13:19:58 +02:00
1 parent b213b067dc
commit 3aed243e35
22 files changed
+425 -12

No files matched your search

+23
View File
@@ -23,6 +23,7 @@ const echo = (url, init) => json(200, JSON.parse(init.body));
// The user and the game at /library/<shown.appid>; `routes` adds or replaces answers.
const answer = (shown, routes = {}, me = {settings: {}}) => fetchRoutes({
'GET /api/users/me': json(200, me),
'GET /api/stats/owners': json(200, {listed: [], listedTotal: 0, privateCount: 0, includesYou: false, page: 0, totalPages: 1}),
[`GET /api/library/games/${shown.appid}`]: json(200, shown),
...routes,
});
@@ -38,6 +39,27 @@ afterEach(() => {
});
describe('GameDetail', () => {
it('showsHowManyOthersOwnTheGameAndOnlyNamesTheListedOnes', async () => {
answer(game, {'GET /api/stats/owners': json(200, {listed: [{displayName: 'Lobo'}], listedTotal: 1, privateCount: 1,
includesYou: true, page: 0, totalPages: 1})});
renderDetail();
expect(await screen.findByText('PEOPLE.OTHER_OWNERS:2')).toBeTruthy();
expect(screen.getByRole('link', {name: 'Lobo'}).getAttribute('href')).toBe('/u/Lobo');
expect(screen.getByText('PEOPLE.PRIVATE:1')).toBeTruthy();
expect(screen.queryByText('PEOPLE.YOU')).toBeNull();
expect(fetch.mock.calls.find(([url]) => url.includes('/api/stats/owners'))[0]).toContain('appid=220&page=0');
});
it('showsNoOwnersTitleWhenNobodyElseOwnsTheGame', async () => {
answer(game, {'GET /api/stats/owners': json(200, {listed: [], listedTotal: 0, privateCount: 0,
includesYou: true, page: 0, totalPages: 0})});
renderDetail();
expect(await screen.findByText('PEOPLE.NONE')).toBeTruthy();
expect(screen.queryByText(/PEOPLE.OTHER_OWNERS/)).toBeNull();
});
it('shows the coming badge of a game that is not released yet', async () => {
answer({...game, source: 'STEAM', coming: true, comingOn: '2026-12-04'});
renderDetail();
@@ -447,6 +469,7 @@ describe('GameDetail session', () => {
it('replacesTheUrlOfAMergedKeyWithTheKeptGame', async () => {
fetchRoutes({
'GET /api/users/me': json(200, {settings: {}}),
'GET /api/stats/owners': json(200, {listed: [], listedTotal: 0, privateCount: 0, includesYou: false, page: 0, totalPages: 1}),
'GET /api/library/games/-7': json(200, {...game, appid: 220, source: 'STEAM'}),
'GET /api/library/games/220': json(200, {...game, appid: 220, source: 'STEAM'}),
});