test(18.1-06): taglist and flat reorder unit matrices, partitioned flat smoke and admin specs (task 2)
- TestTaglistFieldValidate: both modes, trim, dedupe, empty, null, wrong shapes, customTags false, required; TestTaglistFieldHydrate: stored NULL and bad text as [] - TestReorderFlatNodes: parent 422, duplicate and zero id 422, missing or extra 409, no depth or cycle check; TestReorderFlatCompile checks the localized list schema - TestReorderFlatSmoke/partitioned: flat reorder within one partition on Postgres - vitest: script markup as text, Backspace, blur, paste, datalist, customTags, string mode; flat ArrowUp/ArrowDown and the before/after drop zones - export_test.go wrappers for the taglist save check, hydration and node check - check-phase18.1.sh requires the new names in the go, admin and postgres stages
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package cabana
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
"git.golem15.com/golem15/summercms/modules/party"
|
||||
"git.golem15.com/golem15/summercms/modules/phrasebook"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -68,3 +71,34 @@ func CheckMoneyType(model any, field FormField) error { return checkMoneyType(mo
|
||||
func ProjectRow(row any, controller pact.AdminController, cols []ListColumn) map[string]any {
|
||||
return projectRow(row, controller, cols)
|
||||
}
|
||||
|
||||
// CheckTaglistValues exposes the taglist save check (every field allowed)
|
||||
// to the external taglist tests: it rewrites body in place and returns the
|
||||
// *ValidationError of the refused values, or nil.
|
||||
func CheckTaglistValues(ctx context.Context, tr *phrasebook.Translator, fields []FormField, body map[string]any, create bool) error {
|
||||
return checkTaglistValues(ctx, tr, fields, body, nil, create)
|
||||
}
|
||||
|
||||
// HydrateTaglistFields exposes the record GET's taglist hydration to the
|
||||
// external taglist tests.
|
||||
func HydrateTaglistFields(fields []FormField, data map[string]any) {
|
||||
hydrateTaglistFields(fields, data)
|
||||
}
|
||||
|
||||
// CheckReorderNodes exposes the reorder save's node check to the external
|
||||
// reorder tests, over a reorder that is flat or a tree with maxDepth.
|
||||
func CheckReorderNodes(flat bool, maxDepth int, locked []AdminReorderNode, nodes []AdminReorderNodeInput, flatParent string) error {
|
||||
ro := &compiledReorder{flat: flat, maxDepth: maxDepth}
|
||||
if !flat {
|
||||
ro.parentColumn = "parent_id"
|
||||
}
|
||||
ro.sortColumn = "sort_order"
|
||||
return checkReorderNodes(ro, locked, nodes, flatParent)
|
||||
}
|
||||
|
||||
// IsReorderStale reports whether err is the reorder save's 409 (the
|
||||
// submitted node set differs from the stored one).
|
||||
func IsReorderStale(err error) bool {
|
||||
var stale reorderStale
|
||||
return errors.As(err, &stale)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user