fix: fixes after review

This commit is contained in:
2026-10-22 12:41:28 +03:00
parent 07661cfe82
commit 5146ca8419
8 changed files with 112 additions and 11 deletions
+25
View File
@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { randomUUID } from 'crypto';
import { PrismaService } from '../src/db/prisma.service';
import {
bearer,
createTestApp,
@@ -208,6 +209,30 @@ describe('API мессенджера (e2e) — граничные случаи
.expect(400);
});
it('принимает ровно 100 участников и отклоняет 101', async () => {
const alice = await createUser('max');
const ids = Array.from({ length: 100 }, () => randomUUID());
await app.get(PrismaService).user.createMany({
data: ids.map((id) => ({
id,
username: `m_${id.replace(/-/g, '').slice(0, 30)}`,
displayName: 'Member',
passwordHash: 'not-a-real-hash',
})),
});
const ok = await request(server)
.post('/api/v1/chats')
.set('Authorization', bearer(alice))
.send({ title: 'Max', member_ids: [alice.id, ...ids.slice(0, 99)] })
.expect(201);
expect(ok.body.member_ids).toHaveLength(100);
await request(server)
.post('/api/v1/chats')
.set('Authorization', bearer(alice))
.send({ title: 'Too many', member_ids: [alice.id, ...ids] })
.expect(400);
});
it('отклоняет создание чата с неизвестным участником', async () => {
const alice = await createUser('alice4');
await request(server)