agent-messenger 2.10.1 → 2.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/package.json +1 -1
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/teams/token-extractor.js +9 -2
- package/dist/src/platforms/teams/token-extractor.js.map +1 -1
- package/dist/src/shared/chromium/decryptor.d.ts +6 -0
- package/dist/src/shared/chromium/decryptor.d.ts.map +1 -1
- package/dist/src/shared/chromium/decryptor.js +26 -6
- package/dist/src/shared/chromium/decryptor.js.map +1 -1
- package/e2e/channeltalk.e2e.test.ts +13 -13
- package/e2e/channeltalkbot.e2e.test.ts +13 -13
- package/e2e/discord.e2e.test.ts +24 -24
- package/e2e/discordbot.e2e.test.ts +16 -16
- package/e2e/instagram.e2e.test.ts +10 -10
- package/e2e/kakaotalk.e2e.test.ts +7 -7
- package/e2e/line.e2e.test.ts +8 -8
- package/e2e/slack.e2e.test.ts +34 -34
- package/e2e/slackbot.e2e.test.ts +14 -14
- package/e2e/teams.e2e.test.ts +23 -23
- package/e2e/telegram.e2e.test.ts +8 -8
- package/e2e/webex.e2e.test.ts +14 -14
- package/e2e/whatsapp.e2e.test.ts +8 -8
- package/e2e/whatsappbot.e2e.test.ts +6 -6
- package/package.json +1 -1
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +1 -1
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +1 -1
- package/skills/agent-wechatbot/SKILL.md +1 -1
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/platforms/channeltalk/client.test.ts +26 -26
- package/src/platforms/channeltalk/commands/auth.test.ts +16 -16
- package/src/platforms/channeltalk/commands/bot.test.ts +2 -2
- package/src/platforms/channeltalk/commands/chat.test.ts +3 -3
- package/src/platforms/channeltalk/commands/group.test.ts +4 -4
- package/src/platforms/channeltalk/commands/manager.test.ts +2 -2
- package/src/platforms/channeltalk/commands/message.test.ts +17 -17
- package/src/platforms/channeltalk/commands/snapshot.test.ts +7 -7
- package/src/platforms/channeltalk/commands/whoami.test.ts +3 -3
- package/src/platforms/channeltalk/credential-manager.test.ts +18 -18
- package/src/platforms/channeltalk/ensure-auth.test.ts +5 -5
- package/src/platforms/channeltalk/index.test.ts +23 -23
- package/src/platforms/channeltalk/token-extractor.test.ts +21 -21
- package/src/platforms/channeltalk/types.test.ts +12 -12
- package/src/platforms/channeltalkbot/client.test.ts +14 -14
- package/src/platforms/channeltalkbot/commands/auth.test.ts +16 -16
- package/src/platforms/channeltalkbot/commands/bot.test.ts +6 -6
- package/src/platforms/channeltalkbot/commands/chat.test.ts +9 -9
- package/src/platforms/channeltalkbot/commands/group.test.ts +6 -6
- package/src/platforms/channeltalkbot/commands/manager.test.ts +3 -3
- package/src/platforms/channeltalkbot/commands/message.test.ts +10 -10
- package/src/platforms/channeltalkbot/commands/snapshot.test.ts +7 -7
- package/src/platforms/channeltalkbot/commands/whoami.test.ts +4 -4
- package/src/platforms/channeltalkbot/credential-manager.test.ts +27 -27
- package/src/platforms/channeltalkbot/index.test.ts +15 -15
- package/src/platforms/discord/client.test.ts +28 -28
- package/src/platforms/discord/commands/auth.test.ts +7 -7
- package/src/platforms/discord/commands/channel.test.ts +7 -7
- package/src/platforms/discord/commands/dm.test.ts +4 -4
- package/src/platforms/discord/commands/file.test.ts +4 -4
- package/src/platforms/discord/commands/friend.test.ts +6 -6
- package/src/platforms/discord/commands/member.test.ts +5 -5
- package/src/platforms/discord/commands/mention.test.ts +5 -5
- package/src/platforms/discord/commands/message.test.ts +9 -9
- package/src/platforms/discord/commands/note.test.ts +6 -6
- package/src/platforms/discord/commands/profile.test.ts +4 -4
- package/src/platforms/discord/commands/reaction.test.ts +5 -5
- package/src/platforms/discord/commands/server.test.ts +7 -7
- package/src/platforms/discord/commands/snapshot.test.ts +6 -6
- package/src/platforms/discord/commands/thread.test.ts +6 -6
- package/src/platforms/discord/commands/user.test.ts +5 -5
- package/src/platforms/discord/commands/whoami.test.ts +6 -6
- package/src/platforms/discord/credential-manager.test.ts +16 -16
- package/src/platforms/discord/ensure-auth.test.ts +8 -8
- package/src/platforms/discord/index.test.ts +17 -17
- package/src/platforms/discord/listener.test.ts +33 -33
- package/src/platforms/discord/token-extractor.test.ts +53 -53
- package/src/platforms/discord/types.test.ts +26 -26
- package/src/platforms/discordbot/client.test.ts +31 -31
- package/src/platforms/discordbot/commands/auth.test.ts +18 -18
- package/src/platforms/discordbot/commands/channel.test.ts +11 -11
- package/src/platforms/discordbot/commands/file.test.ts +7 -7
- package/src/platforms/discordbot/commands/message.test.ts +25 -25
- package/src/platforms/discordbot/commands/reaction.test.ts +6 -6
- package/src/platforms/discordbot/commands/server.test.ts +12 -12
- package/src/platforms/discordbot/commands/snapshot.test.ts +13 -13
- package/src/platforms/discordbot/commands/thread.test.ts +10 -10
- package/src/platforms/discordbot/commands/user.test.ts +9 -9
- package/src/platforms/discordbot/commands/whoami.test.ts +4 -4
- package/src/platforms/discordbot/credential-manager.test.ts +28 -28
- package/src/platforms/instagram/client.test.ts +18 -18
- package/src/platforms/instagram/commands/auth.test.ts +11 -11
- package/src/platforms/instagram/commands/chat.test.ts +6 -6
- package/src/platforms/instagram/commands/message.test.ts +11 -11
- package/src/platforms/instagram/commands/shared.test.ts +12 -12
- package/src/platforms/instagram/commands/whoami.test.ts +3 -3
- package/src/platforms/instagram/credential-manager.test.ts +21 -21
- package/src/platforms/instagram/ensure-auth.test.ts +4 -4
- package/src/platforms/instagram/index.test.ts +9 -9
- package/src/platforms/instagram/listener.test.ts +8 -8
- package/src/platforms/instagram/token-extractor.test.ts +35 -35
- package/src/platforms/kakaotalk/client.test.ts +33 -33
- package/src/platforms/kakaotalk/commands/auth.test.ts +11 -11
- package/src/platforms/kakaotalk/commands/chat.test.ts +6 -6
- package/src/platforms/kakaotalk/commands/message.test.ts +7 -7
- package/src/platforms/kakaotalk/commands/whoami.test.ts +5 -5
- package/src/platforms/kakaotalk/credential-manager.test.ts +15 -15
- package/src/platforms/kakaotalk/index.test.ts +15 -15
- package/src/platforms/kakaotalk/listener.test.ts +17 -17
- package/src/platforms/line/client.test.ts +17 -17
- package/src/platforms/line/commands/auth.test.ts +8 -8
- package/src/platforms/line/commands/chat.test.ts +7 -7
- package/src/platforms/line/commands/friend.test.ts +6 -6
- package/src/platforms/line/commands/message.test.ts +7 -7
- package/src/platforms/line/commands/whoami.test.ts +6 -6
- package/src/platforms/line/credential-manager.test.ts +17 -17
- package/src/platforms/line/index.test.ts +10 -10
- package/src/platforms/line/listener.test.ts +15 -15
- package/src/platforms/line/types.test.ts +14 -14
- package/src/platforms/slack/cli.test.ts +8 -8
- package/src/platforms/slack/client.test.ts +151 -151
- package/src/platforms/slack/commands/activity.test.ts +13 -13
- package/src/platforms/slack/commands/auth.test.ts +34 -34
- package/src/platforms/slack/commands/bookmark.test.ts +9 -9
- package/src/platforms/slack/commands/channel.test.ts +17 -17
- package/src/platforms/slack/commands/drafts.test.ts +7 -7
- package/src/platforms/slack/commands/emoji.test.ts +3 -3
- package/src/platforms/slack/commands/file.test.ts +12 -12
- package/src/platforms/slack/commands/message.test.ts +19 -19
- package/src/platforms/slack/commands/pin.test.ts +7 -7
- package/src/platforms/slack/commands/reaction.test.ts +10 -10
- package/src/platforms/slack/commands/reminder.test.ts +9 -9
- package/src/platforms/slack/commands/saved.test.ts +7 -7
- package/src/platforms/slack/commands/sections.test.ts +5 -5
- package/src/platforms/slack/commands/snapshot.test.ts +13 -13
- package/src/platforms/slack/commands/unread.test.ts +6 -6
- package/src/platforms/slack/commands/user.test.ts +10 -10
- package/src/platforms/slack/commands/usergroup.test.ts +15 -15
- package/src/platforms/slack/commands/whoami.test.ts +6 -6
- package/src/platforms/slack/commands/workspace.test.ts +26 -26
- package/src/platforms/slack/credential-manager.test.ts +14 -14
- package/src/platforms/slack/ensure-auth.test.ts +21 -21
- package/src/platforms/slack/index.test.ts +12 -12
- package/src/platforms/slack/listener.test.ts +17 -17
- package/src/platforms/slack/token-extractor-node.test.ts +2 -2
- package/src/platforms/slack/token-extractor.test.ts +37 -37
- package/src/platforms/slack/types.test.ts +21 -21
- package/src/platforms/slackbot/client.test.ts +22 -22
- package/src/platforms/slackbot/commands/auth.test.ts +14 -14
- package/src/platforms/slackbot/commands/channel.test.ts +7 -7
- package/src/platforms/slackbot/commands/message.test.ts +13 -13
- package/src/platforms/slackbot/commands/reaction.test.ts +6 -6
- package/src/platforms/slackbot/commands/user.test.ts +7 -7
- package/src/platforms/slackbot/commands/whoami.test.ts +4 -4
- package/src/platforms/slackbot/credential-manager.test.ts +22 -22
- package/src/platforms/slackbot/types.test.ts +7 -7
- package/src/platforms/teams/client.test.ts +30 -30
- package/src/platforms/teams/commands/auth.test.ts +8 -8
- package/src/platforms/teams/commands/channel.test.ts +7 -7
- package/src/platforms/teams/commands/file.test.ts +4 -4
- package/src/platforms/teams/commands/message.test.ts +5 -5
- package/src/platforms/teams/commands/reaction.test.ts +4 -4
- package/src/platforms/teams/commands/snapshot.test.ts +7 -7
- package/src/platforms/teams/commands/team.test.ts +8 -8
- package/src/platforms/teams/commands/user.test.ts +4 -4
- package/src/platforms/teams/commands/whoami.test.ts +6 -6
- package/src/platforms/teams/credential-manager.test.ts +17 -17
- package/src/platforms/teams/ensure-auth.test.ts +13 -13
- package/src/platforms/teams/index.test.ts +15 -15
- package/src/platforms/teams/token-extractor.test.ts +109 -49
- package/src/platforms/teams/token-extractor.ts +7 -2
- package/src/platforms/teams/types.test.ts +26 -26
- package/src/platforms/telegram/app-config.test.ts +4 -4
- package/src/platforms/telegram/chat-utils.test.ts +12 -12
- package/src/platforms/telegram/client.test.ts +4 -4
- package/src/platforms/telegram/commands/auth.test.ts +16 -16
- package/src/platforms/telegram/commands/chat.test.ts +9 -9
- package/src/platforms/telegram/commands/message.test.ts +6 -6
- package/src/platforms/telegram/commands/shared.test.ts +3 -3
- package/src/platforms/telegram/commands/whoami.test.ts +3 -3
- package/src/platforms/telegram/credential-manager.test.ts +10 -10
- package/src/platforms/telegram/types.test.ts +6 -6
- package/src/platforms/webex/app-config.test.ts +8 -8
- package/src/platforms/webex/cli.test.ts +5 -5
- package/src/platforms/webex/client.test.ts +65 -65
- package/src/platforms/webex/commands/auth.test.ts +18 -18
- package/src/platforms/webex/commands/member.test.ts +5 -5
- package/src/platforms/webex/commands/message.test.ts +12 -12
- package/src/platforms/webex/commands/snapshot.test.ts +5 -5
- package/src/platforms/webex/commands/space.test.ts +10 -10
- package/src/platforms/webex/commands/whoami.test.ts +6 -6
- package/src/platforms/webex/credential-manager.test.ts +22 -22
- package/src/platforms/webex/encryption.test.ts +4 -4
- package/src/platforms/webex/ensure-auth.test.ts +5 -5
- package/src/platforms/webex/index.test.ts +5 -5
- package/src/platforms/webex/markdown-to-html.test.ts +33 -33
- package/src/platforms/webex/token-extractor.test.ts +23 -23
- package/src/platforms/webex/types.test.ts +27 -27
- package/src/platforms/wechatbot/client.test.ts +27 -27
- package/src/platforms/wechatbot/commands/auth.test.ts +15 -15
- package/src/platforms/wechatbot/commands/message.test.ts +8 -8
- package/src/platforms/wechatbot/commands/template.test.ts +9 -9
- package/src/platforms/wechatbot/commands/user.test.ts +7 -7
- package/src/platforms/wechatbot/commands/whoami.test.ts +5 -5
- package/src/platforms/wechatbot/credential-manager.test.ts +18 -18
- package/src/platforms/wechatbot/index.test.ts +10 -10
- package/src/platforms/wechatbot/types.test.ts +25 -25
- package/src/platforms/whatsapp/commands/auth.test.ts +13 -13
- package/src/platforms/whatsapp/commands/chat.test.ts +8 -8
- package/src/platforms/whatsapp/commands/message.test.ts +10 -10
- package/src/platforms/whatsapp/commands/whoami.test.ts +3 -3
- package/src/platforms/whatsapp/credential-manager.test.ts +23 -23
- package/src/platforms/whatsapp/ensure-auth.test.ts +4 -4
- package/src/platforms/whatsapp/index.test.ts +8 -8
- package/src/platforms/whatsapp/types.test.ts +42 -42
- package/src/platforms/whatsappbot/client.test.ts +27 -27
- package/src/platforms/whatsappbot/commands/auth.test.ts +14 -14
- package/src/platforms/whatsappbot/commands/message.test.ts +16 -16
- package/src/platforms/whatsappbot/commands/template.test.ts +9 -9
- package/src/platforms/whatsappbot/commands/whoami.test.ts +5 -5
- package/src/platforms/whatsappbot/credential-manager.test.ts +18 -18
- package/src/platforms/whatsappbot/index.test.ts +7 -7
- package/src/platforms/whatsappbot/types.test.ts +18 -18
- package/src/shared/chromium/browsers.test.ts +22 -22
- package/src/shared/chromium/cookie-reader.test.ts +13 -13
- package/src/shared/chromium/decryptor.test.ts +97 -32
- package/src/shared/chromium/decryptor.ts +27 -6
- package/src/shared/utils/concurrency.test.ts +6 -6
- package/src/shared/utils/derived-key-cache.test.ts +11 -11
- package/src/tui/utils.test.ts +31 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, describe, expect, mock,
|
|
1
|
+
import { afterEach, describe, expect, mock, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { DiscordListener } from '@/platforms/discord/listener'
|
|
4
4
|
import type {
|
|
@@ -111,7 +111,7 @@ describe('DiscordListener', () => {
|
|
|
111
111
|
})
|
|
112
112
|
|
|
113
113
|
describe('start', () => {
|
|
114
|
-
|
|
114
|
+
it('calls gatewayConnect and opens WebSocket', async () => {
|
|
115
115
|
const client = createMockClient()
|
|
116
116
|
listener = new DiscordListener(client)
|
|
117
117
|
|
|
@@ -121,7 +121,7 @@ describe('DiscordListener', () => {
|
|
|
121
121
|
expect(client.gatewayConnect).toHaveBeenCalledTimes(1)
|
|
122
122
|
})
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
it('is idempotent', async () => {
|
|
125
125
|
const client = createMockClient()
|
|
126
126
|
listener = new DiscordListener(client)
|
|
127
127
|
|
|
@@ -133,7 +133,7 @@ describe('DiscordListener', () => {
|
|
|
133
133
|
})
|
|
134
134
|
|
|
135
135
|
describe('connected event', () => {
|
|
136
|
-
|
|
136
|
+
it('emits connected with user/sessionId on READY', async () => {
|
|
137
137
|
const client = createMockClient()
|
|
138
138
|
listener = new DiscordListener(client)
|
|
139
139
|
|
|
@@ -152,7 +152,7 @@ describe('DiscordListener', () => {
|
|
|
152
152
|
})
|
|
153
153
|
|
|
154
154
|
describe('identify', () => {
|
|
155
|
-
|
|
155
|
+
it('sends Identify after Hello', async () => {
|
|
156
156
|
const client = createMockClient()
|
|
157
157
|
listener = new DiscordListener(client)
|
|
158
158
|
|
|
@@ -167,7 +167,7 @@ describe('DiscordListener', () => {
|
|
|
167
167
|
expect(identifyMsg.d.token).toBe('fake-token')
|
|
168
168
|
})
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
it('sends Identify with custom intents', async () => {
|
|
171
171
|
const client = createMockClient()
|
|
172
172
|
const customIntents = 1 << 9
|
|
173
173
|
listener = new DiscordListener(client, { intents: customIntents })
|
|
@@ -185,7 +185,7 @@ describe('DiscordListener', () => {
|
|
|
185
185
|
})
|
|
186
186
|
|
|
187
187
|
describe('message events', () => {
|
|
188
|
-
|
|
188
|
+
it('emits message_create events', async () => {
|
|
189
189
|
const client = createMockClient()
|
|
190
190
|
listener = new DiscordListener(client)
|
|
191
191
|
|
|
@@ -213,7 +213,7 @@ describe('DiscordListener', () => {
|
|
|
213
213
|
expect(messages[0].channel_id).toBe('C123')
|
|
214
214
|
})
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
it('emits message_update events', async () => {
|
|
217
217
|
const client = createMockClient()
|
|
218
218
|
listener = new DiscordListener(client)
|
|
219
219
|
|
|
@@ -235,7 +235,7 @@ describe('DiscordListener', () => {
|
|
|
235
235
|
expect(updates[0].content).toBe('edited')
|
|
236
236
|
})
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
it('emits message_delete events', async () => {
|
|
239
239
|
const client = createMockClient()
|
|
240
240
|
listener = new DiscordListener(client)
|
|
241
241
|
|
|
@@ -254,7 +254,7 @@ describe('DiscordListener', () => {
|
|
|
254
254
|
})
|
|
255
255
|
|
|
256
256
|
describe('reaction events', () => {
|
|
257
|
-
|
|
257
|
+
it('emits message_reaction_add events', async () => {
|
|
258
258
|
const client = createMockClient()
|
|
259
259
|
listener = new DiscordListener(client)
|
|
260
260
|
|
|
@@ -283,7 +283,7 @@ describe('DiscordListener', () => {
|
|
|
283
283
|
})
|
|
284
284
|
|
|
285
285
|
describe('discord_event catch-all', () => {
|
|
286
|
-
|
|
286
|
+
it('emits discord_event for every dispatch (not READY)', async () => {
|
|
287
287
|
const client = createMockClient()
|
|
288
288
|
listener = new DiscordListener(client)
|
|
289
289
|
|
|
@@ -308,7 +308,7 @@ describe('DiscordListener', () => {
|
|
|
308
308
|
})
|
|
309
309
|
|
|
310
310
|
describe('heartbeat', () => {
|
|
311
|
-
|
|
311
|
+
it('sends heartbeat after Hello (with jitter)', async () => {
|
|
312
312
|
const originalRandom = Math.random
|
|
313
313
|
Math.random = () => 0
|
|
314
314
|
|
|
@@ -331,7 +331,7 @@ describe('DiscordListener', () => {
|
|
|
331
331
|
}
|
|
332
332
|
})
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
it('heartbeat ACK not emitted as user event', async () => {
|
|
335
335
|
const client = createMockClient()
|
|
336
336
|
listener = new DiscordListener(client)
|
|
337
337
|
|
|
@@ -347,7 +347,7 @@ describe('DiscordListener', () => {
|
|
|
347
347
|
expect(events.length).toBe(0)
|
|
348
348
|
})
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
it('zombie connection triggers reconnect (no ACK received)', async () => {
|
|
351
351
|
const originalRandom = Math.random
|
|
352
352
|
Math.random = () => 0
|
|
353
353
|
|
|
@@ -372,7 +372,7 @@ describe('DiscordListener', () => {
|
|
|
372
372
|
})
|
|
373
373
|
|
|
374
374
|
describe('stop', () => {
|
|
375
|
-
|
|
375
|
+
it('closes WebSocket and prevents reconnection', async () => {
|
|
376
376
|
const client = createMockClient()
|
|
377
377
|
listener = new DiscordListener(client)
|
|
378
378
|
|
|
@@ -387,7 +387,7 @@ describe('DiscordListener', () => {
|
|
|
387
387
|
})
|
|
388
388
|
|
|
389
389
|
describe('reconnection', () => {
|
|
390
|
-
|
|
390
|
+
it('reconnects on WebSocket close when running', async () => {
|
|
391
391
|
const client = createMockClient()
|
|
392
392
|
listener = new DiscordListener(client)
|
|
393
393
|
|
|
@@ -404,7 +404,7 @@ describe('DiscordListener', () => {
|
|
|
404
404
|
expect(client.gatewayConnect.mock.calls.length).toBeGreaterThanOrEqual(2)
|
|
405
405
|
})
|
|
406
406
|
|
|
407
|
-
|
|
407
|
+
it('emits error and reconnects on gatewayConnect failure', async () => {
|
|
408
408
|
let callCount = 0
|
|
409
409
|
const client = createMockClient({
|
|
410
410
|
gatewayConnect: mock(() => {
|
|
@@ -430,7 +430,7 @@ describe('DiscordListener', () => {
|
|
|
430
430
|
})
|
|
431
431
|
|
|
432
432
|
describe('on/off/once', () => {
|
|
433
|
-
|
|
433
|
+
it('off removes listener', async () => {
|
|
434
434
|
const client = createMockClient()
|
|
435
435
|
listener = new DiscordListener(client)
|
|
436
436
|
|
|
@@ -459,7 +459,7 @@ describe('DiscordListener', () => {
|
|
|
459
459
|
expect(messages[0].content).toBe('a')
|
|
460
460
|
})
|
|
461
461
|
|
|
462
|
-
|
|
462
|
+
it('once fires only once', async () => {
|
|
463
463
|
const client = createMockClient()
|
|
464
464
|
listener = new DiscordListener(client)
|
|
465
465
|
|
|
@@ -487,7 +487,7 @@ describe('DiscordListener', () => {
|
|
|
487
487
|
})
|
|
488
488
|
|
|
489
489
|
describe('opcode 7 Reconnect', () => {
|
|
490
|
-
|
|
490
|
+
it('triggers immediate reconnect without backoff', async () => {
|
|
491
491
|
const client = createMockClient()
|
|
492
492
|
listener = new DiscordListener(client)
|
|
493
493
|
|
|
@@ -504,7 +504,7 @@ describe('DiscordListener', () => {
|
|
|
504
504
|
})
|
|
505
505
|
|
|
506
506
|
describe('opcode 9 InvalidSession', () => {
|
|
507
|
-
|
|
507
|
+
it('d=false clears session state, reconnects with fresh identify', async () => {
|
|
508
508
|
const client = createMockClient()
|
|
509
509
|
listener = new DiscordListener(client)
|
|
510
510
|
|
|
@@ -522,7 +522,7 @@ describe('DiscordListener', () => {
|
|
|
522
522
|
expect((listener as any).resumeGatewayUrl).toBeNull()
|
|
523
523
|
})
|
|
524
524
|
|
|
525
|
-
|
|
525
|
+
it('d=true allows resume on reconnect', async () => {
|
|
526
526
|
const client = createMockClient()
|
|
527
527
|
listener = new DiscordListener(client)
|
|
528
528
|
|
|
@@ -540,7 +540,7 @@ describe('DiscordListener', () => {
|
|
|
540
540
|
})
|
|
541
541
|
|
|
542
542
|
describe('resume', () => {
|
|
543
|
-
|
|
543
|
+
it('sends Resume instead of Identify when session exists', async () => {
|
|
544
544
|
const client = createMockClient()
|
|
545
545
|
listener = new DiscordListener(client)
|
|
546
546
|
|
|
@@ -565,7 +565,7 @@ describe('DiscordListener', () => {
|
|
|
565
565
|
})
|
|
566
566
|
|
|
567
567
|
describe('non-recoverable close codes', () => {
|
|
568
|
-
|
|
568
|
+
it('emits error and stops on code 4004', async () => {
|
|
569
569
|
const client = createMockClient()
|
|
570
570
|
listener = new DiscordListener(client)
|
|
571
571
|
|
|
@@ -585,7 +585,7 @@ describe('DiscordListener', () => {
|
|
|
585
585
|
})
|
|
586
586
|
|
|
587
587
|
describe('session reset close codes', () => {
|
|
588
|
-
|
|
588
|
+
it('4007 clears session and reconnects with fresh identify', async () => {
|
|
589
589
|
const client = createMockClient()
|
|
590
590
|
listener = new DiscordListener(client)
|
|
591
591
|
|
|
@@ -615,7 +615,7 @@ describe('DiscordListener', () => {
|
|
|
615
615
|
expect(resumeMsg).toBeUndefined()
|
|
616
616
|
})
|
|
617
617
|
|
|
618
|
-
|
|
618
|
+
it('4009 clears session and reconnects with fresh identify', async () => {
|
|
619
619
|
const client = createMockClient()
|
|
620
620
|
listener = new DiscordListener(client)
|
|
621
621
|
|
|
@@ -631,7 +631,7 @@ describe('DiscordListener', () => {
|
|
|
631
631
|
})
|
|
632
632
|
|
|
633
633
|
describe('duplicate Hello', () => {
|
|
634
|
-
|
|
634
|
+
it('does not stack heartbeat timers on second Hello', async () => {
|
|
635
635
|
const originalRandom = Math.random
|
|
636
636
|
Math.random = () => 0
|
|
637
637
|
|
|
@@ -659,7 +659,7 @@ describe('DiscordListener', () => {
|
|
|
659
659
|
})
|
|
660
660
|
|
|
661
661
|
describe('InvalidSession timer safety', () => {
|
|
662
|
-
|
|
662
|
+
it('stop cancels pending InvalidSession d=true timeout', async () => {
|
|
663
663
|
const originalRandom = Math.random
|
|
664
664
|
Math.random = () => 0
|
|
665
665
|
|
|
@@ -682,7 +682,7 @@ describe('DiscordListener', () => {
|
|
|
682
682
|
}
|
|
683
683
|
})
|
|
684
684
|
|
|
685
|
-
|
|
685
|
+
it('InvalidSession d=false sends fresh identify on reconnect', async () => {
|
|
686
686
|
const client = createMockClient()
|
|
687
687
|
listener = new DiscordListener(client)
|
|
688
688
|
|
|
@@ -708,7 +708,7 @@ describe('DiscordListener', () => {
|
|
|
708
708
|
})
|
|
709
709
|
|
|
710
710
|
describe('server-requested heartbeat', () => {
|
|
711
|
-
|
|
711
|
+
it('responds to opcode 1 with heartbeat', async () => {
|
|
712
712
|
const client = createMockClient()
|
|
713
713
|
listener = new DiscordListener(client)
|
|
714
714
|
|
|
@@ -728,7 +728,7 @@ describe('DiscordListener', () => {
|
|
|
728
728
|
})
|
|
729
729
|
|
|
730
730
|
describe('sequence tracking', () => {
|
|
731
|
-
|
|
731
|
+
it('tracks sequence from dispatch events', async () => {
|
|
732
732
|
const client = createMockClient()
|
|
733
733
|
listener = new DiscordListener(client)
|
|
734
734
|
|
|
@@ -746,7 +746,7 @@ describe('DiscordListener', () => {
|
|
|
746
746
|
expect((listener as any).sequence).toBe(5)
|
|
747
747
|
})
|
|
748
748
|
|
|
749
|
-
|
|
749
|
+
it('ignores null sequence values', async () => {
|
|
750
750
|
const client = createMockClient()
|
|
751
751
|
listener = new DiscordListener(client)
|
|
752
752
|
|
|
@@ -773,7 +773,7 @@ describe('DiscordListener', () => {
|
|
|
773
773
|
})
|
|
774
774
|
|
|
775
775
|
describe('start after stop', () => {
|
|
776
|
-
|
|
776
|
+
it('resets reconnect attempts on fresh start', async () => {
|
|
777
777
|
const client = createMockClient()
|
|
778
778
|
listener = new DiscordListener(client)
|
|
779
779
|
|