outlook-mcp/tests/mailbox-send-path.test.js
Seton Carmichael e70840552d feat(outlook-mcp): shared mailbox targeting, discovery, and scopes (v1.1.0)
Add optional mailbox (UPN/SMTP) routing on email/folder/thread tools via
users/{upn}/... and X-AnchorMailbox. New list-mailboxes probes primary,
OUTLOOK_SHARED_MAILBOXES seeds, cache, and candidates. Send supports
mailbox-rooted sendMail and onBehalfOf. MSAL requests Mail.*.Shared;
check-auth-status reports token scp gaps. Docs, env example, tests.
2026-08-24 08:41:05 -04:00

33 lines
1 KiB
JavaScript

/**
* Unit tests for shared send path selection (pure logic mirror).
* Run: node tests/mailbox-send-path.test.js
*/
const assert = require('assert');
const { normalizeMailbox, buildPath } = require('../utils/mailbox');
function resolveSendPath(args) {
const mb = normalizeMailbox(args.mailbox);
const onBehalf = args.onBehalfOf === true || args.onBehalfOf === 'true';
if (mb.kind === 'user' && !onBehalf) {
return buildPath(mb, 'sendMail');
}
return 'me/sendMail';
}
assert.strictEqual(resolveSendPath({}), 'me/sendMail');
assert.strictEqual(resolveSendPath({ mailbox: 'me' }), 'me/sendMail');
assert.strictEqual(
resolveSendPath({ mailbox: 'helpdesk@contoso.com' }),
'users/helpdesk@contoso.com/sendMail'
);
assert.strictEqual(
resolveSendPath({ mailbox: 'helpdesk@contoso.com', onBehalfOf: true }),
'me/sendMail'
);
assert.strictEqual(
resolveSendPath({ mailbox: 'helpdesk@contoso.com', onBehalfOf: 'true' }),
'me/sendMail'
);
console.log('✅ send path selection');
console.log('\nAll mailbox-send-path tests passed.');