/* @vitest-environment jsdom */

import { render, screen } from "@testing-library/react"
import { describe, expect, it, vi } from "vitest"

import { CreatePageForm } from "./create-page-form"

describe("CreatePageForm", () => {
  it("renders required fields and draft default status", () => {
    render(<CreatePageForm action={vi.fn()} />)

    expect((screen.getByLabelText("Title") as HTMLInputElement).name).toBe("title")
    expect((screen.getByLabelText("Slug") as HTMLInputElement).name).toBe("slug")
    expect((screen.getByLabelText("Content") as HTMLTextAreaElement).name).toBe("content")

    const status = screen.getByLabelText("Status") as HTMLSelectElement
    expect(status.value).toBe("draft")

    expect(screen.getByRole("button", { name: "Create page" })).not.toBeNull()
  })
})
