Default added VoD games to Splat Zones

This commit is contained in:
Kalle
2026-09-29 17:58:13 +03:00
parent 6b2809f32d
commit 24bccdcd07
4 changed files with 24 additions and 2 deletions

View File

@@ -177,6 +177,19 @@ describe("VodForm", () => {
expect(fieldsets.length).toBe(2);
});
test("added match defaults to Splat Zones", async () => {
const screen = await renderForm();
const addButton = screen.getByRole("button", { name: "Add" });
await userEvent.click(addButton.element());
const addedFieldset = screen.container.querySelectorAll("fieldset")[1];
const checkedMode = addedFieldset.querySelector<HTMLInputElement>(
'input[type="radio"]:checked',
);
expect(checkedMode?.value).toBe("SZ");
});
test("can remove matches when more than 1", async () => {
const screen = await renderForm({
defaultValues: {

View File

@@ -123,6 +123,7 @@ const matchFieldsetSchema = v.object({
label: `modes.${mode}` as const,
value: mode,
})),
initialValue: "SZ",
}),
stageId: stageSelect({ label: "labels.vodStage" }),
weapon: weaponSelectOptional({ label: "labels.vodWeapon" }),

View File

@@ -565,7 +565,10 @@ export function radioGroup<V extends string>(
Omit<FormFieldInputGroup<"radio-group", V>, "type" | "initialValue">,
V
>
>,
> & {
/** Value selected when the form has no default value for the field. Defaults to the first item. */
initialValue?: V;
},
): v.GenericSchema<ItemValue<V>, ItemValue<V>> {
return register(itemsSchema(args.items), {
...args,
@@ -573,7 +576,7 @@ export function radioGroup<V extends string>(
bottomText: prefixKey(args.bottomText),
items: prefixItems(args.items),
type: "radio-group",
initialValue: args.items[0].value,
initialValue: args.initialValue ?? args.items[0].value,
});
}

View File

@@ -0,0 +1,5 @@
---
navItem: vods
type: bug
---
Games added to a VoD now default to Splat Zones like the first game