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 { ListedForm } from '@service-storage/generated/schemas/listedForm';
import { describe, expect, it } from 'vitest';
import type { DriveSelection } from '../context/drive-source';
import { hiddenFormDatabases, selectDriveForms } from './drive-forms';
const selection: DriveSelection = {
location: { kind: 'tab', tab: 'owned' },
scope: 'default',
sort: 'updated_at',
search: '',
facets: {},
};
const listed: ListedForm[] = [
{
form: {
id: 'rsvp',
name: 'Offsite RSVP',
description: '',
ownerId: 'me',
databaseId: 'rsvp-database',
tableId: 'rsvp-table',
submittedColumnId: null,
respondentColumnId: null,
audience: 'members',
tallyVisible: false,
responsesVisible: false,
anonymous: false,
status: 'open',
closesAt: null,
confirmationMessage: '',
branding: { logoFileId: null, coverFileId: null, accentColor: null },
createdAt: '2026-10-01T00:00:00Z',
updatedAt: '2026-10-01T00:00:00Z',
projectId: null,
isHiddenInDrive: false,
},
access: 'owner',
},
{
form: {
id: 'poll',
name: 'Lunch?',
description: '',
ownerId: 'me',
databaseId: 'poll-database',
tableId: 'poll-table',
submittedColumnId: null,
respondentColumnId: null,
audience: 'members',
tallyVisible: true,
responsesVisible: false,
anonymous: false,
status: 'open',
closesAt: null,
confirmationMessage: '',
branding: { logoFileId: null, coverFileId: null, accentColor: null },
createdAt: '2026-10-02T00:00:00Z',
updatedAt: '2026-10-02T00:00:00Z',
projectId: null,
isHiddenInDrive: true,
},
access: 'owner',
},
];
describe('Drive form listing', () => {
it('leaves out a form kept out of Drive, and the database made for it', () => {
expect(
selectDriveForms(listed, selection, 'me').map((entity) => entity.id)
).toEqual(['rsvp']);
expect(hiddenFormDatabases(listed)).toEqual(new Set(['poll-database']));
});
});
describe('Drive forms in folders', () => {
it("lists a folder's forms inside that folder, and keeps tabs flat", () => {
const [rsvp, poll] = listed;
if (!rsvp || !poll) throw new Error('fixture');
const filed: ListedForm[] = [
{ ...rsvp, form: { ...rsvp.form, projectId: 'clients' } },
{ ...poll, form: { ...poll.form, projectId: 'clients' } },
];
const folder = {
...selection,
location: { kind: 'folder', id: 'clients' },
} satisfies DriveSelection;
const inFolder = selectDriveForms(filed, folder, 'me');
expect(inFolder.map((entity) => entity.id)).toEqual(['rsvp']);
expect(inFolder[0]?.projectId).toBe('clients');
expect(
selectDriveForms(
filed,
{ ...folder, location: { kind: 'folder', id: 'other' } },
'me'
)
).toEqual([]);
expect(
selectDriveForms(filed, selection, 'me').map((entity) => entity.id)
).toEqual(['rsvp']);
});
});