feat(cabana): accept preset on mltext fields

- compilePresetKey admits a text or mltext target
- checkPresets admits a text or mltext source
- TestPresetML pins every text/mltext pairing and the refusals
This commit is contained in:
Jakub Zych
2026-10-06 21:09:48 +02:00
parent 7e2b1a909b
commit 7afad732c7
4 changed files with 193 additions and 13 deletions

View File

@@ -154,11 +154,11 @@ func TestPhase121BootErrors(t *testing.T) {
{name: "an unknown preset key", files: map[string]string{rosterFieldsFile: rosterFields(t, " preset: name\n", " preset:\n field: name\n prefix: x\n")},
want: "preset: unknown field prefix", file: rosterFieldsFile},
{name: "preset on a field that is not text", files: map[string]string{rosterFieldsFile: rosterFields(t, " type: checkbox\n default: true\n", " type: checkbox\n default: true\n preset: name\n")},
want: "preset is only valid on type: text", file: rosterFieldsFile},
want: "preset is only valid on type: text or mltext", file: rosterFieldsFile},
{name: "preset from an unknown field", files: map[string]string{rosterFieldsFile: rosterFields(t, " preset: name\n", " preset: title\n")},
want: "field slug: preset field title is not a field of this form", file: rosterFieldsFile},
{name: "preset from a field that is not text", files: map[string]string{rosterFieldsFile: rosterFields(t, " preset: name\n", " preset: notify\n")},
want: "field slug: preset field notify must be a text field", file: rosterFieldsFile},
want: "field slug: preset field notify must be a text or mltext field", file: rosterFieldsFile},
{name: "preset from the field itself", files: map[string]string{rosterFieldsFile: rosterFields(t, " preset: name\n", " preset: slug\n")},
want: "field slug: preset names the field itself", file: rosterFieldsFile},
// permissioneditor (D-16).