feat(gacha): add /api/gacha wish animation rendered as MP4

A meteor coloured by rarity falls across a night sky, lands in a white
flash, and the label is revealed with its stars popping in. The caller
picks the result and rarity; the route only draws it. Renders as silent
H.264 so Telegram plays it as an animation without GIF banding, and
shares the render slots with /api/gif.
This commit is contained in:
tiennm99 committed 2026-10-01 11:43:42 +07:00
1 parent 61d0e74709
commit 97d8aeaadf
16 files changed
+1111 -20

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import {describe, expect, test} from 'vitest';
import {parseGachaRequest} from '../src/schemas/gacha-request.js';
const limits = {maxOptionChars: 12};
describe('parseGachaRequest', () => {
test('trims the label and applies defaults', () => {
const request = parseGachaRequest({label: ' Pizza ', rarity: 5}, limits);
expect(request).toEqual({label: 'Pizza', rarity: 5, fps: 24, width: 640});
});
test('accepts the larger frame and fps', () => {
const request = parseGachaRequest({label: 'Pho', rarity: 4, fps: 30, width: 854}, limits);
expect(request.fps).toBe(30);
expect(request.width).toBe(854);
});
test.each([
{label: 'Pizza', rarity: 2},
{label: 'Pizza', rarity: 6},
{label: 'Pizza'},
{label: ' ', rarity: 3},
{label: 'x'.repeat(13), rarity: 3},
{label: 'Pizza', rarity: 3, width: 512},
{label: 'Pizza', rarity: 3, fps: 15},
{label: 'Pizza', rarity: 3, extra: true},
])('rejects %o', (input) => {
expect(() => parseGachaRequest(input, limits)).toThrow();
});
});