feat(office): users admin UI, table rendering, and user save fixes
Add Users list/detail with ACL toggles and library people update/status APIs. Fix project table layout and ANSI-safe cell rendering, and decode array responses from people/status so saves no longer fail on JSON unmarshal. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/eslider/go-onlyoffice/cmd/office/model"
|
||||
)
|
||||
|
||||
func TestUserFormViewShowsIDAndACL(t *testing.T) {
|
||||
f := NewEntityFormForTest()
|
||||
f.SetSize(60, 30)
|
||||
f.Load(model.KindUser, "42", model.FormFields{
|
||||
HasUserEdit: true,
|
||||
UserEnabled: true,
|
||||
UserACL: model.UserACLState{
|
||||
FullAccess: false,
|
||||
Modules: map[string]bool{
|
||||
"documents": true,
|
||||
},
|
||||
},
|
||||
GroupsText: "Admins, Devs",
|
||||
})
|
||||
view := f.View()
|
||||
for _, want := range []string{"User 42", "ID", "42", "Account", "Password", "Full access", "Documents", "Groups", "Admins"} {
|
||||
if !strings.Contains(view, want) {
|
||||
t.Fatalf("view missing %q:\n%s", want, view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserFormFieldCount(t *testing.T) {
|
||||
f := NewEntityFormForTest()
|
||||
f.Load(model.KindUser, "1", model.FormFields{HasUserEdit: true, UserACL: model.UserACLFromRaw(nil)})
|
||||
if got := f.FieldCount(); got != 2+len(model.UserACLDefs) {
|
||||
t.Fatalf("field count=%d want %d", got, len(model.UserACLDefs)+2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLayoutUserTableEmailAbsorbsWidth(t *testing.T) {
|
||||
cols := model.BuildColumns(model.SubjectUsers, nil)
|
||||
lay := layoutUserTable(cols, 100)
|
||||
sum := 0
|
||||
emailW := 0
|
||||
for _, i := range lay.indices {
|
||||
sum += lay.widths[i]
|
||||
if cols[i].Key == "email" {
|
||||
emailW = lay.widths[i]
|
||||
}
|
||||
}
|
||||
if sum != 100 {
|
||||
t.Fatalf("sum=%d want 100", sum)
|
||||
}
|
||||
if emailW < 30 {
|
||||
t.Fatalf("email width=%d should absorb extra space", emailW)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user