test(admin): cover pages and navigation form components

This commit is contained in:
2026-02-12 20:48:51 +01:00
parent ec4f85e1d0
commit 749fb80083
9 changed files with 295 additions and 184 deletions

View File

@@ -0,0 +1,32 @@
/* @vitest-environment jsdom */
import { render, screen } from "@testing-library/react"
import { describe, expect, it, vi } from "vitest"
import { CreateNavigationItemForm } from "./create-navigation-item-form"
describe("CreateNavigationItemForm", () => {
it("renders menu/page options and defaults", () => {
render(
<CreateNavigationItemForm
action={vi.fn()}
menus={[{ id: "menu-1", name: "Primary", location: "header" }]}
pages={[{ id: "page-1", title: "Home", slug: "home" }]}
/>,
)
const menu = screen.getByLabelText("Menu") as HTMLSelectElement
expect(menu.options.length).toBe(1)
expect(menu.value).toBe("menu-1")
const page = screen.getByLabelText("Linked page") as HTMLSelectElement
expect(page.options.length).toBe(2)
expect(page.options[0]?.value).toBe("")
const sortOrder = screen.getByLabelText("Sort order") as HTMLInputElement
expect(sortOrder.value).toBe("0")
const visible = screen.getByLabelText("Visible") as HTMLInputElement
expect(visible.checked).toBe(true)
})
})