fix: svelte check

This commit is contained in:
2026-03-26 15:50:50 +01:00
parent 25d2d1af4a
commit ae4a77f5dd
2 changed files with 15 additions and 6 deletions

View File

@@ -184,7 +184,7 @@ describe('submitScoreSchema', () => {
test('accepts valid score submission', () => {
const valid = {
matchGameId: uuid1,
scores: [{ participantId: uuid2, score: 1000000 }]
scores: [{ playerId: uuid2, score: 1000000 }]
};
expect(submitScoreSchema.parse(valid)).toBeTruthy();
});
@@ -193,7 +193,7 @@ describe('submitScoreSchema', () => {
expect(() =>
submitScoreSchema.parse({
matchGameId: uuid1,
scores: [{ participantId: uuid2, score: -1 }]
scores: [{ playerId: uuid2, score: -1 }]
})
).toThrow();
});
@@ -204,7 +204,7 @@ describe('submitScoreSchema', () => {
test('rejects scores array over 16 entries', () => {
const scores = Array.from({ length: 17 }, (_, i) => ({
participantId: `550e8400-e29b-41d4-a716-4466554400${String(i).padStart(2, '0')}`,
playerId: `550e8400-e29b-41d4-a716-4466554400${String(i).padStart(2, '0')}`,
score: 100
}));
expect(() => submitScoreSchema.parse({ matchGameId: uuid1, scores })).toThrow();
@@ -214,7 +214,7 @@ describe('submitScoreSchema', () => {
expect(() =>
submitScoreSchema.parse({
matchGameId: 'bad',
scores: [{ participantId: uuid2, score: 100 }]
scores: [{ playerId: uuid2, score: 100 }]
})
).toThrow();
});

View File

@@ -40,8 +40,17 @@ export const createInviteSchema = z.object({
// ── Score submission ──
const scoreEntrySchema = z.object({
participantId: z.string().uuid(),
score: z.number().int().min(0)
playerId: z.string().uuid(),
score: z.number().int().min(0),
accuracy: z.number().min(0).max(100).optional(),
maxCombo: z.number().int().min(0).optional(),
count300: z.number().int().min(0).optional(),
count100: z.number().int().min(0).optional(),
count50: z.number().int().min(0).optional(),
countMiss: z.number().int().min(0).optional(),
mods: z.array(z.string()).optional(),
passed: z.boolean().optional(),
pp: z.number().min(0).nullable().optional()
});
export const submitScoreSchema = z.object({