feat(office): table detail panes and Alt+1/2/3 layout toggles
Add spreadsheet-style list, split detail pane with forms and document preview, and Alt+1/2/3 to show/hide panes with even width distribution. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package model
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBuildProjectColumns(t *testing.T) {
|
||||
items := []Item{{
|
||||
ID: "1", Title: "Alpha", Kind: KindProject,
|
||||
Raw: map[string]any{
|
||||
"taskCount": 3, "taskCountTotal": 5,
|
||||
"documentsCount": 2, "participantCount": 4,
|
||||
},
|
||||
}}
|
||||
cols := BuildColumns(SubjectProjects, items)
|
||||
want := []string{"_sel", "id", "title", "tasks", "documents", "users"}
|
||||
if len(cols) != len(want) {
|
||||
t.Fatalf("got %d columns, want %d", len(cols), len(want))
|
||||
}
|
||||
for i, key := range want {
|
||||
if cols[i].Key != key {
|
||||
t.Fatalf("col[%d]=%q want %q", i, cols[i].Key, key)
|
||||
}
|
||||
}
|
||||
for _, c := range cols {
|
||||
if c.Key == "status" || c.Key == "subtitle" {
|
||||
t.Fatalf("unexpected column %q", c.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatProjectTasksOpenClosed(t *testing.T) {
|
||||
raw := map[string]any{"taskCount": 3, "taskCountTotal": 8}
|
||||
if got := formatProjectTasks(raw); got != "3/5" {
|
||||
t.Fatalf("got %q want 3/5", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCellTextProjectDocumentsUsers(t *testing.T) {
|
||||
it := Item{Raw: map[string]any{"documentsCount": 7, "participantCount": 2}}
|
||||
if got := CellText(it, "documents"); got != "7" {
|
||||
t.Fatalf("documents: %q", got)
|
||||
}
|
||||
if got := CellText(it, "users"); got != "2" {
|
||||
t.Fatalf("users: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildColumnsIncludesSelectionAndCoreFields(t *testing.T) {
|
||||
items := []Item{
|
||||
{ID: "1", Title: "Alpha", Kind: KindTask, Raw: map[string]any{"status": "Open"}},
|
||||
}
|
||||
cols := BuildColumns(SubjectTasks, items)
|
||||
if cols[0].Key != "_sel" {
|
||||
t.Fatalf("first column should be selection, got %q", cols[0].Key)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user