okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

Aly Raffauftest(cli): declare Unix requirements and check scanner errors226adf3

main
1.3 KiB43 linesraw
1//go:build unix
2
3// Notices cross the session boundary and clear on a real submitted turn. A
4// unit test with fabricated lifecycle messages cannot prove either daemon
5// command.
6package e2e
7
8import (
9	"strings"
10	"testing"
11
12	"albedo/cli/internal/tui"
13
14	tea "charm.land/bubbletea/v2"
15)
16
17func TestTUINoticeMovesToANewSessionAndClearsOnSend(t *testing.T) {
18	profile := providerRoute(t, echoReply)
19	d := driveTUI(t, nil)
20	const notice = "provider selected for new sessions"
21	d.App.AddNotice(notice)
22	// The created session's stream would block a synchronous walk, so only the
23	// create command runs.
24	d.Update(d.Update(tui.ChatNewSessionMsg{})())
25	if d.App.ActiveSession == nil || !strings.Contains(d.View(), notice) {
26		t.Fatalf("notice did not follow the real new session:\n%s", d.View())
27	}
28
29	d.connected()
30	// Enter batches the send with the spinner; only the send reaches the
31	// daemon.
32	d.App.Chat.TextArea.SetValue("clear the notice")
33	batch, _ := d.Update(tea.KeyPressMsg{Code: tea.KeyEnter})().(tea.BatchMsg)
34	for _, command := range batch {
35		if msg, ok := command().(tui.ChatTurnSentMsg); ok {
36			d.Update(msg)
37		}
38	}
39	if len(d.App.Chat.Notices) != 0 || strings.Contains(d.View(), notice) {
40		t.Fatalf("notice survived the submitted turn %v:\n%s", d.App.Chat.Notices, d.View())
41	}
42	waitIdle(t, d.App.ActiveSession.ID, profile, 1)
43}