okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
226adf3
main
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 ) { 18profile := providerRoute (t ,echoReply ) 19d := driveTUI (t ,nil ) 20const notice = "provider selected for new sessions" 21d .App .AddNotice (notice ) 22// The created session's stream would block a synchronous walk, so only the 23// create command runs. 24d .Update (d .Update (tui.ChatNewSessionMsg {})()) 25if d .App .ActiveSession == nil || ! strings .Contains (d .View (),notice ) { 26t .Fatalf ("notice did not follow the real new session:\n%s" ,d .View ()) 27 } 28 29d .connected () 30// Enter batches the send with the spinner; only the send reaches the 31// daemon. 32d .App .Chat .TextArea .SetValue ("clear the notice" ) 33batch ,_ := d .Update (tea.KeyPressMsg {Code :tea .KeyEnter })().(tea.BatchMsg ) 34for _ ,command := range batch { 35if msg ,ok := command ().(tui.ChatTurnSentMsg );ok { 36d .Update (msg ) 37 } 38 } 39if len (d .App .Chat .Notices )!= 0 || strings .Contains (d .View (),notice ) { 40t .Fatalf ("notice survived the submitted turn %v:\n%s" ,d .App .Chat .Notices ,d .View ()) 41 } 42waitIdle (t ,d .App .ActiveSession .ID ,profile ,1 ) 43}