@@ -16,6 +16,22 @@ describe("channels:history command", () => {
1616 timestamp : 1700000000000 ,
1717 clientId : "client-1" ,
1818 connectionId : "conn-1" ,
19+ version : {
20+ serial : "v1-serial" ,
21+ timestamp : 1700000000000 ,
22+ clientId : "updater-1" ,
23+ } ,
24+ annotations : {
25+ summary : {
26+ "reaction:distinct.v1" : {
27+ "👍" : {
28+ total : 3 ,
29+ clientIds : [ "c1" , "c2" , "c3" ] ,
30+ clipped : false ,
31+ } ,
32+ } ,
33+ } ,
34+ } ,
1935 } ,
2036 {
2137 id : "msg-2" ,
@@ -94,6 +110,27 @@ describe("channels:history command", () => {
94110 expect ( stdout ) . toContain ( "msg-1" ) ;
95111 } ) ;
96112
113+ it ( "should display version fields when present" , async ( ) => {
114+ const { stdout } = await runCommand (
115+ [ "channels:history" , "test-channel" ] ,
116+ import . meta. url ,
117+ ) ;
118+
119+ expect ( stdout ) . toContain ( "Version:" ) ;
120+ expect ( stdout ) . toContain ( "v1-serial" ) ;
121+ expect ( stdout ) . toContain ( "updater-1" ) ;
122+ } ) ;
123+
124+ it ( "should display annotations summary when present" , async ( ) => {
125+ const { stdout } = await runCommand (
126+ [ "channels:history" , "test-channel" ] ,
127+ import . meta. url ,
128+ ) ;
129+
130+ expect ( stdout ) . toContain ( "Annotations:" ) ;
131+ expect ( stdout ) . toContain ( "reaction:distinct.v1:" ) ;
132+ } ) ;
133+
97134 it ( "should handle empty history" , async ( ) => {
98135 const mock = getMockAblyRest ( ) ;
99136 const channel = mock . channels . _getChannel ( "test-channel" ) ;
@@ -124,6 +161,45 @@ describe("channels:history command", () => {
124161 expect ( result [ 0 ] . data ) . toEqual ( { text : "Hello world" } ) ;
125162 } ) ;
126163
164+ it ( "should include version in JSON output when present" , async ( ) => {
165+ const { stdout } = await runCommand (
166+ [ "channels:history" , "test-channel" , "--json" ] ,
167+ import . meta. url ,
168+ ) ;
169+
170+ const result = JSON . parse ( stdout ) ;
171+ expect ( result [ 0 ] ) . toHaveProperty ( "version" ) ;
172+ expect ( result [ 0 ] . version ) . toEqual ( {
173+ serial : "v1-serial" ,
174+ timestamp : 1700000000000 ,
175+ clientId : "updater-1" ,
176+ } ) ;
177+ // Second message has no version
178+ expect ( result [ 1 ] ) . not . toHaveProperty ( "version" ) ;
179+ } ) ;
180+
181+ it ( "should include annotations in JSON output when present" , async ( ) => {
182+ const { stdout } = await runCommand (
183+ [ "channels:history" , "test-channel" , "--json" ] ,
184+ import . meta. url ,
185+ ) ;
186+
187+ const result = JSON . parse ( stdout ) ;
188+ expect ( result [ 0 ] ) . toHaveProperty ( "annotations" ) ;
189+ expect ( result [ 0 ] . annotations . summary ) . toHaveProperty (
190+ "reaction:distinct.v1" ,
191+ ) ;
192+ expect (
193+ result [ 0 ] . annotations . summary [ "reaction:distinct.v1" ] [ "👍" ] ,
194+ ) . toEqual ( {
195+ total : 3 ,
196+ clientIds : [ "c1" , "c2" , "c3" ] ,
197+ clipped : false ,
198+ } ) ;
199+ // Second message has no annotations
200+ expect ( result [ 1 ] ) . not . toHaveProperty ( "annotations" ) ;
201+ } ) ;
202+
127203 it ( "should respect --limit flag" , async ( ) => {
128204 const mock = getMockAblyRest ( ) ;
129205 const channel = mock . channels . _getChannel ( "test-channel" ) ;
0 commit comments