okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
4e62e9e
main
1// The daemon e2e checks rendered views for leaked row marks. These tests also 2// check byte-for-byte preservation of terminal sequences and internal hit targets. 3package tui 4 5import ( 6"strings" 7"testing" 8 9"albedo/cli/internal/daemon" 10"github.com/charmbracelet/x/ansi" 11) 12 13func TestAppViewKeepsRowMarksInternal (t * testing.T ) { 14chat := newTestChatModel (t ,& daemon.Session {ID :"s" }) 15chat .SetSize (80 ,24 ) 16chat .appendSettledEntry (HistoryEntry {Kind :EntryUser ,Text :"hi" ,Timestamp :1 }) 17chat .appendSettledEntry (HistoryEntry {Kind :EntryAssistant ,Text :"a reply to copy" ,Timestamp :2 }) 18chat .appendSettledEntry (HistoryEntry {Kind :EntryTurnEnd ,Mood :moodDone ,Timestamp :3 }) 19chat .refreshViewportContent () 20app := & AppModel {State :AppStateChat ,Chat :chat } 21internal := app .content () 22if ! strings .Contains (internal ,markChrome ) { 23t .Fatal ("fixture has no row marks" ) 24 } 25view := app .View ().Content 26if strings .Contains (view ,"\x1b_albedo:" ) { 27t .Fatalf ("private row marks reached the terminal: %q" ,view ) 28 } 29if ansi .Strip (view )!= ansi .Strip (internal ) { 30t .Fatal ("removing row marks changed visible content" ) 31 } 32if app .content ()!= internal { 33t .Fatal ("drawing removed the internal selection and click metadata" ) 34 } 35} 36 37func TestPrivateRowMarksPreserveTerminalSequences (t * testing.T ) { 38terminal := "\x1b[31mred\x1b[0m" + 39"\x1b]8;;https://example.com\x1b\\link\x1b]8;;\x1b\\" + 40"\x1b_Ga=T;AAAA\x1b\\" 41for _ ,mark := range []string { 42markChrome ,markWrap ,markSplit , 43 (rowAction {verbCopy ,"1-ab" }).mark (), 44 (rowAction {verbOpen ,"1-ab" }).mark (), 45 (rowAction {verbMore ,"1-ab" }).mark (), 46 } { 47if got := privateRowMarks .ReplaceAllString (mark + terminal + mark ,"" );got != terminal { 48t .Fatalf ("mark %q: changed terminal sequences: %q" ,mark ,got ) 49 } 50 } 51}