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, beforeEach, expect, mock, spyOn,
|
|
1
|
+
import { afterEach, beforeEach, expect, mock, spyOn, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { TeamsClient } from '../client'
|
|
4
4
|
import { TeamsCredentialManager } from '../credential-manager'
|
|
@@ -69,7 +69,7 @@ afterEach(() => {
|
|
|
69
69
|
console.log = originalConsoleLog
|
|
70
70
|
})
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
it('send: returns message with id', async () => {
|
|
73
73
|
const consoleSpy = mock((_msg: string) => {})
|
|
74
74
|
console.log = consoleSpy
|
|
75
75
|
|
|
@@ -80,7 +80,7 @@ test('send: returns message with id', async () => {
|
|
|
80
80
|
expect(output).toContain('msg_123')
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
it('list: returns array of messages', async () => {
|
|
84
84
|
const consoleSpy = mock((_msg: string) => {})
|
|
85
85
|
console.log = consoleSpy
|
|
86
86
|
|
|
@@ -92,7 +92,7 @@ test('list: returns array of messages', async () => {
|
|
|
92
92
|
expect(output).toContain('msg_124')
|
|
93
93
|
})
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
it('get: returns single message', async () => {
|
|
96
96
|
const consoleSpy = mock((_msg: string) => {})
|
|
97
97
|
console.log = consoleSpy
|
|
98
98
|
|
|
@@ -103,7 +103,7 @@ test('get: returns single message', async () => {
|
|
|
103
103
|
expect(output).toContain('msg_123')
|
|
104
104
|
})
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
it('delete: returns success', async () => {
|
|
107
107
|
const consoleSpy = mock((_msg: string) => {})
|
|
108
108
|
console.log = consoleSpy
|
|
109
109
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, beforeEach, expect, spyOn,
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { TeamsClient } from '../client'
|
|
4
4
|
import { TeamsCredentialManager } from '../credential-manager'
|
|
@@ -31,7 +31,7 @@ afterEach(() => {
|
|
|
31
31
|
processExitSpy.mockRestore()
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
it('add: sends correct POST request with emoji', async () => {
|
|
35
35
|
try {
|
|
36
36
|
await addAction('team123', 'ch123', 'msg123', 'like', { pretty: false })
|
|
37
37
|
} catch {}
|
|
@@ -45,7 +45,7 @@ test('add: sends correct POST request with emoji', async () => {
|
|
|
45
45
|
expect(output.emoji).toBe('like')
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
it('remove: sends correct DELETE request with emoji', async () => {
|
|
49
49
|
try {
|
|
50
50
|
await removeAction('team123', 'ch123', 'msg123', 'like', { pretty: false })
|
|
51
51
|
} catch {}
|
|
@@ -59,7 +59,7 @@ test('remove: sends correct DELETE request with emoji', async () => {
|
|
|
59
59
|
expect(output.emoji).toBe('like')
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
it('add: handles missing token gracefully', async () => {
|
|
63
63
|
getTokenWithExpirySpy.mockImplementation(() => Promise.resolve(null))
|
|
64
64
|
|
|
65
65
|
try {
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { expect,
|
|
1
|
+
import { expect, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { snapshotCommand } from './snapshot'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
it('snapshot: command is defined', () => {
|
|
6
6
|
expect(snapshotCommand).toBeDefined()
|
|
7
7
|
expect(snapshotCommand.name()).toBe('snapshot')
|
|
8
8
|
})
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
it('snapshot: command has correct description', () => {
|
|
11
11
|
expect(snapshotCommand.description()).toContain('team overview')
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
it('snapshot: command has --channels-only option', () => {
|
|
15
15
|
const options = snapshotCommand.options
|
|
16
16
|
const channelsOnlyOption = options.find((opt) => opt.long === '--channels-only')
|
|
17
17
|
expect(channelsOnlyOption).toBeDefined()
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
it('snapshot: command has --users-only option', () => {
|
|
21
21
|
const options = snapshotCommand.options
|
|
22
22
|
const usersOnlyOption = options.find((opt) => opt.long === '--users-only')
|
|
23
23
|
expect(usersOnlyOption).toBeDefined()
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
it('snapshot: command has --limit option', () => {
|
|
27
27
|
const options = snapshotCommand.options
|
|
28
28
|
const limitOption = options.find((opt) => opt.long === '--limit')
|
|
29
29
|
expect(limitOption).toBeDefined()
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
it('snapshot: command has --team-id option', () => {
|
|
33
33
|
const options = snapshotCommand.options
|
|
34
34
|
const teamIdOption = options.find((opt) => opt.long === '--team-id')
|
|
35
35
|
expect(teamIdOption).toBeDefined()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, beforeEach, expect, spyOn,
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { TeamsClient } from '../client'
|
|
4
4
|
import { TeamsCredentialManager } from '../credential-manager'
|
|
@@ -60,7 +60,7 @@ afterEach(() => {
|
|
|
60
60
|
credManagerSaveConfigSpy?.mockRestore()
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
it('list: returns teams with current marker', async () => {
|
|
64
64
|
// given: credential manager with teams
|
|
65
65
|
const credManager = new TeamsCredentialManager()
|
|
66
66
|
const config = await credManager.loadConfig()
|
|
@@ -75,7 +75,7 @@ test('list: returns teams with current marker', async () => {
|
|
|
75
75
|
expect(account.teams['team-2']).toBeDefined()
|
|
76
76
|
})
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
it('list: marks current team', async () => {
|
|
79
79
|
// given: credential manager with current team set
|
|
80
80
|
const credManager = new TeamsCredentialManager()
|
|
81
81
|
const config = await credManager.loadConfig()
|
|
@@ -88,7 +88,7 @@ test('list: marks current team', async () => {
|
|
|
88
88
|
expect(config!.accounts.work.current_team).toBe('team-1')
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
it('info: returns team details', async () => {
|
|
92
92
|
// given: teams client with team data
|
|
93
93
|
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
94
94
|
const team = await client.getTeam('team-1')
|
|
@@ -102,7 +102,7 @@ test('info: returns team details', async () => {
|
|
|
102
102
|
expect(team.description).toBe('First team')
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
it('info: throws error for non-existent team', async () => {
|
|
106
106
|
// given: teams client
|
|
107
107
|
const client = await new TeamsClient().login({ token: 'test-token', region: 'emea' })
|
|
108
108
|
|
|
@@ -116,7 +116,7 @@ test('info: throws error for non-existent team', async () => {
|
|
|
116
116
|
}
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
it('switch: updates current team', async () => {
|
|
120
120
|
// given: credential manager
|
|
121
121
|
const credManager = new TeamsCredentialManager()
|
|
122
122
|
|
|
@@ -127,7 +127,7 @@ test('switch: updates current team', async () => {
|
|
|
127
127
|
expect(credManager.setCurrentTeam).toHaveBeenCalledWith('team-2', 'Team Two')
|
|
128
128
|
})
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
it('current: returns current team info', async () => {
|
|
131
131
|
// given: credential manager with current team
|
|
132
132
|
const credManager = new TeamsCredentialManager()
|
|
133
133
|
const config = await credManager.loadConfig()
|
|
@@ -140,7 +140,7 @@ test('current: returns current team info', async () => {
|
|
|
140
140
|
expect(config!.accounts.work.current_team).toBe('team-1')
|
|
141
141
|
})
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
it('remove: removes team from config', async () => {
|
|
144
144
|
// given: credential manager with teams
|
|
145
145
|
const credManager = new TeamsCredentialManager()
|
|
146
146
|
const config = await credManager.loadConfig()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expect, mock,
|
|
1
|
+
import { expect, mock, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
// Mock TeamsClient
|
|
4
4
|
const mockClient = {
|
|
@@ -28,7 +28,7 @@ const mockClient = {
|
|
|
28
28
|
]),
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
it('me returns current user info', async () => {
|
|
32
32
|
// given: authenticated user
|
|
33
33
|
const user = await mockClient.testAuth()
|
|
34
34
|
|
|
@@ -46,7 +46,7 @@ test('me returns current user info', async () => {
|
|
|
46
46
|
expect(result.email).toBe('test@example.com')
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
it('info returns user details by id', async () => {
|
|
50
50
|
// given: user id
|
|
51
51
|
const userId = 'user123'
|
|
52
52
|
|
|
@@ -64,7 +64,7 @@ test('info returns user details by id', async () => {
|
|
|
64
64
|
expect(result.displayName).toBe('Test User')
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
it('list returns team members', async () => {
|
|
68
68
|
// given: team id
|
|
69
69
|
const teamId = 'team123'
|
|
70
70
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, beforeEach, expect, spyOn,
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { TeamsClient } from '@/platforms/teams/client'
|
|
4
4
|
import { whoamiAction, whoamiCommand } from '@/platforms/teams/commands/whoami'
|
|
@@ -33,19 +33,19 @@ afterEach(() => {
|
|
|
33
33
|
processExitSpy?.mockRestore()
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
it('whoami command is defined with correct name and description', () => {
|
|
37
37
|
expect(whoamiCommand).toBeDefined()
|
|
38
38
|
expect(whoamiCommand.name()).toBe('whoami')
|
|
39
39
|
expect(whoamiCommand.description()).toBe('Show current authenticated user')
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
it('whoami command has --pretty option', () => {
|
|
43
43
|
const options = whoamiCommand.options
|
|
44
44
|
const hasPretty = options.some((opt: { long?: string }) => opt.long === '--pretty')
|
|
45
45
|
expect(hasPretty).toBe(true)
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
it('whoami outputs id and displayName', async () => {
|
|
49
49
|
await whoamiAction({})
|
|
50
50
|
|
|
51
51
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
@@ -56,7 +56,7 @@ test('whoami outputs id and displayName', async () => {
|
|
|
56
56
|
)
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
it('whoami outputs pretty-printed JSON when pretty is true', async () => {
|
|
60
60
|
await whoamiAction({ pretty: true })
|
|
61
61
|
|
|
62
62
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
@@ -71,7 +71,7 @@ test('whoami outputs pretty-printed JSON when pretty is true', async () => {
|
|
|
71
71
|
)
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
it('whoami exits with error when not authenticated', async () => {
|
|
75
75
|
credManagerSpy.mockResolvedValue(null)
|
|
76
76
|
|
|
77
77
|
await whoamiAction({})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterAll, describe, expect,
|
|
1
|
+
import { afterAll, describe, expect, it } from 'bun:test'
|
|
2
2
|
import { existsSync, rmSync } from 'node:fs'
|
|
3
3
|
import { join } from 'node:path'
|
|
4
4
|
|
|
@@ -19,14 +19,14 @@ afterAll(() => {
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
describe('TeamsCredentialManager', () => {
|
|
22
|
-
|
|
22
|
+
it('loadConfig returns null when file does not exist', async () => {
|
|
23
23
|
const manager = setup()
|
|
24
24
|
const config = await manager.loadConfig()
|
|
25
25
|
|
|
26
26
|
expect(config).toBeNull()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
it('saveConfig creates config file with correct permissions', async () => {
|
|
30
30
|
const testConfigDir = join(
|
|
31
31
|
import.meta.dir,
|
|
32
32
|
`.test-teams-config-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
@@ -58,13 +58,13 @@ describe('TeamsCredentialManager', () => {
|
|
|
58
58
|
expect(loaded).toEqual(config)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
it('getToken returns null when not authenticated', async () => {
|
|
62
62
|
const manager = setup()
|
|
63
63
|
const token = await manager.getToken()
|
|
64
64
|
expect(token).toBeNull()
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
it('setToken saves token to config', async () => {
|
|
68
68
|
const manager = setup()
|
|
69
69
|
await manager.setToken('test-token-123', 'work')
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
72
72
|
expect(token).toBe('test-token-123')
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
it('setToken saves token with expiry', async () => {
|
|
76
76
|
const manager = setup()
|
|
77
77
|
const expiresAt = '2025-12-31T23:59:59Z'
|
|
78
78
|
await manager.setToken('test-token-123', 'work', expiresAt)
|
|
@@ -82,13 +82,13 @@ describe('TeamsCredentialManager', () => {
|
|
|
82
82
|
expect(config?.accounts?.work?.token_expires_at).toBe(expiresAt)
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
it('getCurrentTeam returns null when not set', async () => {
|
|
86
86
|
const manager = setup()
|
|
87
87
|
const team = await manager.getCurrentTeam()
|
|
88
88
|
expect(team).toBeNull()
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
it('getTokenWithExpiry includes region', async () => {
|
|
92
92
|
const manager = setup()
|
|
93
93
|
await manager.saveConfig({
|
|
94
94
|
current_account: 'work',
|
|
@@ -113,7 +113,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
113
113
|
})
|
|
114
114
|
})
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
it('getCurrentTeam returns null when current_team is set but team not in teams record', async () => {
|
|
117
117
|
const manager = setup()
|
|
118
118
|
await manager.setToken('test-token', 'work')
|
|
119
119
|
const config = await manager.loadConfig()
|
|
@@ -126,7 +126,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
126
126
|
expect(team).toBeNull()
|
|
127
127
|
})
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
it('setCurrentTeam saves team info', async () => {
|
|
130
130
|
const manager = setup()
|
|
131
131
|
await manager.setToken('test-token', 'work')
|
|
132
132
|
await manager.setCurrentTeam('team-456', 'My Team')
|
|
@@ -135,7 +135,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
135
135
|
expect(team).toEqual({ team_id: 'team-456', team_name: 'My Team' })
|
|
136
136
|
})
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
it('setCurrentTeam updates existing team', async () => {
|
|
139
139
|
const manager = setup()
|
|
140
140
|
await manager.setToken('test-token', 'work')
|
|
141
141
|
await manager.setCurrentTeam('team-1', 'Team One')
|
|
@@ -149,7 +149,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
149
149
|
expect(config?.accounts?.work?.teams['team-2']).toEqual({ team_id: 'team-2', team_name: 'Team Two' })
|
|
150
150
|
})
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
it('clearCredentials removes all credentials', async () => {
|
|
153
153
|
const manager = setup()
|
|
154
154
|
await manager.setToken('test-token', 'work', '2025-12-31T23:59:59Z')
|
|
155
155
|
await manager.setCurrentTeam('team-123', 'Test Team')
|
|
@@ -160,13 +160,13 @@ describe('TeamsCredentialManager', () => {
|
|
|
160
160
|
expect(config).toBeNull()
|
|
161
161
|
})
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
it('isTokenExpired returns true when no config exists', async () => {
|
|
164
164
|
const manager = setup()
|
|
165
165
|
const expired = await manager.isTokenExpired()
|
|
166
166
|
expect(expired).toBe(true)
|
|
167
167
|
})
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
it('isTokenExpired returns true when no token_expires_at is set', async () => {
|
|
170
170
|
const manager = setup()
|
|
171
171
|
await manager.setToken('test-token', 'work')
|
|
172
172
|
|
|
@@ -174,7 +174,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
174
174
|
expect(expired).toBe(true)
|
|
175
175
|
})
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
it('isTokenExpired returns true when token is expired', async () => {
|
|
178
178
|
const manager = setup()
|
|
179
179
|
const pastDate = new Date(Date.now() - 60000).toISOString()
|
|
180
180
|
await manager.setToken('test-token', 'work', pastDate)
|
|
@@ -183,7 +183,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
183
183
|
expect(expired).toBe(true)
|
|
184
184
|
})
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
it('isTokenExpired returns false when token is not expired', async () => {
|
|
187
187
|
const manager = setup()
|
|
188
188
|
const futureDate = new Date(Date.now() + 3600000).toISOString()
|
|
189
189
|
await manager.setToken('test-token', 'work', futureDate)
|
|
@@ -192,7 +192,7 @@ describe('TeamsCredentialManager', () => {
|
|
|
192
192
|
expect(expired).toBe(false)
|
|
193
193
|
})
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
it('multiple operations preserve existing data', async () => {
|
|
196
196
|
const manager = setup()
|
|
197
197
|
await manager.setToken('token-1', 'work', '2025-12-31T23:59:59Z')
|
|
198
198
|
await manager.setCurrentTeam('team-1', 'Team One')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, spyOn,
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, spyOn, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import { TeamsClient } from './client'
|
|
4
4
|
import { TeamsCredentialManager } from './credential-manager'
|
|
@@ -44,7 +44,7 @@ afterEach(() => {
|
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
describe('ensureTeamsAuth', () => {
|
|
47
|
-
|
|
47
|
+
it('skips extraction when token exists and not expired', async () => {
|
|
48
48
|
// given
|
|
49
49
|
loadConfigSpy.mockResolvedValue({
|
|
50
50
|
current_account: 'work',
|
|
@@ -66,7 +66,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
66
66
|
expect(extractSpy).not.toHaveBeenCalled()
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
it('extracts when no config exists', async () => {
|
|
70
70
|
// given
|
|
71
71
|
loadConfigSpy.mockResolvedValue(null)
|
|
72
72
|
|
|
@@ -94,7 +94,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
94
94
|
)
|
|
95
95
|
})
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
it('re-extracts when token is expired', async () => {
|
|
98
98
|
// given
|
|
99
99
|
loadConfigSpy.mockResolvedValue({
|
|
100
100
|
current_account: 'work',
|
|
@@ -124,7 +124,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
124
124
|
)
|
|
125
125
|
})
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
it('sets first team as current', async () => {
|
|
128
128
|
// when
|
|
129
129
|
await ensureTeamsAuth()
|
|
130
130
|
|
|
@@ -138,7 +138,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
138
138
|
)
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
it('saves token_expires_at', async () => {
|
|
142
142
|
// when
|
|
143
143
|
const before = Date.now()
|
|
144
144
|
await ensureTeamsAuth()
|
|
@@ -151,7 +151,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
151
151
|
expect(expiresAt).toBeLessThanOrEqual(after + 60 * 60 * 1000 + 1)
|
|
152
152
|
})
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
it('does not save when extraction returns null', async () => {
|
|
155
155
|
// given
|
|
156
156
|
extractSpy.mockResolvedValue([])
|
|
157
157
|
|
|
@@ -163,7 +163,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
163
163
|
expect(saveConfigSpy).not.toHaveBeenCalled()
|
|
164
164
|
})
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
it('does not save when no teams found', async () => {
|
|
167
167
|
// given
|
|
168
168
|
listTeamsSpy.mockResolvedValue([])
|
|
169
169
|
|
|
@@ -174,7 +174,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
174
174
|
expect(saveConfigSpy).not.toHaveBeenCalled()
|
|
175
175
|
})
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
it('silently handles extraction failure', async () => {
|
|
178
178
|
// given
|
|
179
179
|
extractSpy.mockRejectedValue(new Error('Teams not found'))
|
|
180
180
|
|
|
@@ -185,7 +185,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
185
185
|
expect(saveConfigSpy).not.toHaveBeenCalled()
|
|
186
186
|
})
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
it('silently handles auth validation failure', async () => {
|
|
189
189
|
// given
|
|
190
190
|
testAuthSpy.mockRejectedValue(new Error('401 Unauthorized'))
|
|
191
191
|
|
|
@@ -196,7 +196,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
196
196
|
expect(saveConfigSpy).not.toHaveBeenCalled()
|
|
197
197
|
})
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
it('extracts and saves multiple accounts', async () => {
|
|
200
200
|
// given
|
|
201
201
|
extractSpy.mockResolvedValue([
|
|
202
202
|
{ token: 'work-token', accountType: 'work' },
|
|
@@ -226,7 +226,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
226
226
|
)
|
|
227
227
|
})
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
it('skips failed account but saves successful ones', async () => {
|
|
230
230
|
// given
|
|
231
231
|
extractSpy.mockResolvedValue([
|
|
232
232
|
{ token: 'work-token', accountType: 'work' },
|
|
@@ -248,7 +248,7 @@ describe('ensureTeamsAuth', () => {
|
|
|
248
248
|
expect(savedConfig.accounts.personal).toBeUndefined()
|
|
249
249
|
})
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
it('re-extracts when token is empty string', async () => {
|
|
252
252
|
// given
|
|
253
253
|
loadConfigSpy.mockResolvedValue({
|
|
254
254
|
current_account: 'work',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expect,
|
|
1
|
+
import { expect, it } from 'bun:test'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
TeamsAccountSchema,
|
|
@@ -17,58 +17,58 @@ import {
|
|
|
17
17
|
TeamsUserSchema,
|
|
18
18
|
} from '@/platforms/teams/index'
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
it('TeamsClient is exported from barrel', () => {
|
|
21
21
|
expect(typeof TeamsClient).toBe('function')
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
it('TeamsError is exported from barrel', () => {
|
|
25
25
|
expect(typeof TeamsError).toBe('function')
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
it('TeamsCredentialManager is exported from barrel', () => {
|
|
29
29
|
expect(typeof TeamsCredentialManager).toBe('function')
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
it('TeamsTeamSchema is exported from barrel', () => {
|
|
33
33
|
expect(typeof TeamsTeamSchema.parse).toBe('function')
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
it('TeamsChannelSchema is exported from barrel', () => {
|
|
37
37
|
expect(typeof TeamsChannelSchema.parse).toBe('function')
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
it('TeamsMessageSchema is exported from barrel', () => {
|
|
41
41
|
expect(typeof TeamsMessageSchema.parse).toBe('function')
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
it('TeamsUserSchema is exported from barrel', () => {
|
|
45
45
|
expect(typeof TeamsUserSchema.parse).toBe('function')
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
it('TeamsReactionSchema is exported from barrel', () => {
|
|
49
49
|
expect(typeof TeamsReactionSchema.parse).toBe('function')
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
it('TeamsFileSchema is exported from barrel', () => {
|
|
53
53
|
expect(typeof TeamsFileSchema.parse).toBe('function')
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
it('TeamsCredentialsSchema is exported from barrel', () => {
|
|
57
57
|
expect(typeof TeamsCredentialsSchema.parse).toBe('function')
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
it('TeamsAccountTypeSchema is exported from barrel', () => {
|
|
61
61
|
expect(typeof TeamsAccountTypeSchema.parse).toBe('function')
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
it('TeamsAccountSchema is exported from barrel', () => {
|
|
65
65
|
expect(typeof TeamsAccountSchema.parse).toBe('function')
|
|
66
66
|
})
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
it('TeamsConfigSchema is exported from barrel', () => {
|
|
69
69
|
expect(typeof TeamsConfigSchema.parse).toBe('function')
|
|
70
70
|
})
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
it('TeamsConfigLegacySchema is exported from barrel', () => {
|
|
73
73
|
expect(typeof TeamsConfigLegacySchema.parse).toBe('function')
|
|
74
74
|
})
|