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, it } from 'vitest';
import {
type CalendarEvent,
DEFAULT_GUEST_POLICY,
NO_VIEWER_CAPABILITIES,
} from '../types';
import { eventAttribution } from './event-attribution';
function event(overrides: Partial<CalendarEvent>): CalendarEvent {
return {
id: '["event","occurrence"]',
eventId: 'event',
occurrenceKey: 'occurrence',
isCancelled: false,
isReadOnly: false,
guestPolicy: DEFAULT_GUEST_POLICY,
viewerCan: NO_VIEWER_CAPABILITIES,
attendees: [],
recurrenceLines: [],
sourceCalendarIds: [],
title: 'd',
start: '2026-08-27T19:00:00.000Z',
end: '2026-08-27T20:45:00.000Z',
allDay: false,
calendar: {
id: 'jackson-cal',
name: 'Jackson Kustec',
color: 'orange',
emailAddress: '[email protected]',
isPrimary: true,
},
visibleCalendars: [],
...overrides,
};
}
describe('eventAttribution', () => {
it('shows the calendar and creator when the organizer is the calendar owner', () => {
const attribution = eventAttribution(
event({
organizerName: 'Jackson Kustec',
organizerEmail: '[email protected]',
creatorName: 'Teo Nys',
creatorEmail: '[email protected]',
})
);
expect(attribution.calendarName).toBe('[email protected]');
expect(attribution.creator).toEqual({
displayName: 'Teo Nys',
email: '[email protected]',
isSelf: false,
});
expect(attribution.organizer).toBeUndefined();
});
it('does not label the calendar owner as organizer when creator is unknown', () => {
const attribution = eventAttribution(
event({
organizerName: 'Jackson Kustec',
organizerEmail: '[email protected]',
})
);
expect(attribution.calendarName).toBe('[email protected]');
expect(attribution.creator).toBeUndefined();
expect(attribution.organizer).toBeUndefined();
});
it('shows a distinct meeting organizer on the viewer calendar', () => {
const attribution = eventAttribution(
event({
calendar: {
id: 'teo-cal',
name: '[email protected]',
color: 'blue',
emailAddress: '[email protected]',
isPrimary: true,
},
organizerName: 'Alex Organizer',
organizerEmail: '[email protected]',
creatorName: 'Alex Organizer',
creatorEmail: '[email protected]',
})
);
expect(attribution.calendarName).toBe('[email protected]');
expect(attribution.creator).toBeUndefined();
expect(attribution.organizer).toEqual({
displayName: 'Alex Organizer',
email: '[email protected]',
isSelf: false,
});
});
it('hides creator and organizer on the writer’s own calendar', () => {
const attribution = eventAttribution(
event({
calendar: {
id: 'teo-cal',
name: '[email protected]',
color: 'blue',
emailAddress: '[email protected]',
isPrimary: true,
},
organizerName: 'Teo Nys',
organizerEmail: '[email protected]',
creatorName: 'Teo Nys',
creatorEmail: '[email protected]',
})
);
expect(attribution.calendarName).toBe('[email protected]');
expect(attribution.creator).toBeUndefined();
expect(attribution.organizer).toBeUndefined();
});
it('does not treat the viewer inbox as the calendar on a shared calendar', () => {
const attribution = eventAttribution(
event({
calendar: {
id: 'jackson-cal',
name: 'Jackson Kustec',
color: 'orange',
emailAddress: '[email protected]',
isPrimary: false,
},
organizerName: 'Jackson Kustec',
organizerEmail: '[email protected]',
creatorName: 'Teo Nys',
creatorEmail: '[email protected]',
})
);
expect(attribution.calendarName).toBe('Jackson Kustec');
expect(attribution.creator).toEqual({
displayName: 'Teo Nys',
email: '[email protected]',
isSelf: false,
});
expect(attribution.organizer).toBeUndefined();
});
it('matches a multi-inbox calendar label to the calendar owner, not the inbox', () => {
const attribution = eventAttribution(
event({
calendar: {
id: 'jackson-cal',
name: 'Jackson Kustec — [email protected]',
color: 'orange',
emailAddress: '[email protected]',
isPrimary: false,
},
organizerName: 'Jackson Kustec',
organizerEmail: '[email protected]',
creatorName: 'Teo Nys',
creatorEmail: '[email protected]',
})
);
expect(attribution.calendarName).toBe('Jackson Kustec — [email protected]');
expect(attribution.creator?.displayName).toBe('Teo Nys');
expect(attribution.organizer).toBeUndefined();
});
});