forked from mtusi2026/mtusi2026lab5
feat: accept uploads into staging with jobs, outbox and job processor
This commit is contained in:
@@ -3,7 +3,13 @@ import { createHash, randomUUID } from 'crypto';
|
||||
import request from 'supertest';
|
||||
import { PrismaService } from '../src/db/prisma.service';
|
||||
import { S3Service } from '../src/storage/s3.service';
|
||||
import { bearer, createTestApp, registerUser, TestUser } from './helpers';
|
||||
import {
|
||||
bearer,
|
||||
createTestApp,
|
||||
processAttachment,
|
||||
registerUser,
|
||||
TestUser,
|
||||
} from './helpers';
|
||||
import { jpeg, SAMPLE_PNG } from './images';
|
||||
|
||||
describe('Скачивание и привязка вложений (e2e)', () => {
|
||||
@@ -35,8 +41,13 @@ describe('Скачивание и привязка вложений (e2e)', () =
|
||||
.set('Authorization', bearer(user))
|
||||
.set('Content-Type', type)
|
||||
.send(body)
|
||||
.expect(201);
|
||||
return res.body;
|
||||
.expect(202);
|
||||
expect(await processAttachment(app, res.body.id)).toBe('ready');
|
||||
const ready = await request(server)
|
||||
.get(`/api/v1/attachments/${res.body.id}`)
|
||||
.set('Authorization', bearer(user))
|
||||
.expect(200);
|
||||
return ready.body;
|
||||
};
|
||||
|
||||
const get = (path: string, user: TestUser | null = bob) => {
|
||||
@@ -134,7 +145,11 @@ describe('Скачивание и привязка вложений (e2e)', () =
|
||||
it('variant: original явно, отсутствующий 404, неизвестный и повторённый 400', async () => {
|
||||
const { id } = await upload();
|
||||
await get(`/api/v1/attachments/${id}/content?variant=original`).expect(200);
|
||||
await get(`/api/v1/attachments/${id}/content?variant=thumbnail`).expect(404);
|
||||
await get(`/api/v1/attachments/${id}/content?variant=thumbnail`).expect(200);
|
||||
await app.get(PrismaService).attachmentVariant.deleteMany({
|
||||
where: { attachmentId: id, name: 'crop' },
|
||||
});
|
||||
await get(`/api/v1/attachments/${id}/content?variant=crop`).expect(404);
|
||||
await get(`/api/v1/attachments/${id}/content?variant=nonsense`).expect(400);
|
||||
await get(`/api/v1/attachments/${id}/content?variant=`).expect(400);
|
||||
await get(`/api/v1/attachments/${id}/content?variant=original&variant=original`).expect(400);
|
||||
|
||||
Reference in New Issue
Block a user