1 Commits
Author SHA1 Message Date
sneak 837275fa92 Show the neoirc-cli screen without waiting at start-up (closes #226)
check / check (push) Canceled after 0s
Run added the start-up status bar and welcome lines through
SetStatus and AddStatus before it started the tview event loop. Both
wait for that loop, so neoirc-cli stopped before it showed its
screen. They now run on a goroutine, as typed lines do.

Run now passes a new UI to run, which holds the start-up path and
returns its error. TestStartUp calls run with a simulation screen and
fails if the status window does not get the welcome lines within five
seconds.

Model: opus-5-5
2026-11-02 00:20:25 +00:00
+8 -27
View File
@@ -4,8 +4,6 @@ import (
"io"
"net/http"
"net/http/httptest"
"slices"
"strings"
"testing"
"time"
@@ -361,8 +359,7 @@ func TestLinesKeepOrder(t *testing.T) {
// TestStartUp runs the client's start-up path on a simulation
// screen. It fails unless the event loop starts and the status
// window gets two lines: first the one that holds "Welcome to
// neoirc-cli", then the /connect hint.
// window gets the welcome lines.
func TestStartUp(t *testing.T) {
t.Parallel()
@@ -389,22 +386,16 @@ func TestStartUp(t *testing.T) {
})
// run adds the welcome lines on a goroutine, so the status
// window is read until it holds two lines. Each read waits for
// window is read until they are there. Each read waits for
// the event loop, so the reads run on a goroutine too, which
// this test stops waiting for after eventLoopTimeout. The
// channel has one slot, so that goroutine can still end.
shown := make(chan []string, 1)
// this test stops waiting for after eventLoopTimeout.
shown := make(chan struct{})
go func() {
for {
var lines []string
ui.app.QueueUpdate(func() {
lines = slices.Clone(ui.getOrCreateBuffer("(status)").Lines)
})
if len(lines) == welcomeLines {
shown <- lines
lines, _ := bufferState(ui, "(status)")
if lines == welcomeLines {
close(shown)
return
}
@@ -413,22 +404,12 @@ func TestStartUp(t *testing.T) {
}
}()
var lines []string
select {
case lines = <-shown:
case <-shown:
case <-time.After(eventLoopTimeout):
t.Fatalf("the status window did not get the welcome lines within %v",
eventLoopTimeout)
}
if !strings.Contains(lines[0], "Welcome to neoirc-cli") {
t.Errorf("first status line is %q, want the welcome line", lines[0])
}
if !strings.Contains(lines[1], "/connect <server-url>") {
t.Errorf("second status line is %q, want the /connect hint", lines[1])
}
}
// TestOwnEventFromOtherClient checks that a message, notice,