@@ -65,6 +65,41 @@ describe("unread replies in the conversation list", () => {
6565 expect ( row ( "Scout" ) . getAttribute ( "aria-label" ) ) . toBe ( "Scout, Idle, unread" ) ;
6666 } ) ;
6767
68+ test ( "what the daemon says was read stays read when the app forgot what it saw" , async ( ) => {
69+ const fake = new FakeBotloft ( ) ;
70+ const crew = fake . addCrew ( "Ops" ) ;
71+ const scout = fake . addBot ( crew . id , "Scout" ) ;
72+ const writer = fake . addBot ( crew . id , "Writer" ) ;
73+ fake . setBotState ( scout . id , "idle" ) ;
74+ fake . setBotState ( writer . id , "idle" ) ;
75+ // Both replied at 5000; the owner read only Writer's, and the app's own
76+ // storage (cleared in beforeEach) knows nothing of it.
77+ fake . bot ( scout . id ) . lastReplyAt = 5000 ;
78+ fake . bot ( writer . id ) . lastReplyAt = 5000 ;
79+ fake . bot ( writer . id ) . readThrough = 5000 ;
80+ renderApp ( fake ) ;
81+ await crewOpened ( "Ops" ) ;
82+ expect ( row ( "Scout" ) . getAttribute ( "aria-label" ) ) . toBe ( "Scout, Idle, unread" ) ;
83+ expect ( row ( "Writer" ) . getAttribute ( "aria-label" ) ) . toBe ( "Writer, Idle" ) ;
84+ } ) ;
85+
86+ test ( "seeing a chat tells the daemon, which keeps it" , async ( ) => {
87+ const fake = new FakeBotloft ( ) ;
88+ const crew = fake . addCrew ( "Ops" ) ;
89+ const scout = fake . addBot ( crew . id , "Scout" ) ;
90+ fake . setBotState ( scout . id , "idle" ) ;
91+ renderApp ( fake ) ;
92+ await crewOpened ( "Ops" ) ;
93+ act ( ( ) => {
94+ fake . chat . reply ( scout . id , "Found three sources." ) ;
95+ } ) ;
96+ openBot ( "Scout" ) ;
97+ await screen . findByRole ( "list" , { name : "Messages" } ) ;
98+ expect (
99+ fake . calls . filter ( ( call ) => call . method === "chat.read" ) . map ( ( call ) => call . params ) ,
100+ ) . toContainEqual ( { botId : scout . id } ) ;
101+ } ) ;
102+
68103 test ( "replies from before the first start with unread marks count as seen" , async ( ) => {
69104 localStorage . removeItem ( "botloft.seenSince" ) ;
70105 const fake = new FakeBotloft ( ) ;
0 commit comments