test(14.2.1-04): add ML, markdown, resolver, and SPA test matrices

Prove nested ML writes, unsafe markdown rejection, request-locale isolation, and generated FormView types.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-06 14:02:49 +02:00
parent c7e2e4b4ed
commit 1bc6200dbd
5 changed files with 447 additions and 0 deletions

View File

@@ -75,6 +75,57 @@ func into[T any]() func(*json.Decoder) error {
// each real response into the Go type its annotation documents with unknown
// fields disallowed, and checks admin/openapi/admin.json names that type for
// the same path, method and status (D-15, D-16; Pitfall 8).
func TestMLOpenAPIConformance(t *testing.T) {
spec := conformSpec(t)
if got := spec.ref("/{vendor}/{plugin}/{controller}/schema/form", "get", "200"); got != "cabana.Envelope-cabana_FormView" {
t.Fatalf("form schema ref = %q", got)
}
_, file, _, ok := runtime.Caller(0)
if !ok {
t.Fatal("caller")
}
raw, err := os.ReadFile(filepath.Join(filepath.Dir(file), "..", "..", "admin", "openapi", "admin.json"))
if err != nil {
t.Fatal(err)
}
doc := string(raw)
for _, name := range []string{"cabana.FormField", "cabana.FormView"} {
if !strings.Contains(doc, `"`+name+`"`) {
t.Fatalf("admin.json missing %s", name)
}
}
schema, err := cabana.CompileForm("acme.demo", stubMLSchemaController{}, fstest.MapFS{
"controllers/widgets/config_form.yaml": {Data: []byte("name: posts\nform: ~/plugins/acme/demo/models/widget/fields.yaml\nmodelClass: Widget\n")},
"models/widget/fields.yaml": {Data: []byte(`fields:
title:
type: mltext
label: Title
excerpt:
type: markdown
label: Excerpt
body:
type: mlmarkdown
label: Body
`)},
})
if err != nil {
t.Fatal(err)
}
got := map[string]string{}
for _, field := range schema.Fields {
got[field.Name] = field.Type
}
if got["title"] != "mltext" || got["excerpt"] != "markdown" || got["body"] != "mlmarkdown" {
t.Fatalf("compiled types = %v", got)
}
}
type stubMLSchemaController struct{}
func (stubMLSchemaController) ID() string { return "acme.demo.widgets" }
func (stubMLSchemaController) ModelName() string { return "Widget" }
func (stubMLSchemaController) ConfigDir() string { return "controllers/widgets" }
func TestPhase10OpenAPIConformance(t *testing.T) {
env := newConformEnv(t)
spec := conformSpec(t)