Skip to content

Commit 32d7797

Browse files
committed
fix(integrations): type the agentmail path test without a cast
1 parent f65dccd commit 32d7797

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎apps/sim/tools/agentmail/agentmail.test.ts‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import { describe, expect, it } from 'vitest'
22
import { agentmailGetMessageTool } from '@/tools/agentmail/get_message'
33
import { agentmailReplyMessageTool } from '@/tools/agentmail/reply_message'
44

5-
type UrlBuilder = (params: Record<string, unknown>) => string
5+
const scope = { apiKey: 'key', inboxId: 'agent@agentmail.to' }
6+
7+
function buildUrl<P>(url: string | ((params: P) => string), params: P): string {
8+
return typeof url === 'function' ? url(params) : url
9+
}
610

711
describe('agentmail request paths', () => {
812
it('encodes RFC 5322 message IDs so their characters stay inside one path segment', () => {
9-
const url = (agentmailGetMessageTool.request.url as UrlBuilder)({
10-
apiKey: 'key',
11-
inboxId: 'agent@agentmail.to',
13+
const url = buildUrl(agentmailGetMessageTool.request.url, {
14+
...scope,
1215
messageId: '<a/b#c?d%e@mail.example.com>',
1316
})
1417

@@ -18,10 +21,8 @@ describe('agentmail request paths', () => {
1821
})
1922

2023
it('rejects a dot-segment message ID instead of addressing the parent path', () => {
21-
const url = agentmailReplyMessageTool.request.url as UrlBuilder
22-
23-
expect(() => url({ apiKey: 'key', inboxId: 'agent@agentmail.to', messageId: '..' })).toThrow(
24-
/messageId/
25-
)
24+
expect(() =>
25+
buildUrl(agentmailReplyMessageTool.request.url, { ...scope, messageId: '..' })
26+
).toThrow(/messageId/)
2627
})
2728
})

0 commit comments

Comments
 (0)