@@ -18,10 +18,11 @@ describe("Telegram location message hooks", () => {
1818 beforeEach ( ( ) => {
1919 hookRunner . hasHooks . mockClear ( ) ;
2020 hookRunner . runInboundClaim . mockClear ( ) ;
21- hookRunner . runMessageReceived . mockClear ( ) ;
21+ hookRunner . runMessageReceived . mockReset ( ) ;
22+ hookRunner . runMessageReceived . mockResolvedValue ( undefined ) ;
2223 } ) ;
2324
24- it ( "ignores non-location edits" , async ( ) => {
25+ it ( "ignores non-location edits" , ( ) => {
2526 const msg = {
2627 chat : { id : 1234 , type : "private" } ,
2728 message_id : 456 ,
@@ -31,7 +32,7 @@ describe("Telegram location message hooks", () => {
3132 text : "edited text" ,
3233 } as Message ;
3334
34- await emitTelegramLiveLocationMessageHook ( {
35+ emitTelegramLiveLocationMessageHook ( {
3536 accountId : "main" ,
3637 msg,
3738 updateId : 9002 ,
@@ -42,7 +43,7 @@ describe("Telegram location message hooks", () => {
4243 expect ( hookRunner . runMessageReceived ) . not . toHaveBeenCalled ( ) ;
4344 } ) ;
4445
45- it ( "emits edited live locations through the global message-received contract" , async ( ) => {
46+ it ( "emits edited live locations through the global message-received contract" , ( ) => {
4647 const msg = {
4748 chat : { id : 1234 , type : "private" } ,
4849 message_id : 456 ,
@@ -57,7 +58,7 @@ describe("Telegram location message hooks", () => {
5758 } ,
5859 } as Message ;
5960
60- await emitTelegramLiveLocationMessageHook ( {
61+ emitTelegramLiveLocationMessageHook ( {
6162 accountId : "main" ,
6263 msg,
6364 updateId : 9002 ,
@@ -98,7 +99,7 @@ describe("Telegram location message hooks", () => {
9899 expect ( hookRunner . runInboundClaim ) . not . toHaveBeenCalled ( ) ;
99100 } ) ;
100101
101- it ( "emits the terminal edit when live-location sharing stops" , async ( ) => {
102+ it ( "emits the terminal edit when live-location sharing stops" , ( ) => {
102103 const msg = {
103104 chat : { id : 1234 , type : "private" } ,
104105 message_id : 456 ,
@@ -108,7 +109,7 @@ describe("Telegram location message hooks", () => {
108109 location : { latitude : 43.8376 , longitude : 18.4534 } ,
109110 } as Message ;
110111
111- await emitTelegramLiveLocationMessageHook ( {
112+ emitTelegramLiveLocationMessageHook ( {
112113 accountId : "main" ,
113114 msg,
114115 updateId : 9003 ,
@@ -125,4 +126,56 @@ describe("Telegram location message hooks", () => {
125126 ) ;
126127 expect ( hookRunner . runInboundClaim ) . not . toHaveBeenCalled ( ) ;
127128 } ) ;
129+
130+ it ( "emits edited channel-post live locations with their provider update kind" , ( ) => {
131+ const msg = {
132+ chat : { id : - 1001234 , type : "supergroup" , title : "Travel updates" } ,
133+ message_id : 456 ,
134+ date : 1_786_094_460 ,
135+ edit_date : 1_786_094_580 ,
136+ from : { id : 789 , is_bot : true , first_name : "Travel updates" } ,
137+ location : { latitude : 43.8376 , longitude : 18.4534 , live_period : 900 } ,
138+ } as Message ;
139+
140+ emitTelegramLiveLocationMessageHook ( {
141+ accountId : "main" ,
142+ msg,
143+ updateId : 9004 ,
144+ updateKind : "edited_channel_post" ,
145+ isForum : false ,
146+ } ) ;
147+
148+ expect ( hookRunner . runMessageReceived ) . toHaveBeenCalledWith (
149+ expect . objectContaining ( {
150+ providerUpdate : expect . objectContaining ( {
151+ id : "9004" ,
152+ kind : "edited_channel_post" ,
153+ } ) ,
154+ } ) ,
155+ expect . any ( Object ) ,
156+ ) ;
157+ } ) ;
158+
159+ it ( "does not wait for plugin observers on the Telegram inbound path" , ( ) => {
160+ hookRunner . runMessageReceived . mockReturnValueOnce ( new Promise ( ( ) => { } ) ) ;
161+ const msg = {
162+ chat : { id : 1234 , type : "private" } ,
163+ message_id : 456 ,
164+ date : 1_786_094_460 ,
165+ edit_date : 1_786_094_520 ,
166+ from : { id : 789 , is_bot : false , first_name : "Pat" } ,
167+ location : { latitude : 43.8376 , longitude : 18.4534 , live_period : 900 } ,
168+ } as Message ;
169+
170+ expect (
171+ emitTelegramLiveLocationMessageHook ( {
172+ accountId : "main" ,
173+ msg,
174+ updateId : 9005 ,
175+ updateKind : "edited_message" ,
176+ isForum : false ,
177+ } ) ,
178+ ) . toBeUndefined ( ) ;
179+ expect ( hookRunner . runMessageReceived ) . toHaveBeenCalledTimes ( 1 ) ;
180+ } ) ;
128181} ) ;
0 commit comments