Pad/internal/editor/integration_test.go
Greg Pomerantz 03fb63863c Fix test build after NewLogic signature change; add development plan draft
NewLogic now takes (FileSystem, path, openfunc); update the e2e harness
and editor tests accordingly. The harness uses a no-op openfunc, matching
impl_other.go (the real app's OpenFile is a platform bridge, no-op off
Android).

Also adds doc/development_plan.md (draft, with corrections note re: the
live repo state).
2026-08-15 22:18:04 -04:00

49 lines
986 B
Go

package editor
import (
"testing"
"time"
"pad/internal/io/pool/mock"
)
func TestOpenFileIntegration(t *testing.T) {
// 1. Setup Logic
mockFS := mock.NewFileSystem()
filename := "/README.md"
content := "Hello World"
mockFS.AddFile(filename, []byte(content), time.Now())
l := NewLogic(mockFS, "/", func(string) {})
go l.Run()
defer l.Done()
// Drain frameChan to prevent deadlocks
go func() {
for range l.FrameChan() {
}
}()
TheState = l.state // Initialize global state
// 2. Open File
// OpenFile dispatches the task to openFileChan, which Run() will consume
OpenFile(filename)
// 3. Process the Result
// We wait for the state to update, which happens when ReadChunkTask completes
success := false
for i := 0; i < 20; i++ {
if l.state.Editor.GetBuffer() == content {
success = true
break
}
time.Sleep(100 * time.Millisecond)
}
// 4. Assert
if !success {
t.Errorf("Expected content %q, got %q", content, l.state.Editor.Buffer)
}
}