Pad/internal/editor/filename_test.go
Greg Pomerantz 2b7c9cd3eb Collapse editor top bar to one row (back + filename)
The cut/copy/paste icons were dead placeholders (no handlers);
clipboard actions live in the floating selection menu, so the second
icon row is removed. The bar goes from two rows at 52dp to one row at
32dp, giving the editor 20dp more height.

- filename_test.go now finds the label by type (back icon precedes it)
- menu tracking tests updated for the new editorY (reg.Y = 10+32)
- scroll_cursor e2e simulation updated to match
- On-device verified: back button works, floating menu places above
  with room and flips below on the first lines, handles unaffected.
2026-08-18 08:32:19 -04:00

65 lines
1.6 KiB
Go

package editor
import (
"testing"
"pad/internal/ui"
)
func TestEditorLayout_Filename(t *testing.T) {
// Setup: Reset state
TheState = NewState()
// Set a filename
expectedFilename := "test.txt"
TheState.Editor.Filename = expectedFilename
// Run layout
screenWidth := ui.Dp(400)
screenHeight := ui.Dp(800)
elements := EditorLayout(screenWidth, screenHeight, false)
// Find top bar (assuming it's the first container element)
topBar := elements[0].(ui.Container)
// Find the filename label in the top bar (the back icon precedes it).
var filenameLabel ui.Label
for _, c := range topBar.Children {
if l, ok := c.(ui.Label); ok {
filenameLabel = l
break
}
}
if filenameLabel.Text != expectedFilename {
t.Errorf("expected filename %q, got %q", expectedFilename, filenameLabel.Text)
}
}
func TestEditorLayout_DefaultFilename(t *testing.T) {
// Setup: Reset state
TheState = NewState()
// Filename is empty
TheState.Editor.Filename = ""
// Run layout
screenWidth := ui.Dp(400)
screenHeight := ui.Dp(800)
elements := EditorLayout(screenWidth, screenHeight, false)
// Find top bar (assuming it's the first container element)
topBar := elements[0].(ui.Container)
// Find the filename label in the top bar (the back icon precedes it).
var filenameLabel ui.Label
for _, c := range topBar.Children {
if l, ok := c.(ui.Label); ok {
filenameLabel = l
break
}
}
expectedDefault := "untitled.txt"
if filenameLabel.Text != expectedDefault {
t.Errorf("expected default filename %q, got %q", expectedDefault, filenameLabel.Text)
}
}