refactor!: disallow star rating < 1 (#27896)

Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
Co-authored-by: timonrieger <mail@timonrieger.de>
This commit is contained in:
Mees Frensel
2026-06-04 19:06:28 +02:00
committed by GitHub
parent 6268d23d12
commit 99281de6ab
29 changed files with 141 additions and 82 deletions
@@ -240,7 +240,7 @@ describe(AssetController.name, () => {
for (const [test, errors] of [
[{ rating: 7 }, [{ path: ['rating'], message: 'Too big: expected number to be <=5' }]],
[{ rating: 3.5 }, [{ path: ['rating'], message: 'Invalid input: expected int, received number' }]],
[{ rating: -2 }, [{ path: ['rating'], message: 'Too small: expected number to be >=-1' }]],
[{ rating: -2 }, [{ path: ['rating'], message: 'Too small: expected number to be >=1' }]],
] as const) {
const { status, body } = await request(ctx.getHttpServer()).put(`/assets/${factory.uuid()}`).send(test);
expect(status).toBe(400);
@@ -248,16 +248,9 @@ describe(AssetController.name, () => {
}
});
it('should convert rating 0 to null', async () => {
const assetId = factory.uuid();
const { status } = await request(ctx.getHttpServer()).put(`/assets/${assetId}`).send({ rating: 0 });
expect(service.update).toHaveBeenCalledWith(undefined, assetId, { rating: null });
expect(status).toBe(200);
});
it('should leave correct ratings as-is', async () => {
const assetId = factory.uuid();
for (const test of [{ rating: -1 }, { rating: 1 }, { rating: 5 }]) {
for (const test of [{ rating: 1 }, { rating: 5 }]) {
const { status } = await request(ctx.getHttpServer()).put(`/assets/${assetId}`).send(test);
expect(service.update).toHaveBeenCalledWith(undefined, assetId, test);
expect(status).toBe(200);