mirror of
https://github.com/immich-app/immich.git
synced 2026-08-03 09:21:49 -07:00
strict search shapes
This commit is contained in:
@@ -130,6 +130,42 @@ describe(SearchController.name, () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject an unknown field on the request body', async () => {
|
||||
const { status, body } = await request(ctx.getHttpServer())
|
||||
.post('/search/metadata')
|
||||
.send({ filter: {}, oderBy: { field: 'rating' } });
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.validationError([{ path: [], message: 'Unrecognized key: "oderBy"' }]));
|
||||
});
|
||||
|
||||
it('should reject an unknown key in the filter', async () => {
|
||||
const { status, body } = await request(ctx.getHttpServer())
|
||||
.post('/search/metadata')
|
||||
.send({ filter: { previewPath: { eq: 'preview.webp' } } });
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.validationError([{ path: ['filter'], message: 'Unrecognized key: "previewPath"' }]));
|
||||
});
|
||||
|
||||
it('should reject a nested or', async () => {
|
||||
const { status, body } = await request(ctx.getHttpServer())
|
||||
.post('/search/metadata')
|
||||
.send({ filter: { or: [{ or: [{ city: { eq: 'Oslo' } }] }] } });
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(
|
||||
errorDto.validationError([{ path: ['filter', 'or', 0], message: 'Unrecognized key: "or"' }]),
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject an empty or branch', async () => {
|
||||
const { status, body } = await request(ctx.getHttpServer())
|
||||
.post('/search/metadata')
|
||||
.send({ filter: { or: [{}] } });
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(
|
||||
errorDto.validationError([{ path: ['filter', 'or', 0], message: 'At least one filter condition is required' }]),
|
||||
);
|
||||
});
|
||||
|
||||
describe('POST /search/random', () => {
|
||||
it('should be an authenticated route', async () => {
|
||||
await request(ctx.getHttpServer()).post('/search/random');
|
||||
|
||||
Reference in New Issue
Block a user