From 4af4a6552772f0fde93eef50b0d8c1dee9750ef7 Mon Sep 17 00:00:00 2001 From: yohlo Date: Tue, 25 Aug 2026 21:54:50 -0700 Subject: [PATCH] bug --- src/features/matches/types.test.ts | 9 +++++++++ src/features/matches/types.ts | 18 +++++++++--------- src/features/tournaments/types.test.ts | 15 +++++++++++++++ src/features/tournaments/types.ts | 2 +- 4 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 src/features/matches/types.test.ts create mode 100644 src/features/tournaments/types.test.ts diff --git a/src/features/matches/types.test.ts b/src/features/matches/types.test.ts new file mode 100644 index 0000000..245f506 --- /dev/null +++ b/src/features/matches/types.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from "vitest"; +import { matchInputSchema } from "./types"; + +describe("matchInputSchema.partial()", () => { + it("does not inject keys the caller did not send", () => { + const parsed = matchInputSchema.partial().parse({ home_cups: 7 }); + expect(parsed).toEqual({ home_cups: 7 }); + }); +}); diff --git a/src/features/matches/types.ts b/src/features/matches/types.ts index 76bac52..ae31612 100644 --- a/src/features/matches/types.ts +++ b/src/features/matches/types.ts @@ -42,20 +42,20 @@ export interface Match { export const matchInputSchema = z.object({ order: z.number().int().min(1).optional(), lid: z.number().int().min(1), - reset: z.boolean().optional().default(false), + reset: z.boolean().optional(), round: z.number().int().min(1), - home_cups: z.number().int().min(0).optional().default(0), - away_cups: z.number().int().min(0).optional().default(0), - ot_count: z.number().int().min(0).optional().default(0), + home_cups: z.number().int().min(0).optional(), + away_cups: z.number().int().min(0).optional(), + ot_count: z.number().int().min(0).optional(), start_time: z.iso.datetime().optional(), end_time: z.iso.datetime().optional(), - bye: z.boolean().optional().default(false), + bye: z.boolean().optional(), home_from_lid: z.number().int().min(1).optional(), away_from_lid: z.number().int().min(1).optional(), - home_from_loser: z.boolean().optional().default(false), - away_from_loser: z.boolean().optional().default(false), - is_losers_bracket: z.boolean().optional().default(false), - status: z.enum(["tbd", "ready", "started", "ended"]).optional().default("tbd"), + home_from_loser: z.boolean().optional(), + away_from_loser: z.boolean().optional(), + is_losers_bracket: z.boolean().optional(), + status: z.enum(["tbd", "ready", "started", "ended"]).optional(), tournament: z.string().min(1), home: z.string().min(1).nullable().optional(), away: z.string().min(1).nullable().optional(), diff --git a/src/features/tournaments/types.test.ts b/src/features/tournaments/types.test.ts new file mode 100644 index 0000000..e7f42cd --- /dev/null +++ b/src/features/tournaments/types.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from "vitest"; +import { tournamentInputSchema } from "./types"; + +describe("tournamentInputSchema.partial()", () => { + it("does not inject keys the caller did not send", () => { + const parsed = tournamentInputSchema.partial().parse({ rules: "

rules

" }); + expect(parsed).toEqual({ rules: "

rules

" }); + }); + + it("passes an explicit regional flag through unchanged", () => { + expect(tournamentInputSchema.partial().parse({ regional: true })).toEqual({ + regional: true, + }); + }); +}); diff --git a/src/features/tournaments/types.ts b/src/features/tournaments/types.ts index 435a99b..3fbe025 100644 --- a/src/features/tournaments/types.ts +++ b/src/features/tournaments/types.ts @@ -98,7 +98,7 @@ export const tournamentInputSchema = z.object({ enroll_time: z.string(), start_time: z.string(), end_time: z.string().optional(), - regional: z.boolean().optional().default(false), + regional: z.boolean().optional(), format: z.enum(["single_elim", "double_elim", "groups", "swiss", "swiss_bracket", "round_robin"]).optional(), phase: z.enum(["seeding", "group_stage", "knockout", "completed"]).optional(), group_config: z.object({