Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.5 KB
Raw Blame
import { describe, expect, it } from 'vitest';
import { peerAuthorId } from './author';
import { userLabel } from './utils';

describe('peerAuthorId', () => {
  it('attributes a peer an agent registered to the agent', () => {
    expect(
      peerAuthorId('11646767255883251712', {
        userId: 'macro|[email protected]',
        actor: 'bot|0198c1a2-7b3c-7d4e-8f90-123456789abc',
      })
    ).toBe('bot|0198c1a2-7b3c-7d4e-8f90-123456789abc');
  });

  it('attributes an AI peer without an agent to the user, marked as AI', () => {
    expect(
      peerAuthorId('11646767255883251712', {
        userId: 'macro|[email protected]',
        actor: null,
      })
    ).toBe('ai|macro|[email protected]');
    expect(userLabel('ai|macro|[email protected]')).toBe('[email protected] (AI)');
  });

  it('still recognizes AI peers from the legacy reserved block', () => {
    expect(
      peerAuthorId('999999999999999000', {
        userId: 'macro|[email protected]',
        actor: null,
      })
    ).toBe('ai|macro|[email protected]');
  });

  it('attributes a human peer to its user', () => {
    expect(
      peerAuthorId('4242424242', {
        userId: 'macro|[email protected]',
        actor: null,
      })
    ).toBe('macro|[email protected]');
    expect(peerAuthorId('4242424242', undefined)).toBe('unknown');
  });

  it('falls back to Macro for an AI peer with no record', () => {
    expect(peerAuthorId('11646767255883251712', undefined)).toBe(
      '00000000-0000-0000-0000-00000000a1a1'
    );
  });
});