Public Access
feat(questions): add questions page with open count badge
Add /questions page and a nav badge with the open count. Core decides which question is open. The page only shows and answers. Move RatingStars out of BacklogCard so both pages share it.
This commit is contained in:
1 parent
1dab069a4d
commit
d3ad19e2fa
15 files changed
+567
-33
No files matched your search
@@ -19,7 +19,8 @@ afterEach(() => {
|
||||
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}), ...routes});
|
||||
'GET /api/inbox': json(200, {results: [], unread: 0}),
|
||||
'GET /api/library/questions/count': json(200, {count: 0}), ...routes});
|
||||
renderWithProviders(<AppHeader isAuthenticated onLogout={() => {}}/>, options);
|
||||
};
|
||||
|
||||
@@ -86,6 +87,44 @@ describe('AppHeader', () => {
|
||||
expect(link.textContent).toBe('');
|
||||
});
|
||||
|
||||
it('shows how many questions are open', async () => {
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'}, {'GET /api/library/questions/count': json(200, {count: 12})});
|
||||
|
||||
const link = await screen.findByRole('link', {name: 'NAV.QUESTIONS_OPEN:12'});
|
||||
|
||||
expect(link.getAttribute('href')).toBe('/questions');
|
||||
expect(link.textContent).toBe('NAV.QUESTIONS9+');
|
||||
});
|
||||
|
||||
it('hides the questions icon below sm while no question is open', async () => {
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'});
|
||||
|
||||
expect((await screen.findByTitle('NAV.QUESTIONS')).className).toContain('max-sm:hidden');
|
||||
});
|
||||
|
||||
it('keeps the questions icon at every width while questions are open', async () => {
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'}, {'GET /api/library/questions/count': json(200, {count: 2})});
|
||||
|
||||
expect((await screen.findByRole('link', {name: 'NAV.QUESTIONS_OPEN:2'})).className).not.toContain('max-sm:hidden');
|
||||
});
|
||||
|
||||
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']});
|
||||
|
||||
expect((await screen.findByTitle('NAV.QUESTIONS')).className).not.toContain('max-sm:hidden');
|
||||
});
|
||||
|
||||
it('shows no question count on the questions page, whose title has it', async () => {
|
||||
loggedInAs({role: 'USER', activeRole: 'USER'}, {'GET /api/library/questions/count': json(200, {count: 3})},
|
||||
{entries: ['/questions']});
|
||||
|
||||
await vi.waitFor(() => expect(fetch).toHaveBeenCalledWith(expect.stringContaining('/api/library/questions/count'), expect.anything()));
|
||||
|
||||
expect(screen.getByTitle('NAV.QUESTIONS').textContent).toBe('NAV.QUESTIONS');
|
||||
expect(screen.queryByRole('link', {name: 'NAV.QUESTIONS_OPEN:3'})).toBeNull();
|
||||
});
|
||||
|
||||
it('offers the admin page and "view as" to an admin', async () => {
|
||||
loggedInAs({role: 'PLATFORM_ADMIN', activeRole: 'PLATFORM_ADMIN'},
|
||||
{'GET /api/admin/users/pending-count': json(200, {count: 0})});
|
||||
|
||||
Reference in new issue
Block a user