@@ -36,6 +36,16 @@ describe('NIP-29 group handlers', () => {
3636 expect ( result . isOpen ) . toBe ( true )
3737 } )
3838
39+ it ( 'takes highest created_at from multiple metadata events' , async ( ) => {
40+ const events = [
41+ { kind : 39000 , pubkey : 'r' , created_at : 500 , tags : [ [ 'd' , 'g' ] , [ 'name' , 'Old' ] ] , content : '' , id : '1' , sig : 's' } ,
42+ { kind : 39000 , pubkey : 'r' , created_at : 1000 , tags : [ [ 'd' , 'g' ] , [ 'name' , 'New' ] ] , content : '' , id : '2' , sig : 's' } ,
43+ ]
44+ const pool = mockPool ( events )
45+ const result = await handleGroupInfo ( pool as any , 'npub1test' , { relay : 'wss://test' , groupId : 'g' } )
46+ expect ( result . name ) . toBe ( 'New' )
47+ } )
48+
3949 it ( 'returns minimal info when no metadata found' , async ( ) => {
4050 const pool = mockPool ( [ ] )
4151 const result = await handleGroupInfo ( pool as any , 'npub1test' , { relay : 'wss://test' , groupId : 'unknown' } )
@@ -100,6 +110,17 @@ describe('NIP-29 group handlers', () => {
100110 expect ( result [ 1 ] . role ) . toBe ( 'admin' )
101111 } )
102112
113+ it ( 'takes highest created_at from multiple member events' , async ( ) => {
114+ const events = [
115+ { kind : 39002 , pubkey : 'r' , created_at : 500 , tags : [ [ 'd' , 'g' ] , [ 'p' , 'old' ] ] , content : '' , id : '1' , sig : 's' } ,
116+ { kind : 39002 , pubkey : 'r' , created_at : 1000 , tags : [ [ 'd' , 'g' ] , [ 'p' , 'new' ] ] , content : '' , id : '2' , sig : 's' } ,
117+ ]
118+ const pool = mockPool ( events )
119+ const result = await handleGroupMembers ( pool as any , 'npub1test' , { groupId : 'g' } )
120+ expect ( result . length ) . toBe ( 1 )
121+ expect ( result [ 0 ] . pubkey ) . toBe ( 'new' )
122+ } )
123+
103124 it ( 'returns empty when no member list found' , async ( ) => {
104125 const pool = mockPool ( [ ] )
105126 const result = await handleGroupMembers ( pool as any , 'npub1test' , { groupId : 'empty' } )
0 commit comments