feat(editor): Bild-Block skip wenn recipe.id === null
This commit is contained in:
@@ -57,7 +57,7 @@ describe('POST /api/recipes/extract-from-photo', () => {
|
||||
it('happy path: 200 with recipe shape', async () => {
|
||||
mockExtract.mockResolvedValueOnce(validAiResponse);
|
||||
const fd = new FormData();
|
||||
fd.append('photo', new Blob([await makeJpeg()], { type: 'image/jpeg' }), 'x.jpg');
|
||||
fd.append('photo', new Blob([new Uint8Array(await makeJpeg())], { type: 'image/jpeg' }), 'x.jpg');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await POST(mkEvent(fd) as any);
|
||||
expect(res.status).toBe(200);
|
||||
@@ -73,7 +73,7 @@ describe('POST /api/recipes/extract-from-photo', () => {
|
||||
it('413 when file exceeds 8 MB', async () => {
|
||||
const big = Buffer.alloc(9 * 1024 * 1024);
|
||||
const fd = new FormData();
|
||||
fd.append('photo', new Blob([big], { type: 'image/jpeg' }));
|
||||
fd.append('photo', new Blob([new Uint8Array(big)], { type: 'image/jpeg' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await POST(mkEvent(fd, '1.1.1.1') as any);
|
||||
expect(res.status).toBe(413);
|
||||
@@ -82,7 +82,7 @@ describe('POST /api/recipes/extract-from-photo', () => {
|
||||
|
||||
it('415 when content-type not in whitelist', async () => {
|
||||
const fd = new FormData();
|
||||
fd.append('photo', new Blob([Buffer.from('hi')], { type: 'text/plain' }));
|
||||
fd.append('photo', new Blob([new Uint8Array(Buffer.from('hi'))], { type: 'text/plain' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await POST(mkEvent(fd, '2.2.2.2') as any);
|
||||
expect(res.status).toBe(415);
|
||||
@@ -103,7 +103,7 @@ describe('POST /api/recipes/extract-from-photo', () => {
|
||||
steps: []
|
||||
});
|
||||
const fd = new FormData();
|
||||
fd.append('photo', new Blob([await makeJpeg()], { type: 'image/jpeg' }));
|
||||
fd.append('photo', new Blob([new Uint8Array(await makeJpeg())], { type: 'image/jpeg' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await POST(mkEvent(fd, '4.4.4.4') as any);
|
||||
expect(res.status).toBe(422);
|
||||
@@ -115,7 +115,7 @@ describe('POST /api/recipes/extract-from-photo', () => {
|
||||
new GeminiError('AI_NOT_CONFIGURED', 'no key')
|
||||
);
|
||||
const fd = new FormData();
|
||||
fd.append('photo', new Blob([await makeJpeg()], { type: 'image/jpeg' }));
|
||||
fd.append('photo', new Blob([new Uint8Array(await makeJpeg())], { type: 'image/jpeg' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await POST(mkEvent(fd, '5.5.5.5') as any);
|
||||
expect(res.status).toBe(503);
|
||||
@@ -127,12 +127,12 @@ describe('POST /api/recipes/extract-from-photo', () => {
|
||||
const ip = '9.9.9.9';
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const fd = new FormData();
|
||||
fd.append('photo', new Blob([await makeJpeg()], { type: 'image/jpeg' }));
|
||||
fd.append('photo', new Blob([new Uint8Array(await makeJpeg())], { type: 'image/jpeg' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await POST(mkEvent(fd, ip) as any);
|
||||
}
|
||||
const last = new FormData();
|
||||
last.append('photo', new Blob([await makeJpeg()], { type: 'image/jpeg' }));
|
||||
last.append('photo', new Blob([new Uint8Array(await makeJpeg())], { type: 'image/jpeg' }));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await POST(mkEvent(last, ip) as any);
|
||||
expect(res.status).toBe(429);
|
||||
|
||||
Reference in New Issue
Block a user