feat: replace browser login with imported Reddit sessions
This commit is contained in:
1 parent
2b0545afcf
commit
c483c7b8be
76 files changed
+2048
-2828
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { createDashboardRequest } from '../../apps/dashboard/src/api/request.js';
|
||||
|
||||
describe('dashboard API requests', () => {
|
||||
it('redirects to sign-in when the session is no longer authorized', async () => {
|
||||
const fetchImplementation = vi.fn<typeof fetch>().mockResolvedValue(new Response(
|
||||
JSON.stringify({ error: 'Dashboard authentication required' }),
|
||||
{ status: 401, headers: { 'Content-Type': 'application/json' } },
|
||||
));
|
||||
const redirectToLogin = vi.fn();
|
||||
const request = createDashboardRequest(fetchImplementation, redirectToLogin);
|
||||
|
||||
const response = await request('/api/stats');
|
||||
|
||||
expect(response.status).toBe(401);
|
||||
expect(redirectToLogin).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user