Public Access
feat(questions): list and restore removed games
Add a "Removed games" section on the questions page and an Undo toast after removing a manual game (#39).
This commit is contained in:
1 parent
c126592887
commit
84b16a2ca8
14 files changed
+280
-9
No files matched your search
@@ -20,7 +20,8 @@ const loggedInAs = (me, routes = {}, options = {}) => {
|
||||
localStorage.setItem('tbp_session', '1');
|
||||
fetchRoutes({'GET /api/users/me': json(200, me), 'GET /api/library/steam-profile': json(200, {}),
|
||||
'GET /api/inbox': json(200, {results: [], unread: 0}),
|
||||
'GET /api/library/questions/count': json(200, {count: 0}), ...routes});
|
||||
'GET /api/library/questions/count': json(200, {count: 0}),
|
||||
'GET /api/library/removed-games': json(200, {results: []}), ...routes});
|
||||
renderWithProviders(<AppHeader isAuthenticated onLogout={() => {}}/>, options);
|
||||
};
|
||||
|
||||
@@ -108,6 +109,24 @@ describe('AppHeader', () => {
|
||||
expect((await screen.findByRole('link', {name: 'NAV.QUESTIONS_OPEN:2'})).className).not.toContain('max-sm:hidden');
|
||||
});
|
||||
|
||||
it('keeps the questions icon at every width while the user has removed games', async () => {
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'},
|
||||
{'GET /api/library/removed-games': json(200, {results: [{appid: 1, name: 'Game'}]})});
|
||||
|
||||
await vi.waitFor(() => expect(screen.getByTitle('NAV.QUESTIONS').className).not.toContain('max-sm:hidden'));
|
||||
});
|
||||
|
||||
it('skipsTheRemovedGamesCallWhileQuestionsAreOpen', async () => {
|
||||
const removed = vi.fn(() => json(200, {results: []}));
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'}, {'GET /api/library/questions/count': json(200, {count: 2}),
|
||||
'GET /api/library/removed-games': removed});
|
||||
|
||||
await screen.findByRole('link', {name: 'NAV.QUESTIONS_OPEN:2'});
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
expect(removed).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('keeps the questions icon below sm on the questions page, without a badge', async () => {
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'}, {'GET /api/library/questions/count': json(200, {count: 0})},
|
||||
{entries: ['/questions']});
|
||||
|
||||
Reference in new issue
Block a user