feat(calendar): migrate to react-day-picker v9 and polish UI - Update classNames and CSS import (style.css) - Custom Dropdown via shadcn Select - Nav arrows aligned with caption (around) - Today highlight with cyan tone, weekdays in sentence case - Wider layout to avoid overflow; remove inner wrapper chore(tickets): make 'Patrimônio do computador (se houver)' optional - Backend hotfix to enforce optional + label on existing tenants - Hide required asterisk for this field in portal/new-ticket refactor(new-ticket): remove channel dropdown from admin/agent flow - Keep default channel as MANUAL feat(ux): simplify requester section and enlarge combobox trigger - Remove RequesterPreview redundancy; show company badge in trigger
76 lines
1.8 KiB
TypeScript
76 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
|
|
import { normalizeCustomFieldInputs } from "../src/lib/ticket-form-helpers"
|
|
import type { TicketFormFieldDefinition } from "../src/lib/ticket-form-types"
|
|
|
|
describe("ticket form helpers", () => {
|
|
const baseFields: TicketFormFieldDefinition[] = [
|
|
{
|
|
id: "field-nome",
|
|
key: "nome",
|
|
label: "Nome",
|
|
type: "text",
|
|
required: true,
|
|
description: "",
|
|
options: [],
|
|
},
|
|
{
|
|
id: "field-data",
|
|
key: "data",
|
|
label: "Data",
|
|
type: "date",
|
|
required: false,
|
|
description: "",
|
|
options: [],
|
|
},
|
|
{
|
|
id: "field-numero",
|
|
key: "numero",
|
|
label: "Número",
|
|
type: "number",
|
|
required: true,
|
|
description: "",
|
|
options: [],
|
|
},
|
|
{
|
|
id: "field-select",
|
|
key: "tipo",
|
|
label: "Tipo",
|
|
type: "select",
|
|
required: true,
|
|
description: "",
|
|
options: [
|
|
{ value: "nova", label: "Nova contratação" },
|
|
{ value: "substituicao", label: "Substituição" },
|
|
],
|
|
},
|
|
]
|
|
|
|
it("normalizes values for required fields", () => {
|
|
const result = normalizeCustomFieldInputs(baseFields, {
|
|
"field-nome": " Ana Silva ",
|
|
"field-numero": "123",
|
|
"field-select": "nova",
|
|
})
|
|
|
|
expect(result.ok).toBe(true)
|
|
if (result.ok) {
|
|
expect(result.payload).toEqual([
|
|
{ fieldId: "field-nome", value: "Ana Silva" },
|
|
{ fieldId: "field-numero", value: 123 },
|
|
{ fieldId: "field-select", value: "nova" },
|
|
])
|
|
}
|
|
})
|
|
|
|
it("fails when a required field is empty", () => {
|
|
const result = normalizeCustomFieldInputs(baseFields, {
|
|
"field-nome": " ",
|
|
})
|
|
|
|
expect(result.ok).toBe(false)
|
|
if (!result.ok) {
|
|
expect(result.message).toContain("Nome")
|
|
}
|
|
})
|
|
})
|