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 { beforeEach, describe, expect, mock,
|
|
1
|
+
import { beforeEach, describe, expect, mock, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import type { WebClient } from '@slack/web-api'
|
|
4
4
|
|
|
@@ -47,21 +47,21 @@ function resetMocks() {
|
|
|
47
47
|
|
|
48
48
|
describe('SlackClient', () => {
|
|
49
49
|
describe('login', () => {
|
|
50
|
-
|
|
50
|
+
it('throws SlackError when token is empty', async () => {
|
|
51
51
|
await expect(new SlackClient().login({ token: '', cookie: 'xoxd-cookie' })).rejects.toThrow(SlackError)
|
|
52
52
|
await expect(new SlackClient().login({ token: '', cookie: 'xoxd-cookie' })).rejects.toThrow('Token is required')
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
it('throws SlackError when cookie is empty', async () => {
|
|
56
56
|
await expect(new SlackClient().login({ token: 'xoxc-token', cookie: '' })).rejects.toThrow(SlackError)
|
|
57
57
|
await expect(new SlackClient().login({ token: 'xoxc-token', cookie: '' })).rejects.toThrow('Cookie is required')
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
it('throws SlackError when both token and cookie are empty', async () => {
|
|
61
61
|
await expect(new SlackClient().login({ token: '', cookie: '' })).rejects.toThrow(SlackError)
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
it('creates client successfully with valid token and cookie', async () => {
|
|
65
65
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
66
66
|
expect(client).toBeInstanceOf(SlackClient)
|
|
67
67
|
})
|
|
@@ -70,7 +70,7 @@ describe('SlackClient', () => {
|
|
|
70
70
|
describe('testAuth', () => {
|
|
71
71
|
beforeEach(() => resetMocks())
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
it('returns auth info on success', async () => {
|
|
74
74
|
mockWebClient.auth.test.mockResolvedValue({
|
|
75
75
|
ok: true,
|
|
76
76
|
user_id: 'U123',
|
|
@@ -88,7 +88,7 @@ describe('SlackClient', () => {
|
|
|
88
88
|
expect(result.team_id).toBe('T123')
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
it('throws SlackError on API failure', async () => {
|
|
92
92
|
mockWebClient.auth.test.mockResolvedValue({
|
|
93
93
|
ok: false,
|
|
94
94
|
error: 'invalid_auth',
|
|
@@ -105,7 +105,7 @@ describe('SlackClient', () => {
|
|
|
105
105
|
describe('listChannels', () => {
|
|
106
106
|
beforeEach(() => resetMocks())
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
it('returns list of channels', async () => {
|
|
109
109
|
mockWebClient.conversations.list.mockResolvedValue({
|
|
110
110
|
ok: true,
|
|
111
111
|
channels: [
|
|
@@ -138,7 +138,7 @@ describe('SlackClient', () => {
|
|
|
138
138
|
expect(channels[1].name).toBe('random')
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
it('handles pagination automatically', async () => {
|
|
142
142
|
mockWebClient.conversations.list
|
|
143
143
|
.mockResolvedValueOnce({
|
|
144
144
|
ok: true,
|
|
@@ -177,7 +177,7 @@ describe('SlackClient', () => {
|
|
|
177
177
|
expect(mockWebClient.conversations.list).toHaveBeenCalledTimes(2)
|
|
178
178
|
})
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
it('throws SlackError on API failure', async () => {
|
|
181
181
|
mockWebClient.conversations.list.mockResolvedValue({
|
|
182
182
|
ok: false,
|
|
183
183
|
error: 'channel_not_found',
|
|
@@ -194,7 +194,7 @@ describe('SlackClient', () => {
|
|
|
194
194
|
describe('getChannel', () => {
|
|
195
195
|
beforeEach(() => resetMocks())
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
it('returns channel info', async () => {
|
|
198
198
|
mockWebClient.conversations.info.mockResolvedValue({
|
|
199
199
|
ok: true,
|
|
200
200
|
channel: {
|
|
@@ -216,7 +216,7 @@ describe('SlackClient', () => {
|
|
|
216
216
|
expect(channel.name).toBe('general')
|
|
217
217
|
})
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
it('throws SlackError when channel not found', async () => {
|
|
220
220
|
mockWebClient.conversations.info.mockResolvedValue({
|
|
221
221
|
ok: false,
|
|
222
222
|
error: 'channel_not_found',
|
|
@@ -233,25 +233,25 @@ describe('SlackClient', () => {
|
|
|
233
233
|
describe('resolveChannel', () => {
|
|
234
234
|
beforeEach(() => resetMocks())
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
it('returns channel ID unchanged when input starts with C', async () => {
|
|
237
237
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
238
238
|
const channel = await client.resolveChannel('C123ABC')
|
|
239
239
|
expect(channel).toBe('C123ABC')
|
|
240
240
|
})
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
it('returns channel ID unchanged when input starts with D', async () => {
|
|
243
243
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
244
244
|
const channel = await client.resolveChannel('D123ABC')
|
|
245
245
|
expect(channel).toBe('D123ABC')
|
|
246
246
|
})
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
it('returns channel ID unchanged when input starts with G', async () => {
|
|
249
249
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
250
250
|
const channel = await client.resolveChannel('G123ABC')
|
|
251
251
|
expect(channel).toBe('G123ABC')
|
|
252
252
|
})
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
it('resolves channel name to ID by calling listChannels', async () => {
|
|
255
255
|
mockWebClient.conversations.list.mockResolvedValue({
|
|
256
256
|
ok: true,
|
|
257
257
|
channels: [
|
|
@@ -275,7 +275,7 @@ describe('SlackClient', () => {
|
|
|
275
275
|
expect(mockWebClient.conversations.list).toHaveBeenCalledTimes(1)
|
|
276
276
|
})
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
it('strips leading # from channel name', async () => {
|
|
279
279
|
mockWebClient.conversations.list.mockResolvedValue({
|
|
280
280
|
ok: true,
|
|
281
281
|
channels: [
|
|
@@ -299,13 +299,13 @@ describe('SlackClient', () => {
|
|
|
299
299
|
expect(mockWebClient.conversations.list).toHaveBeenCalledTimes(1)
|
|
300
300
|
})
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
it('returns channel ID unchanged when input is #C prefixed ID', async () => {
|
|
303
303
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
304
304
|
const channel = await client.resolveChannel('#C123ABC')
|
|
305
305
|
expect(channel).toBe('C123ABC')
|
|
306
306
|
})
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
it("throws SlackError with code 'channel_not_found' when name is not found", async () => {
|
|
309
309
|
mockWebClient.conversations.list.mockResolvedValue({
|
|
310
310
|
ok: true,
|
|
311
311
|
channels: [
|
|
@@ -334,7 +334,7 @@ describe('SlackClient', () => {
|
|
|
334
334
|
describe('getMessages', () => {
|
|
335
335
|
beforeEach(() => resetMocks())
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
it('returns messages with default limit of 20', async () => {
|
|
338
338
|
const messages = Array.from({ length: 20 }, (_, i) => ({
|
|
339
339
|
ts: `123.${i}`,
|
|
340
340
|
text: `Message ${i}`,
|
|
@@ -356,7 +356,7 @@ describe('SlackClient', () => {
|
|
|
356
356
|
)
|
|
357
357
|
})
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
it('respects custom limit', async () => {
|
|
360
360
|
mockWebClient.conversations.history.mockResolvedValue({
|
|
361
361
|
ok: true,
|
|
362
362
|
messages: [{ ts: '123.456', text: 'Hello', type: 'message' }],
|
|
@@ -372,7 +372,7 @@ describe('SlackClient', () => {
|
|
|
372
372
|
)
|
|
373
373
|
})
|
|
374
374
|
|
|
375
|
-
|
|
375
|
+
it('throws SlackError on API failure', async () => {
|
|
376
376
|
mockWebClient.conversations.history.mockResolvedValue({
|
|
377
377
|
ok: false,
|
|
378
378
|
error: 'channel_not_found',
|
|
@@ -389,7 +389,7 @@ describe('SlackClient', () => {
|
|
|
389
389
|
describe('sendMessage', () => {
|
|
390
390
|
beforeEach(() => resetMocks())
|
|
391
391
|
|
|
392
|
-
|
|
392
|
+
it('sends message to channel', async () => {
|
|
393
393
|
mockWebClient.chat.postMessage.mockResolvedValue({
|
|
394
394
|
ok: true,
|
|
395
395
|
ts: '123.456',
|
|
@@ -407,7 +407,7 @@ describe('SlackClient', () => {
|
|
|
407
407
|
)
|
|
408
408
|
})
|
|
409
409
|
|
|
410
|
-
|
|
410
|
+
it('sends message to thread', async () => {
|
|
411
411
|
mockWebClient.chat.postMessage.mockResolvedValue({
|
|
412
412
|
ok: true,
|
|
413
413
|
ts: '123.789',
|
|
@@ -425,7 +425,7 @@ describe('SlackClient', () => {
|
|
|
425
425
|
)
|
|
426
426
|
})
|
|
427
427
|
|
|
428
|
-
|
|
428
|
+
it('throws SlackError on API failure', async () => {
|
|
429
429
|
mockWebClient.chat.postMessage.mockResolvedValue({
|
|
430
430
|
ok: false,
|
|
431
431
|
error: 'channel_not_found',
|
|
@@ -442,7 +442,7 @@ describe('SlackClient', () => {
|
|
|
442
442
|
describe('updateMessage', () => {
|
|
443
443
|
beforeEach(() => resetMocks())
|
|
444
444
|
|
|
445
|
-
|
|
445
|
+
it('updates message text', async () => {
|
|
446
446
|
mockWebClient.chat.update.mockResolvedValue({
|
|
447
447
|
ok: true,
|
|
448
448
|
ts: '123.456',
|
|
@@ -460,7 +460,7 @@ describe('SlackClient', () => {
|
|
|
460
460
|
)
|
|
461
461
|
})
|
|
462
462
|
|
|
463
|
-
|
|
463
|
+
it('throws SlackError on API failure', async () => {
|
|
464
464
|
mockWebClient.chat.update.mockResolvedValue({
|
|
465
465
|
ok: false,
|
|
466
466
|
error: 'message_not_found',
|
|
@@ -477,7 +477,7 @@ describe('SlackClient', () => {
|
|
|
477
477
|
describe('deleteMessage', () => {
|
|
478
478
|
beforeEach(() => resetMocks())
|
|
479
479
|
|
|
480
|
-
|
|
480
|
+
it('deletes message', async () => {
|
|
481
481
|
mockWebClient.chat.delete.mockResolvedValue({ ok: true })
|
|
482
482
|
|
|
483
483
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
@@ -490,7 +490,7 @@ describe('SlackClient', () => {
|
|
|
490
490
|
)
|
|
491
491
|
})
|
|
492
492
|
|
|
493
|
-
|
|
493
|
+
it('throws SlackError on API failure', async () => {
|
|
494
494
|
mockWebClient.chat.delete.mockResolvedValue({
|
|
495
495
|
ok: false,
|
|
496
496
|
error: 'message_not_found',
|
|
@@ -507,7 +507,7 @@ describe('SlackClient', () => {
|
|
|
507
507
|
describe('addReaction', () => {
|
|
508
508
|
beforeEach(() => resetMocks())
|
|
509
509
|
|
|
510
|
-
|
|
510
|
+
it('adds reaction to message', async () => {
|
|
511
511
|
mockWebClient.reactions.add.mockResolvedValue({ ok: true })
|
|
512
512
|
|
|
513
513
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
@@ -520,7 +520,7 @@ describe('SlackClient', () => {
|
|
|
520
520
|
)
|
|
521
521
|
})
|
|
522
522
|
|
|
523
|
-
|
|
523
|
+
it('throws SlackError on API failure', async () => {
|
|
524
524
|
mockWebClient.reactions.add.mockResolvedValue({
|
|
525
525
|
ok: false,
|
|
526
526
|
error: 'already_reacted',
|
|
@@ -537,7 +537,7 @@ describe('SlackClient', () => {
|
|
|
537
537
|
describe('removeReaction', () => {
|
|
538
538
|
beforeEach(() => resetMocks())
|
|
539
539
|
|
|
540
|
-
|
|
540
|
+
it('removes reaction from message', async () => {
|
|
541
541
|
mockWebClient.reactions.remove.mockResolvedValue({ ok: true })
|
|
542
542
|
|
|
543
543
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
@@ -550,7 +550,7 @@ describe('SlackClient', () => {
|
|
|
550
550
|
)
|
|
551
551
|
})
|
|
552
552
|
|
|
553
|
-
|
|
553
|
+
it('throws SlackError on API failure', async () => {
|
|
554
554
|
mockWebClient.reactions.remove.mockResolvedValue({
|
|
555
555
|
ok: false,
|
|
556
556
|
error: 'no_reaction',
|
|
@@ -567,7 +567,7 @@ describe('SlackClient', () => {
|
|
|
567
567
|
describe('listUsers', () => {
|
|
568
568
|
beforeEach(() => resetMocks())
|
|
569
569
|
|
|
570
|
-
|
|
570
|
+
it('returns list of users', async () => {
|
|
571
571
|
mockWebClient.users.list.mockResolvedValue({
|
|
572
572
|
ok: true,
|
|
573
573
|
members: [
|
|
@@ -602,7 +602,7 @@ describe('SlackClient', () => {
|
|
|
602
602
|
expect(users[1].is_admin).toBe(true)
|
|
603
603
|
})
|
|
604
604
|
|
|
605
|
-
|
|
605
|
+
it('handles pagination automatically', async () => {
|
|
606
606
|
mockWebClient.users.list
|
|
607
607
|
.mockResolvedValueOnce({
|
|
608
608
|
ok: true,
|
|
@@ -643,7 +643,7 @@ describe('SlackClient', () => {
|
|
|
643
643
|
expect(mockWebClient.users.list).toHaveBeenCalledTimes(2)
|
|
644
644
|
})
|
|
645
645
|
|
|
646
|
-
|
|
646
|
+
it('throws SlackError on API failure', async () => {
|
|
647
647
|
mockWebClient.users.list.mockResolvedValue({
|
|
648
648
|
ok: false,
|
|
649
649
|
error: 'invalid_auth',
|
|
@@ -660,7 +660,7 @@ describe('SlackClient', () => {
|
|
|
660
660
|
describe('listChannelMembers', () => {
|
|
661
661
|
beforeEach(() => resetMocks())
|
|
662
662
|
|
|
663
|
-
|
|
663
|
+
it('returns member IDs for a channel', async () => {
|
|
664
664
|
mockWebClient.conversations.members.mockResolvedValue({
|
|
665
665
|
ok: true,
|
|
666
666
|
members: ['U123', 'U456', 'U789'],
|
|
@@ -677,7 +677,7 @@ describe('SlackClient', () => {
|
|
|
677
677
|
)
|
|
678
678
|
})
|
|
679
679
|
|
|
680
|
-
|
|
680
|
+
it('handles pagination automatically', async () => {
|
|
681
681
|
mockWebClient.conversations.members
|
|
682
682
|
.mockResolvedValueOnce({
|
|
683
683
|
ok: true,
|
|
@@ -698,7 +698,7 @@ describe('SlackClient', () => {
|
|
|
698
698
|
expect(mockWebClient.conversations.members).toHaveBeenCalledTimes(2)
|
|
699
699
|
})
|
|
700
700
|
|
|
701
|
-
|
|
701
|
+
it('throws SlackError on API failure', async () => {
|
|
702
702
|
mockWebClient.conversations.members.mockResolvedValue({
|
|
703
703
|
ok: false,
|
|
704
704
|
error: 'channel_not_found',
|
|
@@ -715,7 +715,7 @@ describe('SlackClient', () => {
|
|
|
715
715
|
describe('getUser', () => {
|
|
716
716
|
beforeEach(() => resetMocks())
|
|
717
717
|
|
|
718
|
-
|
|
718
|
+
it('returns user info', async () => {
|
|
719
719
|
mockWebClient.users.info.mockResolvedValue({
|
|
720
720
|
ok: true,
|
|
721
721
|
user: {
|
|
@@ -738,7 +738,7 @@ describe('SlackClient', () => {
|
|
|
738
738
|
expect(user.name).toBe('alice')
|
|
739
739
|
})
|
|
740
740
|
|
|
741
|
-
|
|
741
|
+
it('throws SlackError when user not found', async () => {
|
|
742
742
|
mockWebClient.users.info.mockResolvedValue({
|
|
743
743
|
ok: false,
|
|
744
744
|
error: 'user_not_found',
|
|
@@ -755,7 +755,7 @@ describe('SlackClient', () => {
|
|
|
755
755
|
describe('uploadFile', () => {
|
|
756
756
|
beforeEach(() => resetMocks())
|
|
757
757
|
|
|
758
|
-
|
|
758
|
+
it('uploads file to channels', async () => {
|
|
759
759
|
mockWebClient.files.uploadV2.mockResolvedValue({
|
|
760
760
|
ok: true,
|
|
761
761
|
files: [
|
|
@@ -788,7 +788,7 @@ describe('SlackClient', () => {
|
|
|
788
788
|
)
|
|
789
789
|
})
|
|
790
790
|
|
|
791
|
-
|
|
791
|
+
it('throws SlackError on API failure', async () => {
|
|
792
792
|
mockWebClient.files.uploadV2.mockResolvedValue({
|
|
793
793
|
ok: false,
|
|
794
794
|
error: 'file_upload_failed',
|
|
@@ -801,7 +801,7 @@ describe('SlackClient', () => {
|
|
|
801
801
|
await expect(client.uploadFile(['C123'], Buffer.from('test'), 'test.txt')).rejects.toThrow(SlackError)
|
|
802
802
|
})
|
|
803
803
|
|
|
804
|
-
|
|
804
|
+
it('throws SlackError when response has empty files array', async () => {
|
|
805
805
|
mockWebClient.files.uploadV2.mockResolvedValue({
|
|
806
806
|
ok: true,
|
|
807
807
|
files: [],
|
|
@@ -814,7 +814,7 @@ describe('SlackClient', () => {
|
|
|
814
814
|
await expect(client.uploadFile(['C123'], Buffer.from('test'), 'test.txt')).rejects.toThrow(SlackError)
|
|
815
815
|
})
|
|
816
816
|
|
|
817
|
-
|
|
817
|
+
it('throws SlackError when completion has no inner files', async () => {
|
|
818
818
|
mockWebClient.files.uploadV2.mockResolvedValue({
|
|
819
819
|
ok: true,
|
|
820
820
|
files: [{ ok: true, files: [] }],
|
|
@@ -831,7 +831,7 @@ describe('SlackClient', () => {
|
|
|
831
831
|
describe('listFiles', () => {
|
|
832
832
|
beforeEach(() => resetMocks())
|
|
833
833
|
|
|
834
|
-
|
|
834
|
+
it('returns list of files', async () => {
|
|
835
835
|
mockWebClient.files.list.mockResolvedValue({
|
|
836
836
|
ok: true,
|
|
837
837
|
files: [
|
|
@@ -857,7 +857,7 @@ describe('SlackClient', () => {
|
|
|
857
857
|
expect(files[0].name).toBe('test.txt')
|
|
858
858
|
})
|
|
859
859
|
|
|
860
|
-
|
|
860
|
+
it('filters by channel when provided', async () => {
|
|
861
861
|
mockWebClient.files.list.mockResolvedValue({
|
|
862
862
|
ok: true,
|
|
863
863
|
files: [],
|
|
@@ -871,7 +871,7 @@ describe('SlackClient', () => {
|
|
|
871
871
|
expect(mockWebClient.files.list).toHaveBeenCalledWith(expect.objectContaining({ channel: 'C123' }))
|
|
872
872
|
})
|
|
873
873
|
|
|
874
|
-
|
|
874
|
+
it('throws SlackError on API failure', async () => {
|
|
875
875
|
mockWebClient.files.list.mockResolvedValue({
|
|
876
876
|
ok: false,
|
|
877
877
|
error: 'invalid_auth',
|
|
@@ -888,7 +888,7 @@ describe('SlackClient', () => {
|
|
|
888
888
|
describe('getFileInfo', () => {
|
|
889
889
|
beforeEach(() => resetMocks())
|
|
890
890
|
|
|
891
|
-
|
|
891
|
+
it('returns file info', async () => {
|
|
892
892
|
mockWebClient.files.info.mockResolvedValue({
|
|
893
893
|
ok: true,
|
|
894
894
|
file: {
|
|
@@ -914,7 +914,7 @@ describe('SlackClient', () => {
|
|
|
914
914
|
expect(file.url_private).toBe('https://files.slack.com/files-pri/T123-F123/test.txt')
|
|
915
915
|
})
|
|
916
916
|
|
|
917
|
-
|
|
917
|
+
it('throws on API failure', async () => {
|
|
918
918
|
mockWebClient.files.info.mockResolvedValue({ ok: false, error: 'file_not_found' })
|
|
919
919
|
|
|
920
920
|
const client = await new SlackClient().login({ token: 'xoxc-token', cookie: 'xoxd-cookie' })
|
|
@@ -928,7 +928,7 @@ describe('SlackClient', () => {
|
|
|
928
928
|
describe('downloadFile', () => {
|
|
929
929
|
beforeEach(() => resetMocks())
|
|
930
930
|
|
|
931
|
-
|
|
931
|
+
it('downloads file content', async () => {
|
|
932
932
|
mockWebClient.files.info.mockResolvedValue({
|
|
933
933
|
ok: true,
|
|
934
934
|
file: {
|
|
@@ -960,7 +960,7 @@ describe('SlackClient', () => {
|
|
|
960
960
|
}
|
|
961
961
|
})
|
|
962
962
|
|
|
963
|
-
|
|
963
|
+
it('throws when url_private is empty', async () => {
|
|
964
964
|
mockWebClient.files.info.mockResolvedValue({
|
|
965
965
|
ok: true,
|
|
966
966
|
file: {
|
|
@@ -982,7 +982,7 @@ describe('SlackClient', () => {
|
|
|
982
982
|
await expect(client.downloadFile('F123')).rejects.toThrow('File has no download URL')
|
|
983
983
|
})
|
|
984
984
|
|
|
985
|
-
|
|
985
|
+
it('throws on download failure', async () => {
|
|
986
986
|
mockWebClient.files.info.mockResolvedValue({
|
|
987
987
|
ok: true,
|
|
988
988
|
file: {
|
|
@@ -1011,7 +1011,7 @@ describe('SlackClient', () => {
|
|
|
1011
1011
|
}
|
|
1012
1012
|
})
|
|
1013
1013
|
|
|
1014
|
-
|
|
1014
|
+
it('sends correct auth headers', async () => {
|
|
1015
1015
|
mockWebClient.files.info.mockResolvedValue({
|
|
1016
1016
|
ok: true,
|
|
1017
1017
|
file: {
|
|
@@ -1050,7 +1050,7 @@ describe('SlackClient', () => {
|
|
|
1050
1050
|
describe('getThreadReplies', () => {
|
|
1051
1051
|
beforeEach(() => resetMocks())
|
|
1052
1052
|
|
|
1053
|
-
|
|
1053
|
+
it('returns thread replies including parent message', async () => {
|
|
1054
1054
|
mockWebClient.conversations.replies.mockResolvedValue({
|
|
1055
1055
|
ok: true,
|
|
1056
1056
|
messages: [
|
|
@@ -1093,7 +1093,7 @@ describe('SlackClient', () => {
|
|
|
1093
1093
|
expect(result.has_more).toBe(false)
|
|
1094
1094
|
})
|
|
1095
1095
|
|
|
1096
|
-
|
|
1096
|
+
it('respects limit parameter', async () => {
|
|
1097
1097
|
mockWebClient.conversations.replies.mockResolvedValue({
|
|
1098
1098
|
ok: true,
|
|
1099
1099
|
messages: [{ ts: '123.456', text: 'Hello', type: 'message' }],
|
|
@@ -1110,7 +1110,7 @@ describe('SlackClient', () => {
|
|
|
1110
1110
|
)
|
|
1111
1111
|
})
|
|
1112
1112
|
|
|
1113
|
-
|
|
1113
|
+
it('passes optional oldest and latest parameters', async () => {
|
|
1114
1114
|
mockWebClient.conversations.replies.mockResolvedValue({
|
|
1115
1115
|
ok: true,
|
|
1116
1116
|
messages: [],
|
|
@@ -1135,7 +1135,7 @@ describe('SlackClient', () => {
|
|
|
1135
1135
|
)
|
|
1136
1136
|
})
|
|
1137
1137
|
|
|
1138
|
-
|
|
1138
|
+
it('returns pagination info when has_more is true', async () => {
|
|
1139
1139
|
mockWebClient.conversations.replies.mockResolvedValue({
|
|
1140
1140
|
ok: true,
|
|
1141
1141
|
messages: [{ ts: '123.456', text: 'Hello', type: 'message' }],
|
|
@@ -1152,7 +1152,7 @@ describe('SlackClient', () => {
|
|
|
1152
1152
|
expect(result.next_cursor).toBe('cursor123')
|
|
1153
1153
|
})
|
|
1154
1154
|
|
|
1155
|
-
|
|
1155
|
+
it('throws SlackError when thread not found', async () => {
|
|
1156
1156
|
mockWebClient.conversations.replies.mockResolvedValue({
|
|
1157
1157
|
ok: false,
|
|
1158
1158
|
error: 'thread_not_found',
|
|
@@ -1165,7 +1165,7 @@ describe('SlackClient', () => {
|
|
|
1165
1165
|
await expect(client.getThreadReplies('C123', '999.999')).rejects.toThrow(SlackError)
|
|
1166
1166
|
})
|
|
1167
1167
|
|
|
1168
|
-
|
|
1168
|
+
it('throws SlackError when channel not found', async () => {
|
|
1169
1169
|
mockWebClient.conversations.replies.mockResolvedValue({
|
|
1170
1170
|
ok: false,
|
|
1171
1171
|
error: 'channel_not_found',
|
|
@@ -1182,7 +1182,7 @@ describe('SlackClient', () => {
|
|
|
1182
1182
|
describe('rate limiting', () => {
|
|
1183
1183
|
beforeEach(() => resetMocks())
|
|
1184
1184
|
|
|
1185
|
-
|
|
1185
|
+
it('retries on rate limit error with exponential backoff', async () => {
|
|
1186
1186
|
const rateLimitError = new Error('Rate limited')
|
|
1187
1187
|
;(rateLimitError as any).code = 'slack_webapi_rate_limited_error'
|
|
1188
1188
|
;(rateLimitError as any).retryAfter = 0.001
|
|
@@ -1213,7 +1213,7 @@ describe('SlackClient', () => {
|
|
|
1213
1213
|
expect(mockWebClient.conversations.list).toHaveBeenCalledTimes(3)
|
|
1214
1214
|
})
|
|
1215
1215
|
|
|
1216
|
-
|
|
1216
|
+
it('throws SlackError after max retries (3)', async () => {
|
|
1217
1217
|
const rateLimitError = new Error('Rate limited')
|
|
1218
1218
|
;(rateLimitError as any).code = 'slack_webapi_rate_limited_error'
|
|
1219
1219
|
;(rateLimitError as any).retryAfter = 0.001
|
|
@@ -1229,7 +1229,7 @@ describe('SlackClient', () => {
|
|
|
1229
1229
|
expect(mockWebClient.conversations.list).toHaveBeenCalledTimes(4)
|
|
1230
1230
|
})
|
|
1231
1231
|
|
|
1232
|
-
|
|
1232
|
+
it('does not retry on non-rate-limit errors', async () => {
|
|
1233
1233
|
const otherError = new Error('Some other error')
|
|
1234
1234
|
;(otherError as any).code = 'some_other_error'
|
|
1235
1235
|
|
|
@@ -1245,19 +1245,19 @@ describe('SlackClient', () => {
|
|
|
1245
1245
|
})
|
|
1246
1246
|
|
|
1247
1247
|
describe('SlackError', () => {
|
|
1248
|
-
|
|
1248
|
+
it('is an instance of Error', () => {
|
|
1249
1249
|
const error = new SlackError('test error', 'test_code')
|
|
1250
1250
|
expect(error).toBeInstanceOf(Error)
|
|
1251
1251
|
expect(error).toBeInstanceOf(SlackError)
|
|
1252
1252
|
})
|
|
1253
1253
|
|
|
1254
|
-
|
|
1254
|
+
it('has message and code properties', () => {
|
|
1255
1255
|
const error = new SlackError('test error', 'test_code')
|
|
1256
1256
|
expect(error.message).toBe('test error')
|
|
1257
1257
|
expect(error.code).toBe('test_code')
|
|
1258
1258
|
})
|
|
1259
1259
|
|
|
1260
|
-
|
|
1260
|
+
it('has name property set to SlackError', () => {
|
|
1261
1261
|
const error = new SlackError('test error', 'test_code')
|
|
1262
1262
|
expect(error.name).toBe('SlackError')
|
|
1263
1263
|
})
|
|
@@ -1553,7 +1553,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1553
1553
|
}
|
|
1554
1554
|
|
|
1555
1555
|
describe('mid-surface methods', () => {
|
|
1556
|
-
|
|
1556
|
+
it('lists DMs and respects includeArchived option', async () => {
|
|
1557
1557
|
const { client, mock } = await makeClient()
|
|
1558
1558
|
mock.conversations.list.mockResolvedValueOnce({
|
|
1559
1559
|
ok: true,
|
|
@@ -1577,7 +1577,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1577
1577
|
})
|
|
1578
1578
|
})
|
|
1579
1579
|
|
|
1580
|
-
|
|
1580
|
+
it('maps unread counts and totals', async () => {
|
|
1581
1581
|
const { client, mock } = await makeClient()
|
|
1582
1582
|
mock.apiCall.mockImplementation((method: string) => {
|
|
1583
1583
|
if (method === 'client.counts') {
|
|
@@ -1602,7 +1602,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1602
1602
|
expect(counts.total_mentions).toBe(1)
|
|
1603
1603
|
})
|
|
1604
1604
|
|
|
1605
|
-
|
|
1605
|
+
it('maps thread view from subscriptions API', async () => {
|
|
1606
1606
|
const { client, mock } = await makeClient()
|
|
1607
1607
|
mock.subscriptions.thread.getView.mockResolvedValue({
|
|
1608
1608
|
ok: true,
|
|
@@ -1630,7 +1630,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1630
1630
|
})
|
|
1631
1631
|
})
|
|
1632
1632
|
|
|
1633
|
-
|
|
1633
|
+
it('marks a channel as read', async () => {
|
|
1634
1634
|
const { client, mock } = await makeClient()
|
|
1635
1635
|
|
|
1636
1636
|
await client.markRead('C001', '123.456')
|
|
@@ -1638,7 +1638,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1638
1638
|
expect(mock.conversations.mark).toHaveBeenCalledWith({ channel: 'C001', ts: '123.456' })
|
|
1639
1639
|
})
|
|
1640
1640
|
|
|
1641
|
-
|
|
1641
|
+
it('maps activity feed and passes custom options', async () => {
|
|
1642
1642
|
const { client, mock } = await makeClient()
|
|
1643
1643
|
mock.apiCall.mockImplementation((method: string, args?: Record<string, unknown>) => {
|
|
1644
1644
|
if (method === 'activity.feed') {
|
|
@@ -1680,7 +1680,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1680
1680
|
])
|
|
1681
1681
|
})
|
|
1682
1682
|
|
|
1683
|
-
|
|
1683
|
+
it('maps saved items with pagination metadata', async () => {
|
|
1684
1684
|
const { client, mock } = await makeClient()
|
|
1685
1685
|
mock.apiCall.mockImplementation((method: string) => {
|
|
1686
1686
|
if (method === 'saved.list') {
|
|
@@ -1737,7 +1737,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1737
1737
|
})
|
|
1738
1738
|
})
|
|
1739
1739
|
|
|
1740
|
-
|
|
1740
|
+
it('maps channel sections', async () => {
|
|
1741
1741
|
const { client, mock } = await makeClient()
|
|
1742
1742
|
mock.apiCall.mockImplementation((method: string) => {
|
|
1743
1743
|
if (method === 'users.channelSections.list') {
|
|
@@ -1770,7 +1770,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1770
1770
|
])
|
|
1771
1771
|
})
|
|
1772
1772
|
|
|
1773
|
-
|
|
1773
|
+
it('opens a conversation and returns open status', async () => {
|
|
1774
1774
|
const { client, mock } = await makeClient()
|
|
1775
1775
|
mock.conversations.open.mockResolvedValue({
|
|
1776
1776
|
ok: true,
|
|
@@ -1784,7 +1784,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1784
1784
|
expect(mock.conversations.open).toHaveBeenCalledWith({ users: 'U001,U002' })
|
|
1785
1785
|
})
|
|
1786
1786
|
|
|
1787
|
-
|
|
1787
|
+
it('maps drafts and next cursor', async () => {
|
|
1788
1788
|
const { client, mock } = await makeClient()
|
|
1789
1789
|
mock.apiCall.mockImplementation((method: string) => {
|
|
1790
1790
|
if (method === 'drafts.list') {
|
|
@@ -1821,7 +1821,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1821
1821
|
})
|
|
1822
1822
|
})
|
|
1823
1823
|
|
|
1824
|
-
|
|
1824
|
+
it('returns RTM connection info with stored cookie', async () => {
|
|
1825
1825
|
const { client, mock } = await makeClient()
|
|
1826
1826
|
mock.apiCall.mockImplementation((method: string) => {
|
|
1827
1827
|
if (method === 'rtm.connect') {
|
|
@@ -1847,13 +1847,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1847
1847
|
})
|
|
1848
1848
|
|
|
1849
1849
|
describe('pinMessage', () => {
|
|
1850
|
-
|
|
1850
|
+
it('calls pins.add with correct args', async () => {
|
|
1851
1851
|
const { client, mock } = await makeClient()
|
|
1852
1852
|
await client.pinMessage('C001', '123.456')
|
|
1853
1853
|
expect(mock.pins.add).toHaveBeenCalledWith({ channel: 'C001', timestamp: '123.456' })
|
|
1854
1854
|
})
|
|
1855
1855
|
|
|
1856
|
-
|
|
1856
|
+
it('throws SlackError on API failure', async () => {
|
|
1857
1857
|
const { client, mock } = await makeClient()
|
|
1858
1858
|
mock.pins.add.mockResolvedValue({ ok: false, error: 'not_pinned' })
|
|
1859
1859
|
await expect(client.pinMessage('C001', '123.456')).rejects.toThrow(SlackError)
|
|
@@ -1861,13 +1861,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1861
1861
|
})
|
|
1862
1862
|
|
|
1863
1863
|
describe('unpinMessage', () => {
|
|
1864
|
-
|
|
1864
|
+
it('calls pins.remove with correct args', async () => {
|
|
1865
1865
|
const { client, mock } = await makeClient()
|
|
1866
1866
|
await client.unpinMessage('C001', '123.456')
|
|
1867
1867
|
expect(mock.pins.remove).toHaveBeenCalledWith({ channel: 'C001', timestamp: '123.456' })
|
|
1868
1868
|
})
|
|
1869
1869
|
|
|
1870
|
-
|
|
1870
|
+
it('throws SlackError on API failure', async () => {
|
|
1871
1871
|
const { client, mock } = await makeClient()
|
|
1872
1872
|
mock.pins.remove.mockResolvedValue({ ok: false, error: 'no_pin' })
|
|
1873
1873
|
await expect(client.unpinMessage('C001', '123.456')).rejects.toThrow(SlackError)
|
|
@@ -1875,7 +1875,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1875
1875
|
})
|
|
1876
1876
|
|
|
1877
1877
|
describe('listPins', () => {
|
|
1878
|
-
|
|
1878
|
+
it('returns mapped pin items', async () => {
|
|
1879
1879
|
const { client, mock } = await makeClient()
|
|
1880
1880
|
mock.pins.list.mockResolvedValue({
|
|
1881
1881
|
ok: true,
|
|
@@ -1887,7 +1887,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1887
1887
|
expect(pins[0].created_by).toBe('U001')
|
|
1888
1888
|
})
|
|
1889
1889
|
|
|
1890
|
-
|
|
1890
|
+
it('throws SlackError on API failure', async () => {
|
|
1891
1891
|
const { client, mock } = await makeClient()
|
|
1892
1892
|
mock.pins.list.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
1893
1893
|
await expect(client.listPins('C001')).rejects.toThrow(SlackError)
|
|
@@ -1895,14 +1895,14 @@ describe('SlackClient extended methods', () => {
|
|
|
1895
1895
|
})
|
|
1896
1896
|
|
|
1897
1897
|
describe('addBookmark', () => {
|
|
1898
|
-
|
|
1898
|
+
it('calls bookmarks.add and returns bookmark', async () => {
|
|
1899
1899
|
const { client } = await makeClient()
|
|
1900
1900
|
const result = await client.addBookmark('C001', 'Test', 'https://example.com')
|
|
1901
1901
|
expect(result.id).toBe('Bm001')
|
|
1902
1902
|
expect(result.title).toBe('Test')
|
|
1903
1903
|
})
|
|
1904
1904
|
|
|
1905
|
-
|
|
1905
|
+
it('throws SlackError on API failure', async () => {
|
|
1906
1906
|
const { client, mock } = await makeClient()
|
|
1907
1907
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
1908
1908
|
await expect(client.addBookmark('C001', 'Test', 'https://example.com')).rejects.toThrow(SlackError)
|
|
@@ -1910,13 +1910,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1910
1910
|
})
|
|
1911
1911
|
|
|
1912
1912
|
describe('editBookmark', () => {
|
|
1913
|
-
|
|
1913
|
+
it('calls bookmarks.edit and returns updated bookmark', async () => {
|
|
1914
1914
|
const { client } = await makeClient()
|
|
1915
1915
|
const result = await client.editBookmark('C001', 'Bm001', { title: 'Updated' })
|
|
1916
1916
|
expect(result.title).toBe('Updated')
|
|
1917
1917
|
})
|
|
1918
1918
|
|
|
1919
|
-
|
|
1919
|
+
it('throws SlackError on API failure', async () => {
|
|
1920
1920
|
const { client, mock } = await makeClient()
|
|
1921
1921
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'bookmark_not_found' })
|
|
1922
1922
|
await expect(client.editBookmark('C001', 'Bm001', { title: 'X' })).rejects.toThrow(SlackError)
|
|
@@ -1924,13 +1924,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1924
1924
|
})
|
|
1925
1925
|
|
|
1926
1926
|
describe('removeBookmark', () => {
|
|
1927
|
-
|
|
1927
|
+
it('calls bookmarks.remove successfully', async () => {
|
|
1928
1928
|
const { client, mock } = await makeClient()
|
|
1929
1929
|
await client.removeBookmark('C001', 'Bm001')
|
|
1930
1930
|
expect(mock.apiCall).toHaveBeenCalledWith('bookmarks.remove', { channel_id: 'C001', bookmark_id: 'Bm001' })
|
|
1931
1931
|
})
|
|
1932
1932
|
|
|
1933
|
-
|
|
1933
|
+
it('throws SlackError on API failure', async () => {
|
|
1934
1934
|
const { client, mock } = await makeClient()
|
|
1935
1935
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'bookmark_not_found' })
|
|
1936
1936
|
await expect(client.removeBookmark('C001', 'Bm001')).rejects.toThrow(SlackError)
|
|
@@ -1938,13 +1938,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1938
1938
|
})
|
|
1939
1939
|
|
|
1940
1940
|
describe('listBookmarks', () => {
|
|
1941
|
-
|
|
1941
|
+
it('returns empty array when no bookmarks', async () => {
|
|
1942
1942
|
const { client } = await makeClient()
|
|
1943
1943
|
const result = await client.listBookmarks('C001')
|
|
1944
1944
|
expect(result).toHaveLength(0)
|
|
1945
1945
|
})
|
|
1946
1946
|
|
|
1947
|
-
|
|
1947
|
+
it('throws SlackError on API failure', async () => {
|
|
1948
1948
|
const { client, mock } = await makeClient()
|
|
1949
1949
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
1950
1950
|
await expect(client.listBookmarks('C001')).rejects.toThrow(SlackError)
|
|
@@ -1952,7 +1952,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1952
1952
|
})
|
|
1953
1953
|
|
|
1954
1954
|
describe('scheduleMessage', () => {
|
|
1955
|
-
|
|
1955
|
+
it('returns scheduled message with id', async () => {
|
|
1956
1956
|
const { client } = await makeClient()
|
|
1957
1957
|
const result = await client.scheduleMessage('C001', 'Hello', 1700000000)
|
|
1958
1958
|
expect(result.id).toBe('SM001')
|
|
@@ -1960,7 +1960,7 @@ describe('SlackClient extended methods', () => {
|
|
|
1960
1960
|
expect(result.channel_id).toBe('C001')
|
|
1961
1961
|
})
|
|
1962
1962
|
|
|
1963
|
-
|
|
1963
|
+
it('throws SlackError on API failure', async () => {
|
|
1964
1964
|
const { client, mock } = await makeClient()
|
|
1965
1965
|
mock.chat.scheduleMessage.mockResolvedValue({ ok: false, error: 'invalid_time' })
|
|
1966
1966
|
await expect(client.scheduleMessage('C001', 'Hello', 1700000000)).rejects.toThrow(SlackError)
|
|
@@ -1968,13 +1968,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1968
1968
|
})
|
|
1969
1969
|
|
|
1970
1970
|
describe('listScheduledMessages', () => {
|
|
1971
|
-
|
|
1971
|
+
it('returns empty array when no scheduled messages', async () => {
|
|
1972
1972
|
const { client } = await makeClient()
|
|
1973
1973
|
const result = await client.listScheduledMessages()
|
|
1974
1974
|
expect(result).toHaveLength(0)
|
|
1975
1975
|
})
|
|
1976
1976
|
|
|
1977
|
-
|
|
1977
|
+
it('throws SlackError on API failure', async () => {
|
|
1978
1978
|
const { client, mock } = await makeClient()
|
|
1979
1979
|
mock.chat.scheduledMessages.list.mockResolvedValue({ ok: false, error: 'invalid_auth' })
|
|
1980
1980
|
await expect(client.listScheduledMessages()).rejects.toThrow(SlackError)
|
|
@@ -1982,13 +1982,13 @@ describe('SlackClient extended methods', () => {
|
|
|
1982
1982
|
})
|
|
1983
1983
|
|
|
1984
1984
|
describe('deleteScheduledMessage', () => {
|
|
1985
|
-
|
|
1985
|
+
it('calls deleteScheduledMessage with correct args', async () => {
|
|
1986
1986
|
const { client, mock } = await makeClient()
|
|
1987
1987
|
await client.deleteScheduledMessage('C001', 'SM001')
|
|
1988
1988
|
expect(mock.chat.deleteScheduledMessage).toHaveBeenCalledWith({ channel: 'C001', scheduled_message_id: 'SM001' })
|
|
1989
1989
|
})
|
|
1990
1990
|
|
|
1991
|
-
|
|
1991
|
+
it('throws SlackError on API failure', async () => {
|
|
1992
1992
|
const { client, mock } = await makeClient()
|
|
1993
1993
|
mock.chat.deleteScheduledMessage.mockResolvedValue({ ok: false, error: 'invalid_scheduled_message_id' })
|
|
1994
1994
|
await expect(client.deleteScheduledMessage('C001', 'SM001')).rejects.toThrow(SlackError)
|
|
@@ -1996,14 +1996,14 @@ describe('SlackClient extended methods', () => {
|
|
|
1996
1996
|
})
|
|
1997
1997
|
|
|
1998
1998
|
describe('createChannel', () => {
|
|
1999
|
-
|
|
1999
|
+
it('returns created channel', async () => {
|
|
2000
2000
|
const { client } = await makeClient()
|
|
2001
2001
|
const ch = await client.createChannel('new-channel')
|
|
2002
2002
|
expect(ch.id).toBe('C001')
|
|
2003
2003
|
expect(ch.name).toBe('test')
|
|
2004
2004
|
})
|
|
2005
2005
|
|
|
2006
|
-
|
|
2006
|
+
it('throws SlackError on API failure', async () => {
|
|
2007
2007
|
const { client, mock } = await makeClient()
|
|
2008
2008
|
mock.conversations.create.mockResolvedValue({ ok: false, error: 'name_taken' })
|
|
2009
2009
|
await expect(client.createChannel('existing')).rejects.toThrow(SlackError)
|
|
@@ -2011,13 +2011,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2011
2011
|
})
|
|
2012
2012
|
|
|
2013
2013
|
describe('archiveChannel', () => {
|
|
2014
|
-
|
|
2014
|
+
it('archives channel successfully', async () => {
|
|
2015
2015
|
const { client, mock } = await makeClient()
|
|
2016
2016
|
await client.archiveChannel('C001')
|
|
2017
2017
|
expect(mock.conversations.archive).toHaveBeenCalledWith({ channel: 'C001' })
|
|
2018
2018
|
})
|
|
2019
2019
|
|
|
2020
|
-
|
|
2020
|
+
it('throws SlackError on API failure', async () => {
|
|
2021
2021
|
const { client, mock } = await makeClient()
|
|
2022
2022
|
mock.conversations.archive.mockResolvedValue({ ok: false, error: 'already_archived' })
|
|
2023
2023
|
await expect(client.archiveChannel('C001')).rejects.toThrow(SlackError)
|
|
@@ -2025,13 +2025,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2025
2025
|
})
|
|
2026
2026
|
|
|
2027
2027
|
describe('setChannelTopic', () => {
|
|
2028
|
-
|
|
2028
|
+
it('returns new topic', async () => {
|
|
2029
2029
|
const { client } = await makeClient()
|
|
2030
2030
|
const result = await client.setChannelTopic('C001', 'new-topic')
|
|
2031
2031
|
expect(result.topic).toBe('new-topic')
|
|
2032
2032
|
})
|
|
2033
2033
|
|
|
2034
|
-
|
|
2034
|
+
it('throws SlackError on API failure', async () => {
|
|
2035
2035
|
const { client, mock } = await makeClient()
|
|
2036
2036
|
mock.conversations.setTopic.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
2037
2037
|
await expect(client.setChannelTopic('C001', 'topic')).rejects.toThrow(SlackError)
|
|
@@ -2039,13 +2039,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2039
2039
|
})
|
|
2040
2040
|
|
|
2041
2041
|
describe('setChannelPurpose', () => {
|
|
2042
|
-
|
|
2042
|
+
it('returns new purpose', async () => {
|
|
2043
2043
|
const { client } = await makeClient()
|
|
2044
2044
|
const result = await client.setChannelPurpose('C001', 'new-purpose')
|
|
2045
2045
|
expect(result.purpose).toBe('new-purpose')
|
|
2046
2046
|
})
|
|
2047
2047
|
|
|
2048
|
-
|
|
2048
|
+
it('throws SlackError on API failure', async () => {
|
|
2049
2049
|
const { client, mock } = await makeClient()
|
|
2050
2050
|
mock.conversations.setPurpose.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
2051
2051
|
await expect(client.setChannelPurpose('C001', 'purpose')).rejects.toThrow(SlackError)
|
|
@@ -2053,13 +2053,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2053
2053
|
})
|
|
2054
2054
|
|
|
2055
2055
|
describe('inviteToChannel', () => {
|
|
2056
|
-
|
|
2056
|
+
it('returns channel after invite', async () => {
|
|
2057
2057
|
const { client } = await makeClient()
|
|
2058
2058
|
const ch = await client.inviteToChannel('C001', 'U002')
|
|
2059
2059
|
expect(ch.id).toBe('C001')
|
|
2060
2060
|
})
|
|
2061
2061
|
|
|
2062
|
-
|
|
2062
|
+
it('throws SlackError on API failure', async () => {
|
|
2063
2063
|
const { client, mock } = await makeClient()
|
|
2064
2064
|
mock.conversations.invite.mockResolvedValue({ ok: false, error: 'user_not_found' })
|
|
2065
2065
|
await expect(client.inviteToChannel('C001', 'U999')).rejects.toThrow(SlackError)
|
|
@@ -2067,13 +2067,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2067
2067
|
})
|
|
2068
2068
|
|
|
2069
2069
|
describe('joinChannel', () => {
|
|
2070
|
-
|
|
2070
|
+
it('returns channel after joining', async () => {
|
|
2071
2071
|
const { client } = await makeClient()
|
|
2072
2072
|
const ch = await client.joinChannel('C001')
|
|
2073
2073
|
expect(ch.id).toBe('C001')
|
|
2074
2074
|
})
|
|
2075
2075
|
|
|
2076
|
-
|
|
2076
|
+
it('throws SlackError on API failure', async () => {
|
|
2077
2077
|
const { client, mock } = await makeClient()
|
|
2078
2078
|
mock.conversations.join.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
2079
2079
|
await expect(client.joinChannel('C001')).rejects.toThrow(SlackError)
|
|
@@ -2081,13 +2081,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2081
2081
|
})
|
|
2082
2082
|
|
|
2083
2083
|
describe('leaveChannel', () => {
|
|
2084
|
-
|
|
2084
|
+
it('leaves channel successfully', async () => {
|
|
2085
2085
|
const { client, mock } = await makeClient()
|
|
2086
2086
|
await client.leaveChannel('C001')
|
|
2087
2087
|
expect(mock.conversations.leave).toHaveBeenCalledWith({ channel: 'C001' })
|
|
2088
2088
|
})
|
|
2089
2089
|
|
|
2090
|
-
|
|
2090
|
+
it('throws SlackError on API failure', async () => {
|
|
2091
2091
|
const { client, mock } = await makeClient()
|
|
2092
2092
|
mock.conversations.leave.mockResolvedValue({ ok: false, error: 'channel_not_found' })
|
|
2093
2093
|
await expect(client.leaveChannel('C001')).rejects.toThrow(SlackError)
|
|
@@ -2095,14 +2095,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2095
2095
|
})
|
|
2096
2096
|
|
|
2097
2097
|
describe('lookupUserByEmail', () => {
|
|
2098
|
-
|
|
2098
|
+
it('returns user for given email', async () => {
|
|
2099
2099
|
const { client } = await makeClient()
|
|
2100
2100
|
const user = await client.lookupUserByEmail('test@example.com')
|
|
2101
2101
|
expect(user.id).toBe('U001')
|
|
2102
2102
|
expect(user.name).toBe('test')
|
|
2103
2103
|
})
|
|
2104
2104
|
|
|
2105
|
-
|
|
2105
|
+
it('throws SlackError on API failure', async () => {
|
|
2106
2106
|
const { client, mock } = await makeClient()
|
|
2107
2107
|
mock.users.lookupByEmail.mockResolvedValue({ ok: false, error: 'users_not_found' })
|
|
2108
2108
|
await expect(client.lookupUserByEmail('nobody@example.com')).rejects.toThrow(SlackError)
|
|
@@ -2110,13 +2110,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2110
2110
|
})
|
|
2111
2111
|
|
|
2112
2112
|
describe('getUserProfile', () => {
|
|
2113
|
-
|
|
2113
|
+
it('returns user profile', async () => {
|
|
2114
2114
|
const { client } = await makeClient()
|
|
2115
2115
|
const profile = await client.getUserProfile('U001')
|
|
2116
2116
|
expect(profile.display_name).toBe('Test')
|
|
2117
2117
|
})
|
|
2118
2118
|
|
|
2119
|
-
|
|
2119
|
+
it('throws SlackError on API failure', async () => {
|
|
2120
2120
|
const { client, mock } = await makeClient()
|
|
2121
2121
|
mock.users.profile.get.mockResolvedValue({ ok: false, error: 'user_not_found' })
|
|
2122
2122
|
await expect(client.getUserProfile('U999')).rejects.toThrow(SlackError)
|
|
@@ -2124,13 +2124,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2124
2124
|
})
|
|
2125
2125
|
|
|
2126
2126
|
describe('setUserProfile', () => {
|
|
2127
|
-
|
|
2127
|
+
it('returns updated profile', async () => {
|
|
2128
2128
|
const { client } = await makeClient()
|
|
2129
2129
|
const profile = await client.setUserProfile({ status_text: 'Working', status_emoji: ':computer:' })
|
|
2130
2130
|
expect(profile.status_text).toBe('Working')
|
|
2131
2131
|
})
|
|
2132
2132
|
|
|
2133
|
-
|
|
2133
|
+
it('throws SlackError on API failure', async () => {
|
|
2134
2134
|
const { client, mock } = await makeClient()
|
|
2135
2135
|
mock.users.profile.set.mockResolvedValue({ ok: false, error: 'invalid_profile' })
|
|
2136
2136
|
await expect(client.setUserProfile({ status_text: 'x' })).rejects.toThrow(SlackError)
|
|
@@ -2138,13 +2138,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2138
2138
|
})
|
|
2139
2139
|
|
|
2140
2140
|
describe('postEphemeral', () => {
|
|
2141
|
-
|
|
2141
|
+
it('returns message_ts on success', async () => {
|
|
2142
2142
|
const { client } = await makeClient()
|
|
2143
2143
|
const ts = await client.postEphemeral('C001', 'U001', 'Hello!')
|
|
2144
2144
|
expect(ts).toBe('123.456')
|
|
2145
2145
|
})
|
|
2146
2146
|
|
|
2147
|
-
|
|
2147
|
+
it('throws SlackError on API failure', async () => {
|
|
2148
2148
|
const { client, mock } = await makeClient()
|
|
2149
2149
|
mock.chat.postEphemeral.mockResolvedValue({ ok: false, error: 'user_not_in_channel' })
|
|
2150
2150
|
await expect(client.postEphemeral('C001', 'U001', 'Hello!')).rejects.toThrow(SlackError)
|
|
@@ -2152,13 +2152,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2152
2152
|
})
|
|
2153
2153
|
|
|
2154
2154
|
describe('getPermalink', () => {
|
|
2155
|
-
|
|
2155
|
+
it('returns permalink on success', async () => {
|
|
2156
2156
|
const { client } = await makeClient()
|
|
2157
2157
|
const link = await client.getPermalink('C001', '123.456')
|
|
2158
2158
|
expect(link).toBe('https://slack.com/archives/C001/p123456')
|
|
2159
2159
|
})
|
|
2160
2160
|
|
|
2161
|
-
|
|
2161
|
+
it('throws SlackError on API failure', async () => {
|
|
2162
2162
|
const { client, mock } = await makeClient()
|
|
2163
2163
|
mock.chat.getPermalink.mockResolvedValue({ ok: false, error: 'message_not_found' })
|
|
2164
2164
|
await expect(client.getPermalink('C001', '123.456')).rejects.toThrow(SlackError)
|
|
@@ -2166,14 +2166,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2166
2166
|
})
|
|
2167
2167
|
|
|
2168
2168
|
describe('addReminder', () => {
|
|
2169
|
-
|
|
2169
|
+
it('returns reminder on success', async () => {
|
|
2170
2170
|
const { client } = await makeClient()
|
|
2171
2171
|
const reminder = await client.addReminder('Do something', 1700000000)
|
|
2172
2172
|
expect(reminder.id).toBe('Rm001')
|
|
2173
2173
|
expect(reminder.text).toBe('Test')
|
|
2174
2174
|
})
|
|
2175
2175
|
|
|
2176
|
-
|
|
2176
|
+
it('throws SlackError on API failure', async () => {
|
|
2177
2177
|
const { client, mock } = await makeClient()
|
|
2178
2178
|
mock.reminders.add.mockResolvedValue({ ok: false, error: 'invalid_time' })
|
|
2179
2179
|
await expect(client.addReminder('Do something', 1700000000)).rejects.toThrow(SlackError)
|
|
@@ -2181,13 +2181,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2181
2181
|
})
|
|
2182
2182
|
|
|
2183
2183
|
describe('listReminders', () => {
|
|
2184
|
-
|
|
2184
|
+
it('returns empty array when no reminders', async () => {
|
|
2185
2185
|
const { client } = await makeClient()
|
|
2186
2186
|
const result = await client.listReminders()
|
|
2187
2187
|
expect(result).toHaveLength(0)
|
|
2188
2188
|
})
|
|
2189
2189
|
|
|
2190
|
-
|
|
2190
|
+
it('throws SlackError on API failure', async () => {
|
|
2191
2191
|
const { client, mock } = await makeClient()
|
|
2192
2192
|
mock.reminders.list.mockResolvedValue({ ok: false, error: 'invalid_auth' })
|
|
2193
2193
|
await expect(client.listReminders()).rejects.toThrow(SlackError)
|
|
@@ -2195,13 +2195,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2195
2195
|
})
|
|
2196
2196
|
|
|
2197
2197
|
describe('completeReminder', () => {
|
|
2198
|
-
|
|
2198
|
+
it('completes reminder successfully', async () => {
|
|
2199
2199
|
const { client, mock } = await makeClient()
|
|
2200
2200
|
await client.completeReminder('Rm001')
|
|
2201
2201
|
expect(mock.reminders.complete).toHaveBeenCalledWith({ reminder: 'Rm001' })
|
|
2202
2202
|
})
|
|
2203
2203
|
|
|
2204
|
-
|
|
2204
|
+
it('throws SlackError on API failure', async () => {
|
|
2205
2205
|
const { client, mock } = await makeClient()
|
|
2206
2206
|
mock.reminders.complete.mockResolvedValue({ ok: false, error: 'reminder_not_found' })
|
|
2207
2207
|
await expect(client.completeReminder('Rm999')).rejects.toThrow(SlackError)
|
|
@@ -2209,13 +2209,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2209
2209
|
})
|
|
2210
2210
|
|
|
2211
2211
|
describe('deleteReminder', () => {
|
|
2212
|
-
|
|
2212
|
+
it('deletes reminder successfully', async () => {
|
|
2213
2213
|
const { client, mock } = await makeClient()
|
|
2214
2214
|
await client.deleteReminder('Rm001')
|
|
2215
2215
|
expect(mock.reminders.delete).toHaveBeenCalledWith({ reminder: 'Rm001' })
|
|
2216
2216
|
})
|
|
2217
2217
|
|
|
2218
|
-
|
|
2218
|
+
it('throws SlackError on API failure', async () => {
|
|
2219
2219
|
const { client, mock } = await makeClient()
|
|
2220
2220
|
mock.reminders.delete.mockResolvedValue({ ok: false, error: 'reminder_not_found' })
|
|
2221
2221
|
await expect(client.deleteReminder('Rm999')).rejects.toThrow(SlackError)
|
|
@@ -2223,13 +2223,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2223
2223
|
})
|
|
2224
2224
|
|
|
2225
2225
|
describe('deleteFile', () => {
|
|
2226
|
-
|
|
2226
|
+
it('deletes file successfully', async () => {
|
|
2227
2227
|
const { client, mock } = await makeClient()
|
|
2228
2228
|
await client.deleteFile('F001')
|
|
2229
2229
|
expect(mock.files.delete).toHaveBeenCalledWith({ file: 'F001' })
|
|
2230
2230
|
})
|
|
2231
2231
|
|
|
2232
|
-
|
|
2232
|
+
it('throws SlackError on API failure', async () => {
|
|
2233
2233
|
const { client, mock } = await makeClient()
|
|
2234
2234
|
mock.files.delete.mockResolvedValue({ ok: false, error: 'file_not_found' })
|
|
2235
2235
|
await expect(client.deleteFile('F999')).rejects.toThrow(SlackError)
|
|
@@ -2237,13 +2237,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2237
2237
|
})
|
|
2238
2238
|
|
|
2239
2239
|
describe('listEmoji', () => {
|
|
2240
|
-
|
|
2240
|
+
it('returns emoji map on success', async () => {
|
|
2241
2241
|
const { client } = await makeClient()
|
|
2242
2242
|
const emoji = await client.listEmoji()
|
|
2243
2243
|
expect(emoji['party_blob']).toBe('https://example.com/party_blob.gif')
|
|
2244
2244
|
})
|
|
2245
2245
|
|
|
2246
|
-
|
|
2246
|
+
it('throws SlackError on API failure', async () => {
|
|
2247
2247
|
const { client, mock } = await makeClient()
|
|
2248
2248
|
mock.emoji.list.mockResolvedValue({ ok: false, error: 'invalid_auth' })
|
|
2249
2249
|
await expect(client.listEmoji()).rejects.toThrow(SlackError)
|
|
@@ -2251,7 +2251,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2251
2251
|
})
|
|
2252
2252
|
|
|
2253
2253
|
describe('listUsergroups', () => {
|
|
2254
|
-
|
|
2254
|
+
it('returns mapped usergroups', async () => {
|
|
2255
2255
|
const { client } = await makeClient()
|
|
2256
2256
|
const groups = await client.listUsergroups({ includeCount: true })
|
|
2257
2257
|
expect(groups).toHaveLength(1)
|
|
@@ -2261,7 +2261,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2261
2261
|
expect(groups[0].user_count).toBe(1)
|
|
2262
2262
|
})
|
|
2263
2263
|
|
|
2264
|
-
|
|
2264
|
+
it('calls apiCall with correct params', async () => {
|
|
2265
2265
|
const { client, mock } = await makeClient()
|
|
2266
2266
|
await client.listUsergroups({ includeDisabled: true, includeUsers: true, includeCount: true })
|
|
2267
2267
|
expect(mock.apiCall).toHaveBeenCalledWith('usergroups.list', {
|
|
@@ -2271,7 +2271,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2271
2271
|
})
|
|
2272
2272
|
})
|
|
2273
2273
|
|
|
2274
|
-
|
|
2274
|
+
it('throws SlackError on API failure', async () => {
|
|
2275
2275
|
const { client, mock } = await makeClient()
|
|
2276
2276
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'invalid_auth' })
|
|
2277
2277
|
await expect(client.listUsergroups()).rejects.toThrow(SlackError)
|
|
@@ -2279,14 +2279,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2279
2279
|
})
|
|
2280
2280
|
|
|
2281
2281
|
describe('createUsergroup', () => {
|
|
2282
|
-
|
|
2282
|
+
it('returns created usergroup', async () => {
|
|
2283
2283
|
const { client } = await makeClient()
|
|
2284
2284
|
const group = await client.createUsergroup('Marketing', { handle: 'marketing' })
|
|
2285
2285
|
expect(group.id).toBe('S002')
|
|
2286
2286
|
expect(group.name).toBe('Marketing')
|
|
2287
2287
|
})
|
|
2288
2288
|
|
|
2289
|
-
|
|
2289
|
+
it('calls apiCall with correct params including channels', async () => {
|
|
2290
2290
|
const { client, mock } = await makeClient()
|
|
2291
2291
|
await client.createUsergroup('Marketing', {
|
|
2292
2292
|
handle: 'marketing',
|
|
@@ -2301,7 +2301,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2301
2301
|
})
|
|
2302
2302
|
})
|
|
2303
2303
|
|
|
2304
|
-
|
|
2304
|
+
it('throws SlackError on API failure', async () => {
|
|
2305
2305
|
const { client, mock } = await makeClient()
|
|
2306
2306
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'name_already_exists' })
|
|
2307
2307
|
await expect(client.createUsergroup('Dup')).rejects.toThrow(SlackError)
|
|
@@ -2309,14 +2309,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2309
2309
|
})
|
|
2310
2310
|
|
|
2311
2311
|
describe('updateUsergroup', () => {
|
|
2312
|
-
|
|
2312
|
+
it('returns updated usergroup', async () => {
|
|
2313
2313
|
const { client } = await makeClient()
|
|
2314
2314
|
const group = await client.updateUsergroup('S001', { name: 'Updated', handle: 'updated' })
|
|
2315
2315
|
expect(group.name).toBe('Updated')
|
|
2316
2316
|
expect(group.handle).toBe('updated')
|
|
2317
2317
|
})
|
|
2318
2318
|
|
|
2319
|
-
|
|
2319
|
+
it('calls apiCall with correct params', async () => {
|
|
2320
2320
|
const { client, mock } = await makeClient()
|
|
2321
2321
|
await client.updateUsergroup('S001', { name: 'New', channels: ['C001'] })
|
|
2322
2322
|
expect(mock.apiCall).toHaveBeenCalledWith('usergroups.update', {
|
|
@@ -2328,7 +2328,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2328
2328
|
})
|
|
2329
2329
|
})
|
|
2330
2330
|
|
|
2331
|
-
|
|
2331
|
+
it('throws SlackError on API failure', async () => {
|
|
2332
2332
|
const { client, mock } = await makeClient()
|
|
2333
2333
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'no_such_subteam' })
|
|
2334
2334
|
await expect(client.updateUsergroup('S999', { name: 'X' })).rejects.toThrow(SlackError)
|
|
@@ -2336,14 +2336,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2336
2336
|
})
|
|
2337
2337
|
|
|
2338
2338
|
describe('disableUsergroup', () => {
|
|
2339
|
-
|
|
2339
|
+
it('returns disabled usergroup with date_delete set', async () => {
|
|
2340
2340
|
const { client } = await makeClient()
|
|
2341
2341
|
const group = await client.disableUsergroup('S001')
|
|
2342
2342
|
expect(group.id).toBe('S001')
|
|
2343
2343
|
expect(group.date_delete).toBeGreaterThan(0)
|
|
2344
2344
|
})
|
|
2345
2345
|
|
|
2346
|
-
|
|
2346
|
+
it('throws SlackError on API failure', async () => {
|
|
2347
2347
|
const { client, mock } = await makeClient()
|
|
2348
2348
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'no_such_subteam' })
|
|
2349
2349
|
await expect(client.disableUsergroup('S999')).rejects.toThrow(SlackError)
|
|
@@ -2351,14 +2351,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2351
2351
|
})
|
|
2352
2352
|
|
|
2353
2353
|
describe('enableUsergroup', () => {
|
|
2354
|
-
|
|
2354
|
+
it('returns enabled usergroup with date_delete cleared', async () => {
|
|
2355
2355
|
const { client } = await makeClient()
|
|
2356
2356
|
const group = await client.enableUsergroup('S001')
|
|
2357
2357
|
expect(group.id).toBe('S001')
|
|
2358
2358
|
expect(group.date_delete).toBe(0)
|
|
2359
2359
|
})
|
|
2360
2360
|
|
|
2361
|
-
|
|
2361
|
+
it('throws SlackError on API failure', async () => {
|
|
2362
2362
|
const { client, mock } = await makeClient()
|
|
2363
2363
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'no_such_subteam' })
|
|
2364
2364
|
await expect(client.enableUsergroup('S999')).rejects.toThrow(SlackError)
|
|
@@ -2366,13 +2366,13 @@ describe('SlackClient extended methods', () => {
|
|
|
2366
2366
|
})
|
|
2367
2367
|
|
|
2368
2368
|
describe('listUsergroupMembers', () => {
|
|
2369
|
-
|
|
2369
|
+
it('returns user ID array', async () => {
|
|
2370
2370
|
const { client } = await makeClient()
|
|
2371
2371
|
const users = await client.listUsergroupMembers('S001')
|
|
2372
2372
|
expect(users).toEqual(['U001', 'U002'])
|
|
2373
2373
|
})
|
|
2374
2374
|
|
|
2375
|
-
|
|
2375
|
+
it('calls apiCall with correct params', async () => {
|
|
2376
2376
|
const { client, mock } = await makeClient()
|
|
2377
2377
|
await client.listUsergroupMembers('S001', { includeDisabled: true })
|
|
2378
2378
|
expect(mock.apiCall).toHaveBeenCalledWith('usergroups.users.list', {
|
|
@@ -2381,7 +2381,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2381
2381
|
})
|
|
2382
2382
|
})
|
|
2383
2383
|
|
|
2384
|
-
|
|
2384
|
+
it('throws SlackError on API failure', async () => {
|
|
2385
2385
|
const { client, mock } = await makeClient()
|
|
2386
2386
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'no_such_subteam' })
|
|
2387
2387
|
await expect(client.listUsergroupMembers('S999')).rejects.toThrow(SlackError)
|
|
@@ -2389,14 +2389,14 @@ describe('SlackClient extended methods', () => {
|
|
|
2389
2389
|
})
|
|
2390
2390
|
|
|
2391
2391
|
describe('updateUsergroupMembers', () => {
|
|
2392
|
-
|
|
2392
|
+
it('returns updated usergroup with new members', async () => {
|
|
2393
2393
|
const { client } = await makeClient()
|
|
2394
2394
|
const group = await client.updateUsergroupMembers('S001', ['U001', 'U003'])
|
|
2395
2395
|
expect(group.users).toEqual(['U001', 'U003'])
|
|
2396
2396
|
expect(group.user_count).toBe(2)
|
|
2397
2397
|
})
|
|
2398
2398
|
|
|
2399
|
-
|
|
2399
|
+
it('calls apiCall with comma-joined user IDs', async () => {
|
|
2400
2400
|
const { client, mock } = await makeClient()
|
|
2401
2401
|
await client.updateUsergroupMembers('S001', ['U001', 'U003'])
|
|
2402
2402
|
expect(mock.apiCall).toHaveBeenCalledWith('usergroups.users.update', {
|
|
@@ -2405,7 +2405,7 @@ describe('SlackClient extended methods', () => {
|
|
|
2405
2405
|
})
|
|
2406
2406
|
})
|
|
2407
2407
|
|
|
2408
|
-
|
|
2408
|
+
it('throws SlackError on API failure', async () => {
|
|
2409
2409
|
const { client, mock } = await makeClient()
|
|
2410
2410
|
mock.apiCall.mockResolvedValue({ ok: false, error: 'no_users_provided' })
|
|
2411
2411
|
await expect(client.updateUsergroupMembers('S001', [])).rejects.toThrow(SlackError)
|