Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
import { describe, expect, spyOn, test } from 'bun:test';
import {
hydrateChannelEvent,
userFromPrincipal,
} from '../src/events/hydrate/channel';
import type { MacroClient } from '../src/utils/client';
const client = {} as MacroClient;
describe('userFromPrincipal', () => {
test('resolves user principals, normalizing case', () => {
expect(userFromPrincipal(client, 'macro|[email protected]')?.id).toBe(
'macro|[email protected]',
);
});
test('only treats a leading bot| as a bot, since | is legal in an email', () => {
expect(userFromPrincipal(client, 'macro|bot|[email protected]')?.id).toBe(
'macro|bot|[email protected]',
);
});
test('gives no user for bots or empty principals', () => {
for (const id of [
'bot|00000000-0000-0000-0000-000000000001',
'macro|',
'',
]) {
expect(userFromPrincipal(client, id)).toBeUndefined();
}
});
});
describe('hydrateChannelEvent', () => {
test('an event type from a newer server is skipped instead of throwing', () => {
const warn = spyOn(console, 'warn').mockImplementation(() => {});
const fromNewerServer = JSON.parse(
'{"event_type":"channel.archived","metadata":{}}',
);
expect(hydrateChannelEvent(client, fromNewerServer)).toBeUndefined();
expect(warn).toHaveBeenCalledTimes(1);
warn.mockRestore();
});
});