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
fix(call): start call button (#4750)
Will Hutchinson86be4131b5b8
diff --git a/apps/web/src/features/next-soup/soup-view/NewCallButton.test.tsx b/apps/web/src/features/next-soup/soup-view/NewCallButton.test.tsxnew file mode 100644index 0000000000..934e2a0c76--- /dev/null+++ b/apps/web/src/features/next-soup/soup-view/NewCallButton.test.tsx@@ -0,0 +1,91 @@+/**+ * @vitest-environment jsdom+ */++import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';+import type { JSX } from 'solid-js';+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { NewCallButton } from './NewCallButton';++const mocks = vi.hoisted(() => ({+ joinChannelCall: vi.fn<(_: string) => Promise<void>>(),+}));++vi.mock('@channel/Call/join-channel-call', () => ({+ joinChannelCall: mocks.joinChannelCall,+}));++vi.mock('@core/component/RecipientSelector', () => ({+ RecipientSelector: (props: {+ setSelectedOptions: (options: Array<{ id: string }>) => void;+ }) => (+ <button+ type="button"+ onClick={() => props.setSelectedOptions([{ id: 'channel-option' }])}+ >+ Choose channel+ </button>+ ),+}));++vi.mock('@core/component/Toast/Toast', () => ({+ toast: { failure: vi.fn() },+}));++vi.mock('@core/signal/useCombinedRecipient', () => ({+ useCombinedRecipients: () => ({ all: () => [] }),+}));++vi.mock('@core/util/destination', () => ({+ getDestinationFromOptions: () => ({+ type: 'channel',+ id: 'channel-123',+ }),+}));++vi.mock('@queries/channel/get-or-create-dm', () => ({+ useGetOrCreateDirectMessageMutation: () => ({ mutateAsync: vi.fn() }),+ useGetOrCreatePrivateChannelMutation: () => ({ mutateAsync: vi.fn() }),+}));++vi.mock('@ui', () => {+ type ChildrenProps = { children?: JSX.Element };+ type ButtonProps = ChildrenProps & {+ disabled?: boolean;+ onClick?: JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent>;+ };++ const Button = (props: ButtonProps) => (+ <button disabled={props.disabled} onClick={props.onClick} type="button">+ {props.children}+ </button>+ );+ const Dialog = (props: ChildrenProps) => <>{props.children}</>;+ Dialog.CloseButton = Button;+ Dialog.Title = (props: ChildrenProps) => <span>{props.children}</span>;++ return {+ Button,+ Dialog,+ Surface: (props: ChildrenProps) => <div>{props.children}</div>,+ };+});++beforeEach(() => {+ mocks.joinChannelCall.mockReset();+ mocks.joinChannelCall.mockResolvedValue();+});++describe('NewCallButton', () => {+ it('starts the selected channel through the mounted-channel call flow', async () => {+ render(() => <NewCallButton />);++ fireEvent.click(screen.getByRole('button', { name: 'Choose channel' }));+ fireEvent.click(screen.getByRole('button', { name: 'Start Call' }));++ await waitFor(() => {+ expect(mocks.joinChannelCall).toHaveBeenCalledOnce();+ expect(mocks.joinChannelCall).toHaveBeenCalledWith('channel-123');+ });+ });+});diff --git a/apps/web/src/features/next-soup/soup-view/NewCallButton.tsx b/apps/web/src/features/next-soup/soup-view/NewCallButton.tsxindex 25da59c5c4..b220e83295 100644--- a/apps/web/src/features/next-soup/soup-view/NewCallButton.tsx+++ b/apps/web/src/features/next-soup/soup-view/NewCallButton.tsx@@ -1,4 +1,4 @@-import { useSplitLayout } from '@components/app/split-layout/layout';+import { joinChannelCall } from '@channel/Call/join-channel-call';import { RecipientSelector } from '@core/component/RecipientSelector';import { toast } from '@core/component/Toast/Toast';import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';@@ -22,7 +22,6 @@ export function NewCallButton() {>([]);const [triedToSubmit, setTriedToSubmit] = createSignal(false);const [isSubmitting, setIsSubmitting] = createSignal(false);- const { replaceSplit } = useSplitLayout();const getOrCreateDmMutation = useGetOrCreateDirectMessageMutation();const getOrCreatePrivateChannelMutation =useGetOrCreatePrivateChannelMutation();@@ -69,13 +68,7 @@ export function NewCallButton() {setIsOpen(false);reset();- replaceSplit({- content: {- type: 'channel',- id: channelId,- params: { join_call: 'true' },- },- });+ await joinChannelCall(channelId);} catch (err) {console.error('Failed to start call', err);toast.failure('Failed to start call');