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 { RecommendedItem } from '@queries/ai/homeRecommendations';
import { cleanup, fireEvent, render } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { HomeSuggestions } from './home-suggestions';
afterEach(cleanup);
const items: RecommendedItem[] = [1, 2, 3, 4].map((id) => ({
entityType: 'email_thread',
entityId: `email-${id}`,
title: `Email subject ${id}`,
source: 'Email',
action: 'reply_now',
reason: `Confirm the requested deadline ${id}`,
prompt: `Draft a reply to email ${id}`,
}));
describe('HomeSuggestions', () => {
it('shows three item names and reasons with separate draft and Open actions', () => {
const onSelect = vi.fn();
const onOpen = vi.fn();
const view = render(() => (
<HomeSuggestions
view={{ kind: 'items', items }}
onSelect={onSelect}
onOpen={onOpen}
onRetry={vi.fn()}
onConnect={vi.fn()}
/>
));
expect(view.getAllByText('Open')).toHaveLength(3);
expect(view.queryByText(items[3].reason)).toBeNull();
expect(view.getByText(items[0].title)).toBeTruthy();
expect(view.queryByText(items[3].title)).toBeNull();
fireEvent.click(view.getByText(items[0].reason));
expect(onSelect).toHaveBeenCalledExactlyOnceWith(items[0]);
expect(onOpen).not.toHaveBeenCalled();
fireEvent.click(
view.getByRole('button', {
name: `Open ${items[1].title} in a new split`,
})
);
expect(onOpen).toHaveBeenCalledExactlyOnceWith(items[1]);
expect(onSelect).toHaveBeenCalledTimes(1);
});
it('offers Try again for a retryable failure', () => {
const onRetry = vi.fn();
const view = render(() => (
<HomeSuggestions
view={{ kind: 'error', retryable: true }}
onSelect={vi.fn()}
onOpen={vi.fn()}
onRetry={onRetry}
onConnect={vi.fn()}
/>
));
fireEvent.click(view.getByRole('button', { name: 'Try again' }));
expect(onRetry).toHaveBeenCalledOnce();
});
it('offers no Try again when the plan refused the request', () => {
const view = render(() => (
<HomeSuggestions
view={{ kind: 'error', retryable: false }}
onSelect={vi.fn()}
onOpen={vi.fn()}
onRetry={vi.fn()}
onConnect={vi.fn()}
/>
));
expect(
view.getByText('Suggestions are unavailable right now.')
).toBeTruthy();
expect(view.queryByRole('button', { name: 'Try again' })).toBeNull();
});
});