- Shared: link building, feed ordering, input schemas, API client - API unit: track matching, private-address blocking, token crypto, plan expiry, provider response parsing - API integration against Postgres and Redis: auth, follows and pins, now-playing state, webhooks, OAuth return URLs, realtime, rate limits - Tests use a dedicated *_test database and Redis DB, and refuse to wipe anything else; fetch is stubbed so they never hit the network - Pin Node to 22.13+ (.nvmrc), which Vite's native bindings require Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
15 lines
557 B
TypeScript
15 lines
557 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { useTestApp } from './helpers';
|
|
|
|
const app = useTestApp({ rateLimits: true });
|
|
|
|
describe('rate limits', () => {
|
|
it('throttles login attempts per client', async () => {
|
|
const attempt = () => app().inject({ method: 'POST', url: '/auth/login', payload: { email: 'a@b.co', password: 'x' } });
|
|
const codes = [];
|
|
for (let i = 0; i < 11; i++) codes.push((await attempt()).statusCode);
|
|
expect(codes.slice(0, 10).every((c) => c === 401)).toBe(true);
|
|
expect(codes[10]).toBe(429);
|
|
});
|
|
});
|