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 type { Item } from '@service-storage/generated/schemas/item';
import { describe, expect, it, vi } from 'vitest';
import { transformHistoryResponse } from '../transforms';
vi.mock('@core/constant/allBlocks', () => ({
itemToSafeName: (item: { name?: string }) => item.name || 'Untitled',
}));
vi.mock('@service-storage/util/filename', () => ({
formatDocumentName: (name: string) => name,
}));
function createItem(overrides: Partial<Item> = {}): Item {
return {
id: `item-${Math.random().toString(36).slice(2)}`,
name: 'Test Item',
type: 'document',
userId: 'user-1',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...overrides,
} as Item;
}
describe('history transforms', () => {
it('omits backing descriptions without deduplicating ordinary entities by title', () => {
const result = transformHistoryResponse({
data: [
createItem({
id: 'description',
subType: { type: 'initiative_description' },
}),
createItem({ id: 'note', fileType: 'md' }),
createItem({
id: 'task',
subType: { type: 'task', is_completed: false },
}),
createItem({ id: 'folder', type: 'project' }),
],
});
expect(result.map((item) => item.id)).toEqual(['note', 'task', 'folder']);
});
it('transforms response', () => {
const data = {
data: [
createItem({ id: 'doc-1', name: 'My Doc' }),
createItem({ id: 'doc-2', name: 'Other Doc' }),
],
};
const result = transformHistoryResponse(data);
expect(result.map((i) => i.id)).toEqual(['doc-1', 'doc-2']);
expect(result[0].name).toBe('My Doc');
});
it('keeps raw name for md documents', () => {
const data = {
data: [createItem({ id: 'doc-1', name: '', fileType: 'md' })],
};
console.log('data', data);
const result = transformHistoryResponse(data);
expect(result[0].name).toBe('Untitled');
expect(result[0].rawName).toBe('');
});
});