The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
chore(front): remove Effect component tests (#26963)
Charles Bochetfc58cbc964f2
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatPrepromptEffect.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatPrepromptEffect.test.tsxdeleted file mode 100644index 89e9f7edabd..00000000000--- a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatPrepromptEffect.test.tsx+++ /dev/null@@ -1,98 +0,0 @@-import { act, render, renderHook } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { type ReactNode } from 'react';--import { serializePlainTextAsAdvancedTextEditorDocument } from '@/advanced-text-editor/utils/serializePlainTextAsAdvancedTextEditorDocument';-import { AgentChatPrepromptEffect } from '@/ai/components/AgentChatPrepromptEffect';-import { AGENT_CHAT_RESTORE_EDITOR_CONTENT_EVENT_NAME } from '@/ai/constants/AgentChatRestoreEditorContentEventName';-import { AGENT_CHAT_SEND_MESSAGE_EVENT_NAME } from '@/ai/constants/AgentChatSendMessageEventName';-import { useStageAiChatPreprompt } from '@/ai/hooks/useStageAiChatPreprompt';-import { AGENT_CHAT_NEW_THREAD_DRAFT_KEY } from '@/ai/states/agentChatDraftsByThreadIdState';-import {- type AgentChatPrepromptMode,- agentChatPrepromptState,-} from '@/ai/states/agentChatPrepromptState';-import { shouldFocusChatEditorState } from '@/ai/states/shouldFocusChatEditorState';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>-);--const listenToEvent = (eventName: string) => {- const listener = jest.fn();- window.addEventListener(eventName, listener);-- return listener;-};--const stagePreprompt = ({- text,- mode,-}: {- text: string;- mode: AgentChatPrepromptMode;-}) => {- const { result } = renderHook(() => useStageAiChatPreprompt(), {- wrapper: Wrapper,- });-- act(() => {- result.current.stageAiChatPreprompt({- serializedDocument: serializePlainTextAsAdvancedTextEditorDocument(text),- mode,- draftKey: AGENT_CHAT_NEW_THREAD_DRAFT_KEY,- });- });-};--describe('AgentChatPrepromptEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- jest.useFakeTimers();- resetJotaiStore();- });-- afterEach(() => {- jest.useRealTimers();- });-- it('should send the preprompt and clear the composer in SEND mode', () => {- const sendListener = listenToEvent(AGENT_CHAT_SEND_MESSAGE_EVENT_NAME);- const restoreListener = listenToEvent(- AGENT_CHAT_RESTORE_EDITOR_CONTENT_EVENT_NAME,- );- render(<AgentChatPrepromptEffect />, { wrapper: Wrapper });- stagePreprompt({ text: 'What can you do?', mode: 'SEND' });- act(() => {- jest.runAllTimers();- });-- expect(sendListener).toHaveBeenCalled();- expect(restoreListener.mock.calls[0][0].detail).toEqual({ content: '' });- expect(jotaiStore.get(shouldFocusChatEditorState.atom)).toBe(false);- expect(jotaiStore.get(agentChatPrepromptState.atom)).toBeNull();- });-- it('should fill the composer and ask for focus in PREFILL mode', () => {- const sendListener = listenToEvent(AGENT_CHAT_SEND_MESSAGE_EVENT_NAME);- const restoreListener = listenToEvent(- AGENT_CHAT_RESTORE_EDITOR_CONTENT_EVENT_NAME,- );- render(<AgentChatPrepromptEffect />, { wrapper: Wrapper });- stagePreprompt({ text: 'Create a workflow that ', mode: 'PREFILL' });- act(() => {- jest.runAllTimers();- });-- expect(sendListener).not.toHaveBeenCalled();- expect(restoreListener.mock.calls[0][0].detail.content).toContain(- 'Create a workflow that ',- );- expect(jotaiStore.get(shouldFocusChatEditorState.atom)).toBe(true);- expect(jotaiStore.get(agentChatPrepromptState.atom)).toBeNull();- });-});diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatRuntimeEffects.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatRuntimeEffects.test.tsxdeleted file mode 100644index 2f572bc369f..00000000000--- a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatRuntimeEffects.test.tsx+++ /dev/null@@ -1,60 +0,0 @@-import { render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { type ReactNode } from 'react';--import { AgentChatRuntimeEffects } from '@/ai/components/AgentChatRuntimeEffects';-import { hasAgentChatBeenOpenedState } from '@/ai/states/hasAgentChatBeenOpenedState';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--jest.mock('@/ai/components/AgentChatMessagesFetchEffect', () => ({- AgentChatMessagesFetchEffect: () => <div data-testid="messages-fetch" />,-}));-jest.mock('@/ai/components/AgentChatStreamSubscriptionEffect', () => ({- AgentChatStreamSubscriptionEffect: () => (- <div data-testid="stream-subscription" />- ),-}));-jest.mock('@/ai/components/AgentChatPrepromptEffect', () => ({- AgentChatPrepromptEffect: () => <div data-testid="preprompt" />,-}));-jest.mock('@/ai/components/AgentChatStreamKeepAliveEffect', () => ({- AgentChatStreamKeepAliveEffect: () => <div data-testid="keep-alive" />,-}));-jest.mock('@/ai/components/AgentChatSessionStartTimeEffect', () => ({- AgentChatSessionStartTimeEffect: () => <div data-testid="session-start" />,-}));--const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>-);--describe('AgentChatRuntimeEffects', () => {- beforeEach(() => {- resetJotaiStore();- });-- it('should render nothing until the chat has been opened once', () => {- const { container } = render(<AgentChatRuntimeEffects />, {- wrapper: Wrapper,- });-- expect(container).toBeEmptyDOMElement();- });-- it('should run the chat runtime once the chat has been opened, regardless of the side panel', () => {- jotaiStore.set(hasAgentChatBeenOpenedState.atom, true);-- const { getByTestId } = render(<AgentChatRuntimeEffects />, {- wrapper: Wrapper,- });-- expect(getByTestId('messages-fetch')).toBeInTheDocument();- expect(getByTestId('stream-subscription')).toBeInTheDocument();- expect(getByTestId('preprompt')).toBeInTheDocument();- expect(getByTestId('keep-alive')).toBeInTheDocument();- expect(getByTestId('session-start')).toBeInTheDocument();- });-});diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatThreadInitializationEffect.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatThreadInitializationEffect.test.tsxdeleted file mode 100644index 2fd99597064..00000000000--- a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatThreadInitializationEffect.test.tsx+++ /dev/null@@ -1,175 +0,0 @@-import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';-import { agentChatUsageComponentFamilyState } from '@/ai/states/agentChatUsageComponentFamilyState';-import { setAgentChatThreadList } from '@/ai/testing/setAgentChatThreadList';-import {- type CurrentWorkspace,- currentWorkspaceState,-} from '@/auth/states/currentWorkspaceState';-import { metadataStoreState } from '@/metadata-store/states/metadataStoreState';-import { WorkspaceActivationStatus } from 'twenty-shared/workspace';-import { act, render } from '@testing-library/react';-import { createStore, Provider as JotaiProvider } from 'jotai';--import { AgentChatThreadInitializationEffect } from '@/ai/components/AgentChatThreadInitializationEffect';-import { AgentChatComponentInstanceContext } from '@/ai/contexts/AgentChatComponentInstanceContext';--const refreshAgentChatThreadsMock = jest.fn();--jest.mock('@/ai/hooks/useRefreshAgentChatThreads', () => ({- useRefreshAgentChatThreads: () => ({- refreshAgentChatThreads: refreshAgentChatThreadsMock,- }),-}));--jest.mock('@/settings/roles/hooks/useHasPermissionFlag', () => ({- useHasPermissionFlag: () => true,-}));--const buildStore = () => {- const store = createStore();-- // The workspace is persisted in local storage, shared across stores- store.set(currentWorkspaceState.atom, null);- store.set(metadataStoreState.atomFamily('fieldMetadataItems'), {- current: [],- draft: [],- status: 'up-to-date',- });-- return store;-};--describe('AgentChatThreadInitializationEffect', () => {- beforeEach(() => {- jest.useFakeTimers();- jest.clearAllMocks();- });-- afterEach(() => {- jest.useRealTimers();- });-- it('retries when the initial thread request fails', async () => {- refreshAgentChatThreadsMock- .mockResolvedValueOnce(undefined)- .mockResolvedValueOnce([]);-- render(- <JotaiProvider store={buildStore()}>- <AgentChatComponentInstanceContext.Provider- value={{ instanceId: 'agent-chat-initialization-test' }}- >- <AgentChatThreadInitializationEffect />- </AgentChatComponentInstanceContext.Provider>- </JotaiProvider>,- );-- await act(async () => {- await Promise.resolve();- });-- expect(refreshAgentChatThreadsMock).toHaveBeenCalledTimes(1);-- await act(async () => {- jest.advanceTimersByTime(3000);- await Promise.resolve();- });-- expect(refreshAgentChatThreadsMock).toHaveBeenCalledTimes(2);- });- it('waits for the chat fields before reading chats through the record API', async () => {- const store = createStore();- store.set(metadataStoreState.atomFamily('fieldMetadataItems'), {- current: [],- draft: [],- status: 'empty',- });-- render(- <JotaiProvider store={store}>- <AgentChatComponentInstanceContext.Provider- value={{ instanceId: 'agent-chat-initialization-test' }}- >- <AgentChatThreadInitializationEffect />- </AgentChatComponentInstanceContext.Provider>- </JotaiProvider>,- );-- await act(async () => {- await Promise.resolve();- });-- expect(refreshAgentChatThreadsMock).not.toHaveBeenCalled();- });-- it('does not read chats in a suspended workspace, which the record API refuses', async () => {- const store = buildStore();- store.set(currentWorkspaceState.atom, {- id: 'workspace-id',- activationStatus: WorkspaceActivationStatus.SUSPENDED,- } as CurrentWorkspace);-- render(- <JotaiProvider store={store}>- <AgentChatComponentInstanceContext.Provider- value={{ instanceId: 'agent-chat-initialization-test' }}- >- <AgentChatThreadInitializationEffect />- </AgentChatComponentInstanceContext.Provider>- </JotaiProvider>,- );-- await act(async () => {- await Promise.resolve();- });-- expect(refreshAgentChatThreadsMock).not.toHaveBeenCalled();- });-- it('seeds an already-selected deep link when metadata arrives', async () => {- refreshAgentChatThreadsMock.mockResolvedValue([]);- const store = buildStore();- const threadId = '9ebfd0b0-a703-4478-8859-9b01c2eef391';- store.set(currentAiChatThreadState.atom, threadId);- const usageAtom = agentChatUsageComponentFamilyState.atomFamily({- instanceId: 'agent-chat-initialization-test',- familyKey: { threadId },- });- render(- <JotaiProvider store={store}>- <AgentChatComponentInstanceContext.Provider- value={{ instanceId: 'agent-chat-initialization-test' }}- >- <AgentChatThreadInitializationEffect />- </AgentChatComponentInstanceContext.Provider>- </JotaiProvider>,- );- expect(store.get(usageAtom)).toBeNull();- await act(async () => {- setAgentChatThreadList(store, [- {- __typename: 'AgentChatThread',- id: threadId,- title: null,- deletedAt: '2026-09-01',- createdAt: '2026-08-01',- updatedAt: '2026-09-01',- conversationSize: 120,- totalInputTokens: 250,- totalOutputTokens: 30,- totalCacheReadTokens: 80,- contextWindowTokens: 1000,- totalInputCredits: 125000,- totalOutputCredits: 50000,- },- ]);- });- expect(store.get(usageAtom)).toMatchObject({- inputTokens: 250,- cachedInputTokens: 80,- inputCredits: 0.125,- lastMessage: null,- });- expect(store.get(currentAiChatThreadState.atom)).toBe(threadId);- });-});diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatThreadRecordOperationsEffect.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatThreadRecordOperationsEffect.test.tsxdeleted file mode 100644index 077a0933946..00000000000--- a/packages/twenty-front/src/modules/ai/components/__tests__/AgentChatThreadRecordOperationsEffect.test.tsx+++ /dev/null@@ -1,195 +0,0 @@-import { act, render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';--import { AgentChatThreadRecordOperationsEffect } from '@/ai/components/AgentChatThreadRecordOperationsEffect';-import { agentChatThreadListState } from '@/ai/states/agentChatThreadListState';-import { dispatchObjectRecordOperationBrowserEvent } from '@/browser-event/utils/dispatchObjectRecordOperationBrowserEvent';-import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const CHAT_OBJECT_METADATA_ITEM = {- id: 'chat-object-metadata-id',- nameSingular: 'agentChatThread',-} as EnrichedObjectMetadataItem;-const OTHER_OBJECT_METADATA_ITEM = {- id: 'company-object-metadata-id',- nameSingular: 'company',-} as EnrichedObjectMetadataItem;-const CHAT_ID = '20202020-0000-4000-8000-0000000000aa';--const applyAgentChatThreadUpdate = jest.fn();-const addAgentChatThread = jest.fn();-const refreshAgentChatThreads = jest.fn();-const leaveRemovedAiChatThread = jest.fn();-const useListenToEventsForQuery = jest.fn();--jest.mock('@/ai/hooks/useApplyAgentChatThreadUpdate', () => ({- useApplyAgentChatThreadUpdate: () => ({- applyAgentChatThreadUpdate,- addAgentChatThread,- }),-}));-jest.mock('@/ai/hooks/useRefreshAgentChatThreads', () => ({- useRefreshAgentChatThreads: () => ({ refreshAgentChatThreads }),-}));-jest.mock('@/ai/hooks/useLeaveRemovedAiChatThread', () => ({- useLeaveRemovedAiChatThread: () => ({ leaveRemovedAiChatThread }),-}));-jest.mock('@/sse-db-event/hooks/useListenToEventsForQuery', () => ({- useListenToEventsForQuery: (params: unknown) =>- useListenToEventsForQuery(params),-}));-jest.mock(- '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue',- () => ({- useAtomFamilySelectorValue: () => CHAT_OBJECT_METADATA_ITEM,- }),-);--const dispatchChatOperation = (- operation: Parameters<- typeof dispatchObjectRecordOperationBrowserEvent- >[0]['operation'],- objectMetadataItem = CHAT_OBJECT_METADATA_ITEM,-) =>- act(() => {- dispatchObjectRecordOperationBrowserEvent({- objectMetadataItem,- operation,- });- });--describe('AgentChatThreadRecordOperationsEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- resetJotaiStore();- jotaiStore.set(agentChatThreadListState.atom, {- threadIds: [CHAT_ID],- hasNextPage: true,- endCursor: 'page-1',- });- refreshAgentChatThreads.mockResolvedValue([]);- render(- <JotaiProvider store={jotaiStore}>- <AgentChatThreadRecordOperationsEffect />- </JotaiProvider>,- );- });-- it("listens to every chat the member can read, including other tabs'", () => {- expect(useListenToEventsForQuery).toHaveBeenCalledWith(- expect.objectContaining({- operationSignature: {- objectNameSingular: 'agentChatThread',- variables: {},- },- skip: false,- }),- );- });-- it('applies renames and usage updates to the stored chat', () => {- dispatchChatOperation({- type: 'update-one',- result: {- updateInput: {- recordId: CHAT_ID,- updatedFields: [{ title: 'Renamed' }, { totalInputTokens: 12 }],- },- },- });-- expect(applyAgentChatThreadUpdate).toHaveBeenCalledWith({- id: CHAT_ID,- title: 'Renamed',- totalInputTokens: 12,- });- expect(refreshAgentChatThreads).not.toHaveBeenCalled();- });-- it('reloads the list when a chat past the loaded pages is updated', () => {- dispatchChatOperation({- type: 'update-one',- result: {- updateInput: {- recordId: 'older-chat',- updatedFields: [{ title: 'Renamed' }],- },- },- });-- expect(refreshAgentChatThreads).toHaveBeenCalledTimes(1);- });-- it('lists a created chat but leaves a workflow run conversation to its run', () => {- dispatchChatOperation({- type: 'create-one',- createdRecord: { id: CHAT_ID, workflowRunId: null },- });-- expect(addAgentChatThread).toHaveBeenCalledWith({- id: CHAT_ID,- workflowRunId: null,- });-- dispatchChatOperation({- type: 'create-one',- createdRecord: { id: 'run-conversation', workflowRunId: 'run' },- });-- expect(addAgentChatThread).toHaveBeenCalledTimes(1);- });-- it('marks deleted chats and clears the mark on restore', () => {- dispatchChatOperation({ type: 'delete-one', deletedRecordId: CHAT_ID });-- expect(applyAgentChatThreadUpdate).toHaveBeenLastCalledWith({- id: CHAT_ID,- deletedAt: expect.any(String),- });-- dispatchChatOperation({- type: 'restore-one',- restoredRecord: { id: CHAT_ID },- });-- expect(applyAgentChatThreadUpdate).toHaveBeenLastCalledWith({- id: CHAT_ID,- deletedAt: null,- });- });-- it('reads the chats again after a destroy and leaves a chat that is gone, even when the reload fails', async () => {- refreshAgentChatThreads.mockResolvedValue(undefined);-- dispatchChatOperation({ type: 'destroy-one' });-- await act(async () => {- await Promise.resolve();- });-- expect(refreshAgentChatThreads).toHaveBeenCalledTimes(1);- expect(leaveRemovedAiChatThread).toHaveBeenCalledTimes(1);- });-- it('reads the chats again after the event stream reconnects', async () => {- const { onSseReconnected } = useListenToEventsForQuery.mock.calls[0][0];-- await act(() => onSseReconnected());-- expect(refreshAgentChatThreads).toHaveBeenCalledTimes(1);- expect(leaveRemovedAiChatThread).toHaveBeenCalledTimes(1);- });-- it('ignores operations on other objects', () => {- dispatchChatOperation(- { type: 'delete-one', deletedRecordId: CHAT_ID },- OTHER_OBJECT_METADATA_ITEM,- );-- expect(applyAgentChatThreadUpdate).not.toHaveBeenCalled();- });-});diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatPageCloseAskAiPanelEffect.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatPageCloseAskAiPanelEffect.test.tsxdeleted file mode 100644index 72259b7e889..00000000000--- a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatPageCloseAskAiPanelEffect.test.tsx+++ /dev/null@@ -1,96 +0,0 @@-import { render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { type ReactNode } from 'react';-import { SidePanelPages } from 'twenty-shared/types';--import { AiChatPageCloseAskAiPanelEffect } from '@/ai/components/AiChatPageCloseAskAiPanelEffect';-import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState';-import {- type SidePanelNavigationStackItem,- sidePanelNavigationStackState,-} from '@/side-panel/states/sidePanelNavigationStackState';-import { type ActiveSidePanelPage } from '@/side-panel/types/SidePanelPage';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';-import { IconDotsVertical } from 'twenty-ui/icon';--const setCurrentSidePanelPage = (page: ActiveSidePanelPage) => {- const navigationItem: SidePanelNavigationStackItem =- page === SidePanelPages.RoutedPage- ? {- page,- pageTitle: 'Test page',- pageIcon: IconDotsVertical,- pageId: 'test-page',- routedLocation: {- pathname: '/test',- search: '',- hash: '',- state: null,- key: 'test',- },- }- : {- page,- pageTitle: 'Test page',- pageIcon: IconDotsVertical,- pageId: 'test-page',- };-- jotaiStore.set(sidePanelNavigationStackState.atom, [navigationItem]);-};--const closeSidePanelMenuMock = jest.fn();--jest.mock('@/side-panel/hooks/useSidePanelMenu', () => ({- useSidePanelMenu: () => ({ closeSidePanelMenu: closeSidePanelMenuMock }),-}));--const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>-);--describe('AiChatPageCloseAskAiPanelEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- resetJotaiStore();- });-- it('should dismiss a panel chat the browser navigated back onto', () => {- jotaiStore.set(isSidePanelOpenedState.atom, true);- setCurrentSidePanelPage(SidePanelPages.AskAI);-- render(<AiChatPageCloseAskAiPanelEffect />, { wrapper: Wrapper });-- expect(closeSidePanelMenuMock).toHaveBeenCalled();- });-- it('should leave an open artifact panel alone', () => {- jotaiStore.set(isSidePanelOpenedState.atom, true);- setCurrentSidePanelPage(SidePanelPages.RoutedPage);-- render(<AiChatPageCloseAskAiPanelEffect />, { wrapper: Wrapper });-- expect(closeSidePanelMenuMock).not.toHaveBeenCalled();- });-- it('should do nothing when the panel is closed', () => {- jotaiStore.set(isSidePanelOpenedState.atom, false);- setCurrentSidePanelPage(SidePanelPages.AskAI);-- render(<AiChatPageCloseAskAiPanelEffect />, { wrapper: Wrapper });-- expect(closeSidePanelMenuMock).not.toHaveBeenCalled();- });-- it('should not fight a panel chat opened after mount', () => {- render(<AiChatPageCloseAskAiPanelEffect />, { wrapper: Wrapper });-- jotaiStore.set(isSidePanelOpenedState.atom, true);- setCurrentSidePanelPage(SidePanelPages.AskAI);-- expect(closeSidePanelMenuMock).not.toHaveBeenCalled();- });-});diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatPageThreadUrlSyncEffect.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/AiChatPageThreadUrlSyncEffect.test.tsxdeleted file mode 100644index aaf72403ea5..00000000000--- a/packages/twenty-front/src/modules/ai/components/__tests__/AiChatPageThreadUrlSyncEffect.test.tsx+++ /dev/null@@ -1,206 +0,0 @@-import { act, render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { useEffect } from 'react';-import { MemoryRouter, Route, Routes, useNavigate } from 'react-router-dom';-import { AppPath } from 'twenty-shared/types';--import { AiChatPageThreadUrlSyncEffect } from '@/ai/components/AiChatPageThreadUrlSyncEffect';-import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';-import { setAgentChatThreadList } from '@/ai/testing/setAgentChatThreadList';-import { type AgentChatThreadRecord } from '@/ai/types/AgentChatThreadRecord';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const switchThreadWithDraftMock = jest.fn((toThreadId: string) => {- jotaiStore.set(currentAiChatThreadState.atom, toThreadId);-});-const switchToNewChatMock = jest.fn();-const loadAgentChatThreadMock = jest.fn();--jest.mock('@/ai/hooks/useSwitchToNewAiChat', () => ({- useSwitchToNewAiChat: () => ({ switchToNewChat: switchToNewChatMock }),-}));--jest.mock('@/ai/hooks/useRefreshAgentChatThreads', () => ({- useRefreshAgentChatThreads: () => ({- loadAgentChatThread: loadAgentChatThreadMock,- }),-}));--jest.mock('@/ai/hooks/useSwitchAgentChatThreadWithDraft', () => ({- useSwitchAgentChatThreadWithDraft: () => ({- switchThreadWithDraft: switchThreadWithDraftMock,- }),-}));--const THREAD_A = '11111111-1111-4111-8111-111111111111';-const THREAD_B = '22222222-2222-4222-8222-222222222222';--const buildChat = (- id: string,- deletedAt: string | null = null,-): AgentChatThreadRecord => ({- __typename: 'AgentChatThread',- id,- title: null,- deletedAt,- createdAt: '2026-09-01T00:00:00Z',- updatedAt: '2026-09-07T00:00:00Z',-});--let navigateToThread: ((threadId: string) => void) | undefined;--const RouteUnderTest = () => {- const navigate = useNavigate();-- useEffect(() => {- navigateToThread = (threadId: string) => navigate(`/chat/${threadId}`);- }, [navigate]);-- return <AiChatPageThreadUrlSyncEffect />;-};--const renderEffectAt = (initialPath: string) =>- render(- <JotaiProvider store={jotaiStore}>- <MemoryRouter initialEntries={[initialPath]}>- <Routes>- <Route- path={AppPath.AiChat}- element={<AiChatPageThreadUrlSyncEffect />}- />- </Routes>- </MemoryRouter>- </JotaiProvider>,- );--describe('AiChatPageThreadUrlSyncEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- loadAgentChatThreadMock.mockResolvedValue(null);- resetJotaiStore();- navigateToThread = undefined;- });-- it('should adopt the thread from the URL on a deep link', () => {- jotaiStore.set(currentAiChatThreadState.atom, null);-- renderEffectAt(`/chat/${THREAD_A}`);-- expect(switchThreadWithDraftMock).toHaveBeenCalledWith(THREAD_A);- });-- it('recovers a missing chat only once the thread list has loaded', async () => {- renderEffectAt(`/chat/${THREAD_A}`);-- expect(switchToNewChatMock).not.toHaveBeenCalled();- expect(loadAgentChatThreadMock).not.toHaveBeenCalled();-- await act(async () => {- setAgentChatThreadList(jotaiStore, []);- });-- expect(loadAgentChatThreadMock).toHaveBeenCalledWith(THREAD_A);- expect(switchToNewChatMock).toHaveBeenCalledTimes(1);- });-- it('keeps a chat URL that sits past the loaded pages', async () => {- loadAgentChatThreadMock.mockResolvedValue(buildChat(THREAD_A));- setAgentChatThreadList(jotaiStore, [buildChat(THREAD_B)], {- hasNextPage: true,- });-- await act(async () => {- renderEffectAt(`/chat/${THREAD_A}`);- });-- expect(loadAgentChatThreadMock).toHaveBeenCalledWith(THREAD_A);- expect(switchToNewChatMock).not.toHaveBeenCalled();- });-- it('keeps the chat URL when the chat cannot be looked up', async () => {- loadAgentChatThreadMock.mockResolvedValue(undefined);- setAgentChatThreadList(jotaiStore, [buildChat(THREAD_B)]);-- await act(async () => {- renderEffectAt(`/chat/${THREAD_A}`);- });-- expect(switchToNewChatMock).not.toHaveBeenCalled();- });-- it('keeps a deleted chat URL when the chat is listed', () => {- setAgentChatThreadList(jotaiStore, [- buildChat(THREAD_A, '2026-09-07T00:00:00Z'),- ]);-- renderEffectAt(`/chat/${THREAD_A}`);-- expect(switchThreadWithDraftMock).toHaveBeenCalledWith(THREAD_A);- expect(loadAgentChatThreadMock).not.toHaveBeenCalled();- expect(switchToNewChatMock).not.toHaveBeenCalled();- });-- it('should adopt the thread the browser navigated to', () => {- jotaiStore.set(currentAiChatThreadState.atom, THREAD_A);-- render(- <JotaiProvider store={jotaiStore}>- <MemoryRouter initialEntries={[`/chat/${THREAD_A}`]}>- <Routes>- <Route path={AppPath.AiChat} element={<RouteUnderTest />} />- </Routes>- </MemoryRouter>- </JotaiProvider>,- );-- expect(switchThreadWithDraftMock).not.toHaveBeenCalled();-- act(() => {- navigateToThread?.(THREAD_B);- });-- expect(switchThreadWithDraftMock).toHaveBeenCalledWith(THREAD_B);- });-- it('should do nothing when the URL already names the selected thread', () => {- jotaiStore.set(currentAiChatThreadState.atom, THREAD_A);-- renderEffectAt(`/chat/${THREAD_A}`);-- expect(switchThreadWithDraftMock).not.toHaveBeenCalled();- });-- it('should restore the url thread when a selection bypassed the projection', () => {- jotaiStore.set(currentAiChatThreadState.atom, null);-- renderEffectAt(`/chat/${THREAD_A}`);-- switchThreadWithDraftMock.mockClear();-- act(() => {- jotaiStore.set(currentAiChatThreadState.atom, THREAD_B);- });-- expect(switchThreadWithDraftMock).toHaveBeenCalledWith(THREAD_A);- });-- it('should ignore a malformed thread param and keep the selection', () => {- jotaiStore.set(currentAiChatThreadState.atom, THREAD_B);-- renderEffectAt('/chat/not-a-thread-id');-- expect(switchThreadWithDraftMock).not.toHaveBeenCalled();- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBe(THREAD_B);- });-- it('should leave a bare chat url alone', () => {- jotaiStore.set(currentAiChatThreadState.atom, THREAD_A);-- renderEffectAt('/chat');-- expect(switchThreadWithDraftMock).not.toHaveBeenCalled();- });-});diff --git a/packages/twenty-front/src/modules/ai/components/internal/__tests__/AiChatEditorFocusEffect.test.tsx b/packages/twenty-front/src/modules/ai/components/internal/__tests__/AiChatEditorFocusEffect.test.tsxdeleted file mode 100644index 049eee4c3e2..00000000000--- a/packages/twenty-front/src/modules/ai/components/internal/__tests__/AiChatEditorFocusEffect.test.tsx+++ /dev/null@@ -1,62 +0,0 @@-import { render } from '@testing-library/react';-import { Editor } from '@tiptap/core';-import { Document } from '@tiptap/extension-document';-import { Paragraph } from '@tiptap/extension-paragraph';-import { Text } from '@tiptap/extension-text';-import { Provider as JotaiProvider } from 'jotai';-import { type ReactNode } from 'react';--import { AiChatEditorFocusEffect } from '@/ai/components/internal/AiChatEditorFocusEffect';-import { shouldFocusChatEditorState } from '@/ai/states/shouldFocusChatEditorState';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>-);--// Whether the caret lands is tiptap's business and jsdom does not carry it, so-// these assert what the effect owns: which editor gets to consume the request.-describe('AiChatEditorFocusEffect', () => {- let editor: Editor;-- beforeEach(() => {- resetJotaiStore();- jotaiStore.set(shouldFocusChatEditorState.atom, true);- editor = new Editor({ extensions: [Document, Paragraph, Text] });- });-- afterEach(() => {- if (!editor.isDestroyed) {- editor.destroy();- }- });-- it('should consume the request on a live editor', () => {- render(<AiChatEditorFocusEffect editor={editor} />, { wrapper: Wrapper });-- expect(jotaiStore.get(shouldFocusChatEditorState.atom)).toBe(false);- });-- it('should leave the request for the next editor when the current one is destroyed', () => {- editor.destroy();-- // The crash this guards against: tiptap throws from the commands getter- // once the view is gone, so a destroyed editor cannot simply be focused.- expect(() => editor.commands).toThrow();-- expect(() =>- render(<AiChatEditorFocusEffect editor={editor} />, { wrapper: Wrapper }),- ).not.toThrow();-- expect(jotaiStore.get(shouldFocusChatEditorState.atom)).toBe(true);- });-- it('should keep the request while no editor is mounted', () => {- render(<AiChatEditorFocusEffect editor={null} />, { wrapper: Wrapper });-- expect(jotaiStore.get(shouldFocusChatEditorState.atom)).toBe(true);- });-});diff --git a/packages/twenty-front/src/modules/ai/dictation/components/__tests__/AiChatDictationEffect.test.tsx b/packages/twenty-front/src/modules/ai/dictation/components/__tests__/AiChatDictationEffect.test.tsxdeleted file mode 100644index 3ba55793c52..00000000000--- a/packages/twenty-front/src/modules/ai/dictation/components/__tests__/AiChatDictationEffect.test.tsx+++ /dev/null@@ -1,73 +0,0 @@-import { act, render } from '@testing-library/react';-import { getDefaultStore } from 'jotai';--import { AiChatDictationEffect } from '@/ai/dictation/components/AiChatDictationEffect';-import { dictationEngineState } from '@/ai/dictation/states/dictationEngineState';-import { hasWebSpeechProvenSilentState } from '@/ai/dictation/states/hasWebSpeechProvenSilentState';-import { type WebSpeechRecognitionConstructor } from '@/ai/dictation/types/WebSpeechRecognitionConstructor';--type SpeechRecognitionTestWindow = {- SpeechRecognition?: WebSpeechRecognitionConstructor;-};--const mockEnqueueToast = jest.fn();--jest.mock('twenty-ui/components', () => ({- ...jest.requireActual('twenty-ui/components'),- useToast: () => ({ enqueueToast: mockEnqueueToast }),-}));--const renderEffect = () =>- render(- <AiChatDictationEffect onInterimText={jest.fn()} onFinalText={jest.fn()} />,- );--const readEngine = () => getDefaultStore().get(dictationEngineState.atom);--describe('AiChatDictationEffect', () => {- beforeEach(() => {- localStorage.clear();- getDefaultStore().set(hasWebSpeechProvenSilentState.atom, false);- (window as SpeechRecognitionTestWindow).SpeechRecognition =- function SpeechRecognition() {} as unknown as WebSpeechRecognitionConstructor;- Object.defineProperty(navigator, 'mediaDevices', {- value: { getUserMedia: jest.fn() },- configurable: true,- });- Object.defineProperty(window, 'isSecureContext', {- value: true,- configurable: true,- });- });-- afterEach(() => {- delete (window as SpeechRecognitionTestWindow).SpeechRecognition;- act(() => {- getDefaultStore().set(dictationEngineState.atom, null);- });- });-- // The control renders on the engine's presence, so publishing it is what- // makes dictation appear at all.- it('publishes an engine on a surface that can dictate', () => {- renderEffect();-- expect(readEngine()).not.toBeNull();- });-- it('withdraws the engine when it unmounts', () => {- const { unmount } = renderEffect();-- unmount();-- expect(readEngine()).toBeNull();- });-- it('publishes no engine on a browser with no speech recognition', () => {- delete (window as SpeechRecognitionTestWindow).SpeechRecognition;-- renderEffect();-- expect(readEngine()).toBeNull();- });-});diff --git a/packages/twenty-front/src/modules/auth/components/__tests__/VerifyLoginTokenEffect.test.tsx b/packages/twenty-front/src/modules/auth/components/__tests__/VerifyLoginTokenEffect.test.tsxdeleted file mode 100644index 694dec50d0c..00000000000--- a/packages/twenty-front/src/modules/auth/components/__tests__/VerifyLoginTokenEffect.test.tsx+++ /dev/null@@ -1,59 +0,0 @@-import { render, waitFor } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { StrictMode } from 'react';-import { MemoryRouter } from 'react-router-dom';-import { AppPath } from 'twenty-shared/types';--import { VerifyLoginTokenEffect } from '@/auth/components/VerifyLoginTokenEffect';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const verifyLoginTokenMock = jest.fn();-const navigateMock = jest.fn();--jest.mock('@/auth/hooks/useVerifyLogin', () => ({- useVerifyLogin: () => ({ verifyLoginToken: verifyLoginTokenMock }),-}));--jest.mock('~/hooks/useNavigateApp', () => ({- useNavigateApp: () => navigateMock,-}));--const renderEffect = (initialEntry: string) =>- render(- <JotaiProvider store={jotaiStore}>- <MemoryRouter initialEntries={[initialEntry]}>- <StrictMode>- <VerifyLoginTokenEffect />- </StrictMode>- </MemoryRouter>- </JotaiProvider>,- );--describe('VerifyLoginTokenEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- localStorage.clear();- resetJotaiStore();- });-- it('verifies the login token at most once under StrictMode', async () => {- renderEffect('/verify?loginToken=login-token');-- await waitFor(() => {- expect(verifyLoginTokenMock).toHaveBeenCalledWith('login-token');- });- expect(verifyLoginTokenMock).toHaveBeenCalledTimes(1);- });-- it('navigates to sign in up when no login token is present', async () => {- renderEffect('/verify');-- await waitFor(() => {- expect(navigateMock).toHaveBeenCalledWith(AppPath.SignInUp);- });- expect(verifyLoginTokenMock).not.toHaveBeenCalled();- });-});diff --git a/packages/twenty-front/src/modules/auth/effect-components/__tests__/PendingServerSignOutEffect.test.tsx b/packages/twenty-front/src/modules/auth/effect-components/__tests__/PendingServerSignOutEffect.test.tsxdeleted file mode 100644index 8ec1bfe423b..00000000000--- a/packages/twenty-front/src/modules/auth/effect-components/__tests__/PendingServerSignOutEffect.test.tsx+++ /dev/null@@ -1,102 +0,0 @@-import { renderHook, waitFor } from '@testing-library/react';-import { Provider as JotaiProvider, createStore } from 'jotai';-import { type ReactNode } from 'react';--import { PendingServerSignOutEffect } from '@/auth/effect-components/PendingServerSignOutEffect';-import { isCookieAuthActiveState } from '@/auth/states/isCookieAuthActiveState';-import { isPendingServerSignOutState } from '@/auth/states/isPendingServerSignOutState';-import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';--const mockMutate = jest.fn();--jest.mock('@apollo/client/react', () => ({- useApolloClient: () => ({ mutate: mockMutate }),-}));--const renderEffect = ({- isLoadedOnce = true,- isPendingServerSignOut = true,- isCookieAuthActive = false,-}: {- isLoadedOnce?: boolean;- isPendingServerSignOut?: boolean;- isCookieAuthActive?: boolean;-} = {}) => {- const store = createStore();-- store.set(clientConfigApiStatusState.atom, {- isLoadedOnce,- isLoading: false,- isErrored: false,- isSaved: false,- });- store.set(isPendingServerSignOutState.atom, isPendingServerSignOut);- store.set(isCookieAuthActiveState.atom, isCookieAuthActive);-- renderHook(() => PendingServerSignOutEffect(), {- wrapper: ({ children }: { children: ReactNode }) => (- <JotaiProvider store={store}>{children}</JotaiProvider>- ),- });-- return store;-};--describe('PendingServerSignOutEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- mockMutate.mockResolvedValue({ data: { signOut: true } });- });-- it('should revoke the session left behind by a sign out that never reached the server', async () => {- const store = renderEffect();-- await waitFor(() => expect(mockMutate).toHaveBeenCalledTimes(1));- await waitFor(() =>- expect(store.get(isPendingServerSignOutState.atom)).toBe(false),- );- });-- it('should keep the retry pending when the server is still unreachable', async () => {- mockMutate.mockRejectedValue(new Error('Network error'));-- const store = renderEffect();-- await waitFor(() => expect(mockMutate).toHaveBeenCalledTimes(1));- expect(store.get(isPendingServerSignOutState.atom)).toBe(true);- });-- // A retry is issued seconds later and carries whatever cookie exists by then,- // so it would revoke a session established in the meantime.- it('should not let the sign out be retried', async () => {- renderEffect();-- await waitFor(() => expect(mockMutate).toHaveBeenCalledTimes(1));- expect(mockMutate).toHaveBeenCalledWith(- expect.objectContaining({ context: { skipRetry: true } }),- );- });-- // The pending sign-out is stale once a new session exists; firing it would- // revoke the session the user just got.- it('should drop the pending sign out when a session is already active', async () => {- const store = renderEffect({ isCookieAuthActive: true });-- await waitFor(() =>- expect(store.get(isPendingServerSignOutState.atom)).toBe(false),- );- expect(mockMutate).not.toHaveBeenCalled();- });-- it('should not sign out a session the user never asked to end', async () => {- renderEffect({ isPendingServerSignOut: false });-- await waitFor(() => expect(mockMutate).not.toHaveBeenCalled());- });-- it('should wait for the api before retrying', async () => {- renderEffect({ isLoadedOnce: false });-- await waitFor(() => expect(mockMutate).not.toHaveBeenCalled());- });-});diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/__tests__/SignInUpSsoExchangeTokenEffect.test.tsx b/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/__tests__/SignInUpSsoExchangeTokenEffect.test.tsxdeleted file mode 100644index 7975dc5afb4..00000000000--- a/packages/twenty-front/src/modules/auth/sign-in-up/components/internal/__tests__/SignInUpSsoExchangeTokenEffect.test.tsx+++ /dev/null@@ -1,73 +0,0 @@-import { render, screen, waitFor } from '@testing-library/react';-import { StrictMode } from 'react';-import { BrowserRouter, useSearchParams } from 'react-router-dom';--import { SignInUpSsoExchangeTokenEffect } from '@/auth/sign-in-up/components/internal/SignInUpSsoExchangeTokenEffect';--const redeemSsoExchangeTokenMock = jest.fn();--jest.mock('@/auth/hooks/useRedeemSsoExchangeToken', () => ({- useRedeemSsoExchangeToken: () => ({- redeemSsoExchangeToken: redeemSsoExchangeTokenMock,- }),-}));--const SearchParamsProbe = () => {- const [searchParams] = useSearchParams();-- return <div data-testid="search-params">{searchParams.toString()}</div>;-};--// BrowserRouter because the effect reads and strips window.location, which-// MemoryRouter never touches-const renderEffect = (initialUrl: string) => {- window.history.replaceState(null, '', initialUrl);-- return render(- <StrictMode>- <BrowserRouter>- <SignInUpSsoExchangeTokenEffect />- <SearchParamsProbe />- </BrowserRouter>- </StrictMode>,- );-};--const getSearchParams = () => screen.getByTestId('search-params').textContent;--describe('SignInUpSsoExchangeTokenEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- window.history.replaceState(null, '', '/');- });-- it('redeems the single use token at most once', async () => {- renderEffect('/sign-in-up#ssoExchangeToken=sso-exchange-token');-- await waitFor(() => {- expect(redeemSsoExchangeTokenMock).toHaveBeenCalledWith(- 'sso-exchange-token',- );- });- expect(redeemSsoExchangeTokenMock).toHaveBeenCalledTimes(1);- });-- it('strips the token from the url while keeping returnToPath', async () => {- renderEffect(- '/sign-in-up?returnToPath=%2Fsettings%2Fprofile#ssoExchangeToken=sso-exchange-token',- );-- await waitFor(() => {- expect(window.location.hash).toBe('');- });- expect(getSearchParams()).toBe('returnToPath=%2Fsettings%2Fprofile');- expect(redeemSsoExchangeTokenMock).toHaveBeenCalledTimes(1);- });-- it('does nothing when the url carries no token', () => {- renderEffect('/sign-in-up');-- expect(redeemSsoExchangeTokenMock).not.toHaveBeenCalled();- expect(getSearchParams()).toBe('');- });-});diff --git a/packages/twenty-front/src/modules/client-config/components/__tests__/ClientConfigProviderEffect.test.tsx b/packages/twenty-front/src/modules/client-config/components/__tests__/ClientConfigProviderEffect.test.tsxdeleted file mode 100644index 55138c584c8..00000000000--- a/packages/twenty-front/src/modules/client-config/components/__tests__/ClientConfigProviderEffect.test.tsx+++ /dev/null@@ -1,24 +0,0 @@-import { StrictMode } from 'react';-import { render } from '@testing-library/react';--import { ClientConfigProviderEffect } from '@/client-config/components/ClientConfigProviderEffect';--const initializeClientConfig = jest.fn();--jest.mock('@/client-config/hooks/useClientConfig', () => ({- useClientConfig: () => ({ initializeClientConfig }),-}));--jest.mock('@/ui/utilities/state/jotai/hooks/useAtomState', () => ({- useAtomState: () => [{ isLoadedOnce: false, isLoading: false }, jest.fn()],-}));--it('initializes once when StrictMode replays startup effects', () => {- render(- <StrictMode>- <ClientConfigProviderEffect />- </StrictMode>,- );-- expect(initializeClientConfig).toHaveBeenCalledTimes(1);-});diff --git a/packages/twenty-front/src/modules/error-handler/components/__tests__/PromiseRejectionEffect.test.tsx b/packages/twenty-front/src/modules/error-handler/components/__tests__/PromiseRejectionEffect.test.tsxdeleted file mode 100644index db1d5be87c7..00000000000--- a/packages/twenty-front/src/modules/error-handler/components/__tests__/PromiseRejectionEffect.test.tsx+++ /dev/null@@ -1,76 +0,0 @@-import { render, waitFor } from '@testing-library/react';--import { PromiseRejectionEffect } from '@/error-handler/components/PromiseRejectionEffect';--jest.mock('@sentry/react', () => ({- captureException: jest.fn(),-}));--const mockEnqueueToast = jest.fn();--jest.mock('twenty-ui/components', () => ({- ...jest.requireActual('twenty-ui/components'),- useToast: () => ({ enqueueToast: mockEnqueueToast }),-}));--const { captureException } = jest.requireMock('@sentry/react');--const dispatchUnhandledRejection = (reason: unknown) => {- const event = new Event('unhandledrejection');- Object.defineProperty(event, 'reason', { value: reason });-- window.dispatchEvent(event);-};--describe('PromiseRejectionEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- render(<PromiseRejectionEffect />);- });-- it('should not toast a stale chunk error', async () => {- dispatchUnhandledRejection(new Error('Importing a module script failed.'));-- await waitFor(() => {- expect(captureException).toHaveBeenCalledTimes(1);- });-- expect(mockEnqueueToast).not.toHaveBeenCalled();- });-- it('should still toast an unrelated error', async () => {- dispatchUnhandledRejection(new Error('Some unrelated error'));-- expect(mockEnqueueToast).toHaveBeenCalledWith({- variant: 'error',- children: 'Some unrelated error',- });-- await waitFor(() => {- expect(captureException).toHaveBeenCalledTimes(1);- });- });-- it('should not toast an abort error', async () => {- dispatchUnhandledRejection({ name: 'AbortError' });-- await waitFor(() => {- expect(captureException).toHaveBeenCalledTimes(1);- });-- expect(mockEnqueueToast).not.toHaveBeenCalled();- });-- it('should toast a generic message when the reason is not an Error', async () => {- dispatchUnhandledRejection('something went wrong');-- expect(mockEnqueueToast).toHaveBeenCalledWith({- variant: 'error',- children: 'An error occurred.',- });-- await waitFor(() => {- expect(captureException).toHaveBeenCalledTimes(1);- });- });-});diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/__tests__/RecordIndexLoadBaseOnContextStoreEffect.test.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/__tests__/RecordIndexLoadBaseOnContextStoreEffect.test.tsxdeleted file mode 100644index 438e5afe209..00000000000--- a/packages/twenty-front/src/modules/object-record/record-index/components/__tests__/RecordIndexLoadBaseOnContextStoreEffect.test.tsx+++ /dev/null@@ -1,114 +0,0 @@-import { render } from '@testing-library/react';--import { RecordIndexLoadBaseOnContextStoreEffect } from '@/object-record/record-index/components/RecordIndexLoadBaseOnContextStoreEffect';--jest.mock(- '@/object-record/record-index/hooks/useLoadRecordIndexStates',- () => ({- useLoadRecordIndexStates: jest.fn(),- }),-);-jest.mock(- '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue',- () => ({- useAtomComponentStateValue: jest.fn(),- }),-);-jest.mock(- '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue',- () => ({- useAtomFamilySelectorValue: jest.fn(),- }),-);-jest.mock(- '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow',- () => ({- useContextStoreObjectMetadataItemOrThrow: jest.fn(),- }),-);--const useLoadRecordIndexStatesMock = jest.requireMock(- '@/object-record/record-index/hooks/useLoadRecordIndexStates',-).useLoadRecordIndexStates;-const useAtomComponentStateValueMock = jest.requireMock(- '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue',-).useAtomComponentStateValue;-const useAtomFamilySelectorValueMock = jest.requireMock(- '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue',-).useAtomFamilySelectorValue;-const useContextStoreObjectMetadataItemOrThrowMock = jest.requireMock(- '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow',-).useContextStoreObjectMetadataItemOrThrow;--describe('RecordIndexLoadBaseOnContextStoreEffect', () => {- const loadRecordIndexStates = jest.fn();- const view = { id: 'view-id' };- const objectMetadataItem = { id: 'object-metadata-id' };-- beforeEach(() => {- jest.clearAllMocks();- useLoadRecordIndexStatesMock.mockReturnValue({ loadRecordIndexStates });- useAtomComponentStateValueMock.mockReturnValue('view-id');- useAtomFamilySelectorValueMock.mockReturnValue(view);- useContextStoreObjectMetadataItemOrThrowMock.mockReturnValue({- objectMetadataItem,- });- });-- it('does not reload an unchanged view', () => {- const { rerender } = render(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(1);- expect(loadRecordIndexStates).toHaveBeenLastCalledWith(- view,- objectMetadataItem,- );-- rerender(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(1);- });-- it('reloads the persisted view state when the view groups change', () => {- const viewWithGroups = {- id: 'view-id',- viewGroups: [{ id: 'group-1' }],- };- useAtomFamilySelectorValueMock.mockReturnValue(viewWithGroups);-- const { rerender } = render(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(1);-- rerender(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(1);-- useAtomFamilySelectorValueMock.mockReturnValue({- ...viewWithGroups,- viewGroups: [...viewWithGroups.viewGroups, { id: 'group-2' }],- });- rerender(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(2);- });-- it('does not reload when the view groups are only reordered', () => {- useAtomFamilySelectorValueMock.mockReturnValue({- id: 'view-id',- viewGroups: [{ id: 'group-1' }, { id: 'group-2' }],- });-- const { rerender } = render(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(1);-- useAtomFamilySelectorValueMock.mockReturnValue({- id: 'view-id',- viewGroups: [{ id: 'group-2' }, { id: 'group-1' }],- });- rerender(<RecordIndexLoadBaseOnContextStoreEffect />);-- expect(loadRecordIndexStates).toHaveBeenCalledTimes(1);- });-});diff --git a/packages/twenty-front/src/modules/object-record/record-list/components/__tests__/RecordListUpsertRecordsInStoreEffect.test.tsx b/packages/twenty-front/src/modules/object-record/record-list/components/__tests__/RecordListUpsertRecordsInStoreEffect.test.tsxdeleted file mode 100644index 116acbb772a..00000000000--- a/packages/twenty-front/src/modules/object-record/record-list/components/__tests__/RecordListUpsertRecordsInStoreEffect.test.tsx+++ /dev/null@@ -1,25 +0,0 @@-import { render, waitFor } from '@testing-library/react';--import { RecordListUpsertRecordsInStoreEffect } from '@/object-record/record-list/components/RecordListUpsertRecordsInStoreEffect';--const upsertRecordsInStore = jest.fn();--jest.mock('@/object-record/record-store/hooks/useUpsertRecordsInStore', () => ({- useUpsertRecordsInStore: () => ({ upsertRecordsInStore }),-}));--describe('RecordListUpsertRecordsInStoreEffect', () => {- it('hydrates partial records for consumers of the shared record store', async () => {- const records = [- { id: 'note-id', __typename: 'Note', title: 'Quarterly plan' },- ];-- render(<RecordListUpsertRecordsInStoreEffect records={records} />);-- await waitFor(() => {- expect(upsertRecordsInStore).toHaveBeenCalledWith({- partialRecords: records,- });- });- });-});diff --git a/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/__tests__/WelcomeAnimationAutoLeaveEffect.test.tsx b/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/__tests__/WelcomeAnimationAutoLeaveEffect.test.tsxdeleted file mode 100644index 73df5b5c5b9..00000000000--- a/packages/twenty-front/src/modules/onboarding/components/WelcomeOverlay/__tests__/WelcomeAnimationAutoLeaveEffect.test.tsx+++ /dev/null@@ -1,88 +0,0 @@-import { act, render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { type ReactNode } from 'react';--import { WelcomeAnimationAutoLeaveEffect } from '@/onboarding/components/WelcomeOverlay/WelcomeAnimationAutoLeaveEffect';-import { WELCOME_TITLE_HANDOFF_TARGET_ELEMENT_ID } from '@/onboarding/constants/WelcomeTitleHandoffTargetElementId';-import { isWelcomeAnimationLeavingState } from '@/onboarding/states/isWelcomeAnimationLeavingState';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>-);--const addHandoffTarget = () => {- const target = document.createElement('div');- target.id = WELCOME_TITLE_HANDOFF_TARGET_ELEMENT_ID;- document.body.appendChild(target);-};--const isLeaving = () => jotaiStore.get(isWelcomeAnimationLeavingState.atom);--describe('WelcomeAnimationAutoLeaveEffect', () => {- beforeEach(() => {- resetJotaiStore();- jest.useFakeTimers();- document.body.innerHTML = '';- });-- afterEach(() => {- jest.useRealTimers();- });-- it('should leave at the minimum hold once the handoff target exists', () => {- addHandoffTarget();- render(<WelcomeAnimationAutoLeaveEffect />, { wrapper: Wrapper });-- act(() => {- jest.advanceTimersByTime(2899);- });- expect(isLeaving()).toBe(false);-- act(() => {- jest.advanceTimersByTime(1);- });- expect(isLeaving()).toBe(true);- });-- it('should hold for the minimum until the target appears', () => {- render(<WelcomeAnimationAutoLeaveEffect />, { wrapper: Wrapper });-- act(() => {- jest.advanceTimersByTime(2900);- });- expect(isLeaving()).toBe(false);- });-- it('should leave at the cap when the target never appears', () => {- render(<WelcomeAnimationAutoLeaveEffect />, { wrapper: Wrapper });-- act(() => {- jest.advanceTimersByTime(4999);- });- expect(isLeaving()).toBe(false);-- act(() => {- jest.advanceTimersByTime(1);- });- expect(isLeaving()).toBe(true);- });-- it('should not fire again after the cap once it has already left', () => {- addHandoffTarget();- render(<WelcomeAnimationAutoLeaveEffect />, { wrapper: Wrapper });-- act(() => {- jest.advanceTimersByTime(2900);- });- jotaiStore.set(isWelcomeAnimationLeavingState.atom, false);-- act(() => {- jest.advanceTimersByTime(5000);- });- expect(isLeaving()).toBe(false);- });-});diff --git a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/BookCallBookingSuccessEffect.test.tsx b/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/BookCallBookingSuccessEffect.test.tsxdeleted file mode 100644index 9dd0dfdf161..00000000000--- a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/BookCallBookingSuccessEffect.test.tsx+++ /dev/null@@ -1,68 +0,0 @@-import { act, render } from '@testing-library/react';--import { BookCallBookingSuccessEffect } from '@/onboarding/effect-components/BookCallBookingSuccessEffect';--const mockCalApi = jest.fn();--jest.mock('@calcom/embed-react', () => ({- getCalApi: () => Promise.resolve(mockCalApi),-}));--const renderEffect = async (onBookingSuccessful: () => void) => {- const view = render(- <BookCallBookingSuccessEffect onBookingSuccessful={onBookingSuccessful} />,- );-- await act(async () => {- await Promise.resolve();- });-- const subscription = mockCalApi.mock.calls.find(- ([action]) => action === 'on',- );-- return {- view,- emitBookingSuccessful: subscription?.[1].callback as () => void,- };-};--describe('BookCallBookingSuccessEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- });-- it('should subscribe to the booking success event', async () => {- const onBookingSuccessful = jest.fn();-- const { emitBookingSuccessful } = await renderEffect(onBookingSuccessful);-- expect(emitBookingSuccessful).toBeDefined();- });-- it('should notify once even when the embed emits repeatedly', async () => {- const onBookingSuccessful = jest.fn();-- const { emitBookingSuccessful } = await renderEffect(onBookingSuccessful);-- act(() => {- emitBookingSuccessful();- emitBookingSuccessful();- });-- expect(onBookingSuccessful).toHaveBeenCalledTimes(1);- });-- it('should unsubscribe on unmount so listeners cannot stack up', async () => {- const onBookingSuccessful = jest.fn();-- const { view } = await renderEffect(onBookingSuccessful);-- view.unmount();-- expect(mockCalApi).toHaveBeenCalledWith(- 'off',- expect.objectContaining({ action: 'bookingSuccessfulV2' }),- );- });-});diff --git a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/CompanyEnrichmentOnboardingEffect.test.tsx b/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/CompanyEnrichmentOnboardingEffect.test.tsxdeleted file mode 100644index 9123be90247..00000000000--- a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/CompanyEnrichmentOnboardingEffect.test.tsx+++ /dev/null@@ -1,454 +0,0 @@-import { MockedProvider } from '@apollo/client/testing/react';-import { act, render } from '@testing-library/react';-import { GraphQLError } from 'graphql';-import { Provider as JotaiProvider } from 'jotai';-import {- type WorkspaceCompanyEnrichment,- type WorkspacePersonEnrichment,-} from 'twenty-shared/workspace';--import { currentUserState } from '@/auth/states/currentUserState';-import { isCompanyEnrichmentEnabledState } from '@/client-config/states/isCompanyEnrichmentEnabledState';-import { CompanyEnrichmentOnboardingEffect } from '@/onboarding/effect-components/CompanyEnrichmentOnboardingEffect';-import { companyEnrichmentState } from '@/onboarding/states/companyEnrichmentState';-import { hasAttemptedCompanyEnrichmentFetchState } from '@/onboarding/states/hasAttemptedCompanyEnrichmentFetchState';-import { personEnrichmentState } from '@/onboarding/states/personEnrichmentState';-import { getIsBookCallOnboardingStepPending } from '@/onboarding/utils/getIsBookCallOnboardingStepPending';-import { waitForCompanyEnrichmentSettlement } from '@/onboarding/utils/waitForCompanyEnrichmentSettlement';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';-import {- CompleteBookCallOnboardingStepDocument,- EnrichWorkspaceCompanyDocument,- OnboardingStatus,-} from '~/generated-metadata/graphql';--const mockOnboardingStatus = jest.fn();--jest.mock('@/onboarding/hooks/useOnboardingStatus', () => ({- useOnboardingStatus: () => mockOnboardingStatus(),-}));--const enrichment: WorkspaceCompanyEnrichment = {- domain: 'acme.com',- enrichedAt: '2026-07-21T10:00:00.000Z',- name: 'Acme Inc',- website: null,- industry: null,- employeeCount: null,- size: null,- founded: null,- headline: null,- summary: null,- tags: [],- locality: null,- region: null,- country: null,-};--const personEnrichment: WorkspacePersonEnrichment = {- email: '[email protected]',- enrichedAt: '2026-07-21T10:00:00.000Z',- fullName: 'Ada Lovelace',- jobTitle: 'Head of Sales',- jobTitleLevels: [],- jobCompanyName: null,- industry: null,- headline: null,- linkedinUrl: null,- skills: [],- locality: null,- region: null,- country: null,-};--const buildEnrichMock = ({- outcome,- enrichmentPayload,- countCall,- isBookCallOnboardingStepPending = false,- personOutcome = 'unavailable',- personEnrichmentPayload = null,-}: {- outcome: string;- enrichmentPayload: WorkspaceCompanyEnrichment | null;- countCall: () => void;- isBookCallOnboardingStepPending?: boolean;- personOutcome?: string;- personEnrichmentPayload?: WorkspacePersonEnrichment | null;-}) => ({- request: { query: EnrichWorkspaceCompanyDocument },- result: () => {- countCall();-- return {- data: {- enrichWorkspaceCompany: {- __typename: 'WorkspaceCompanyEnrichmentResult',- outcome,- enrichment: enrichmentPayload,- personOutcome,- personEnrichment: personEnrichmentPayload,- isBookCallOnboardingStepPending,- },- },- };- },-});--const renderEffect = (mocks: readonly unknown[]) =>- render(- <MockedProvider mocks={mocks as never}>- <JotaiProvider store={jotaiStore}>- <CompanyEnrichmentOnboardingEffect />- </JotaiProvider>- </MockedProvider>,- );--const flushMutation = async () => {- await act(async () => {- await new Promise((resolve) => setTimeout(resolve, 100));- });-};--describe('CompanyEnrichmentOnboardingEffect', () => {- beforeEach(() => {- resetJotaiStore();- localStorage.clear();- sessionStorage.clear();- mockOnboardingStatus.mockReturnValue(OnboardingStatus.PROFILE_CREATION);- jotaiStore.set(isCompanyEnrichmentEnabledState.atom, true);- });-- it('does not fetch when enrichment has no consumer or api key', async () => {- jotaiStore.set(isCompanyEnrichmentEnabledState.atom, false);-- let callCount = 0;- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {- callCount += 1;- },- }),- ]);-- await flushMutation();-- expect(callCount).toBe(0);- expect(jotaiStore.get(companyEnrichmentState.atom)).toBeNull();- expect(jotaiStore.get(hasAttemptedCompanyEnrichmentFetchState.atom)).toBe(- false,- );- });-- afterEach(() => {- jest.clearAllMocks();- });-- it('fetches once during onboarding and stores a matched enrichment', async () => {- let callCount = 0;- const { rerender } = renderEffect([- {- ...buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {- callCount += 1;- },- }),- maxUsageCount: 2,- },- ]);-- await flushMutation();-- rerender(- <MockedProvider mocks={[] as never}>- <JotaiProvider store={jotaiStore}>- <CompanyEnrichmentOnboardingEffect />- </JotaiProvider>- </MockedProvider>,- );- await flushMutation();-- expect(callCount).toBe(1);- expect(jotaiStore.get(companyEnrichmentState.atom)).toMatchObject({- domain: 'acme.com',- name: 'Acme Inc',- });- expect(jotaiStore.get(hasAttemptedCompanyEnrichmentFetchState.atom)).toBe(- true,- );- });-- it('stays unsettled for a waiter while the fetch is in flight', async () => {- let hasSettled = false;-- void waitForCompanyEnrichmentSettlement({- store: jotaiStore,- timeoutMs: 10_000,- }).then(() => {- hasSettled = true;- });-- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {},- }),- ]);-- await act(async () => {- await Promise.resolve();- });-- expect(jotaiStore.get(hasAttemptedCompanyEnrichmentFetchState.atom)).toBe(- true,- );- expect(hasSettled).toBe(false);-- await flushMutation();-- expect(hasSettled).toBe(true);- });-- it.each([OnboardingStatus.COMPLETED, OnboardingStatus.WORKSPACE_ACTIVATION])(- 'does not fetch when the onboarding status is %s',- async (status) => {- mockOnboardingStatus.mockReturnValue(status);-- let callCount = 0;- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {- callCount += 1;- },- }),- ]);-- await flushMutation();-- expect(callCount).toBe(0);- expect(jotaiStore.get(companyEnrichmentState.atom)).toBeNull();- },- );-- it('does not fetch when an enrichment is already stored', async () => {- jotaiStore.set(companyEnrichmentState.atom, enrichment);-- let callCount = 0;- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {- callCount += 1;- },- }),- ]);-- await flushMutation();-- expect(callCount).toBe(0);- });-- it.each(['transientError', 'unavailable'])(- 'stores nothing on a %s outcome',- async (outcome) => {- let callCount = 0;- renderEffect([- buildEnrichMock({- outcome,- enrichmentPayload: null,- countCall: () => {- callCount += 1;- },- }),- ]);-- await flushMutation();-- expect(callCount).toBe(1);- expect(jotaiStore.get(companyEnrichmentState.atom)).toBeNull();- expect(jotaiStore.get(hasAttemptedCompanyEnrichmentFetchState.atom)).toBe(- true,- );- },- );-- it('records the pending book-call step reported by the server', async () => {- jotaiStore.set(currentUserState.atom, { id: 'user-id' } as never);-- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {},- isBookCallOnboardingStepPending: true,- }),- ]);-- await flushMutation();-- expect(- getIsBookCallOnboardingStepPending(jotaiStore.get(currentUserState.atom)),- ).toBe(true);- });-- it('records the pending book-call step even when the enrichment did not match', async () => {- jotaiStore.set(currentUserState.atom, { id: 'user-id' } as never);-- renderEffect([- buildEnrichMock({- outcome: 'transientError',- enrichmentPayload: null,- countCall: () => {},- isBookCallOnboardingStepPending: true,- }),- ]);-- await flushMutation();-- expect(- getIsBookCallOnboardingStepPending(jotaiStore.get(currentUserState.atom)),- ).toBe(true);- });-- it('drops a pending book-call step that lands after the user advanced past it', async () => {- mockOnboardingStatus.mockReturnValue(OnboardingStatus.PROFILE_CREATION);- jotaiStore.set(currentUserState.atom, {- id: 'user-id',- onboardingStatus: OnboardingStatus.PLAN_REQUIRED,- } as never);-- let hasClearedBookCallStep = false;-- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {},- isBookCallOnboardingStepPending: true,- }),- {- request: {- query: CompleteBookCallOnboardingStepDocument,- variables: { hasBookedCall: false, isAutoSkipped: true },- },- result: () => {- hasClearedBookCallStep = true;-- return {- data: {- completeBookCallOnboardingStep: {- __typename: 'OnboardingStepSuccess',- success: true,- },- },- };- },- },- ]);-- await flushMutation();-- expect(- getIsBookCallOnboardingStepPending(jotaiStore.get(currentUserState.atom)),- ).toBe(false);- expect(hasClearedBookCallStep).toBe(true);- expect(jotaiStore.get(companyEnrichmentState.atom)).toMatchObject({- domain: 'acme.com',- });- });-- it('keeps the step pending locally when clearing it on the server fails', async () => {- jotaiStore.set(currentUserState.atom, {- id: 'user-id',- onboardingStatus: OnboardingStatus.PLAN_REQUIRED,- } as never);-- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {},- isBookCallOnboardingStepPending: true,- }),- {- request: { query: CompleteBookCallOnboardingStepDocument },- result: { errors: [new GraphQLError('Internal server error')] },- },- ]);-- await flushMutation();-- // The server still has the offer, so local state must not claim otherwise.- expect(- getIsBookCallOnboardingStepPending(jotaiStore.get(currentUserState.atom)),- ).toBe(true);- expect(jotaiStore.get(companyEnrichmentState.atom)).toMatchObject({- domain: 'acme.com',- });- });-- it('stores a matched person enrichment alongside the company one', async () => {- renderEffect([- buildEnrichMock({- outcome: 'unavailable',- enrichmentPayload: null,- countCall: () => {},- personOutcome: 'matched',- personEnrichmentPayload: personEnrichment,- }),- ]);-- await flushMutation();-- expect(jotaiStore.get(personEnrichmentState.atom)).toMatchObject({- email: '[email protected]',- jobTitle: 'Head of Sales',- });- expect(jotaiStore.get(companyEnrichmentState.atom)).toBeNull();- });-- it('stores no person enrichment on a non-matched person outcome', async () => {- renderEffect([- buildEnrichMock({- outcome: 'matched',- enrichmentPayload: enrichment,- countCall: () => {},- personOutcome: 'unavailable',- }),- ]);-- await flushMutation();-- expect(jotaiStore.get(personEnrichmentState.atom)).toBeNull();- expect(jotaiStore.get(companyEnrichmentState.atom)).toMatchObject({- domain: 'acme.com',- });- });-- it('stores nothing when the mutation fails', async () => {- renderEffect([- {- request: { query: EnrichWorkspaceCompanyDocument },- result: { errors: [new GraphQLError('Internal server error')] },- },- ]);-- await flushMutation();-- expect(jotaiStore.get(companyEnrichmentState.atom)).toBeNull();- expect(jotaiStore.get(hasAttemptedCompanyEnrichmentFetchState.atom)).toBe(- true,- );- });-});diff --git a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/PrefetchBookCallStepEffect.test.tsx b/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/PrefetchBookCallStepEffect.test.tsxdeleted file mode 100644index b3583a70e69..00000000000--- a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/PrefetchBookCallStepEffect.test.tsx+++ /dev/null@@ -1,103 +0,0 @@-import { act, render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';--import { currentUserState } from '@/auth/states/currentUserState';-import { calendarBookingPageIdState } from '@/client-config/states/calendarBookingPageIdState';-import { isBookCallOnboardingStepEnabledState } from '@/client-config/states/isBookCallOnboardingStepEnabledState';-import { ONBOARDING_BOOK_CALL_PENDING_USER_VAR_KEY } from '@/onboarding/constants/OnboardingBookCallPendingUserVarKey';-import { PrefetchBookCallStepEffect } from '@/onboarding/effect-components/PrefetchBookCallStepEffect';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--const mockCalApi = jest.fn();--jest.mock('@calcom/embed-react', () => ({- getCalApi: () => Promise.resolve(mockCalApi),-}));--const renderEffect = async ({- isBookCallOnboardingStepEnabled,- isBookCallOnboardingStepPending,- calendarBookingPageId,-}: {- isBookCallOnboardingStepEnabled: boolean;- isBookCallOnboardingStepPending: boolean;- calendarBookingPageId: string | null;-}) => {- jotaiStore.set(- isBookCallOnboardingStepEnabledState.atom,- isBookCallOnboardingStepEnabled,- );- jotaiStore.set(calendarBookingPageIdState.atom, calendarBookingPageId);- jotaiStore.set(currentUserState.atom, {- id: 'user-id',- userVars: {- [ONBOARDING_BOOK_CALL_PENDING_USER_VAR_KEY]:- isBookCallOnboardingStepPending,- },- } as never);-- render(- <JotaiProvider store={jotaiStore}>- <PrefetchBookCallStepEffect />- </JotaiProvider>,- );-- await act(async () => {- await Promise.resolve();- });-};--const getPreloadCalls = () =>- mockCalApi.mock.calls.filter(([action]) => action === 'preload');--describe('PrefetchBookCallStepEffect', () => {- beforeEach(() => {- resetJotaiStore();- jest.clearAllMocks();- });-- it('should warm the booking page when the step is pending and configured', async () => {- await renderEffect({- isBookCallOnboardingStepEnabled: true,- isBookCallOnboardingStepPending: true,- calendarBookingPageId: 'team/twenty/talk-to-us',- });-- expect(getPreloadCalls()).toEqual([- ['preload', { calLink: 'team/twenty/talk-to-us' }],- ]);- });-- it('should not warm anything when the user is not pending the step', async () => {- await renderEffect({- isBookCallOnboardingStepEnabled: true,- isBookCallOnboardingStepPending: false,- calendarBookingPageId: 'team/twenty/talk-to-us',- });-- expect(getPreloadCalls()).toHaveLength(0);- });-- it('should not warm anything when the step is disabled', async () => {- await renderEffect({- isBookCallOnboardingStepEnabled: false,- isBookCallOnboardingStepPending: true,- calendarBookingPageId: 'team/twenty/talk-to-us',- });-- expect(getPreloadCalls()).toHaveLength(0);- });-- it('should not warm anything without a booking page', async () => {- await renderEffect({- isBookCallOnboardingStepEnabled: true,- isBookCallOnboardingStepPending: true,- calendarBookingPageId: null,- });-- expect(getPreloadCalls()).toHaveLength(0);- });-});diff --git a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/WorkspaceSetupChatKickoffEffect.test.tsx b/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/WorkspaceSetupChatKickoffEffect.test.tsxdeleted file mode 100644index 5ad7c1d6c49..00000000000--- a/packages/twenty-front/src/modules/onboarding/effect-components/__tests__/WorkspaceSetupChatKickoffEffect.test.tsx+++ /dev/null@@ -1,368 +0,0 @@-import { MockedProvider } from '@apollo/client/testing/react';-import { act, render } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { StrictMode } from 'react';-import {- type WorkspaceCompanyEnrichment,- type WorkspacePersonEnrichment,-} from 'twenty-shared/workspace';--import { AGENT_CHAT_INSTANCE_ID } from '@/ai/constants/AgentChatInstanceId';-import { agentChatIsAwaitingFirstChunkComponentFamilyState } from '@/ai/states/agentChatIsAwaitingFirstChunkComponentFamilyState';-import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';-import { currentAiChatThreadTitleComponentFamilyState } from '@/ai/states/currentAiChatThreadTitleComponentFamilyState';-import { hasInitializedAgentChatThreadsState } from '@/ai/states/hasInitializedAgentChatThreadsState';-import { skipMessagesSkeletonUntilLoadedState } from '@/ai/states/skipMessagesSkeletonUntilLoadedState';-import { WorkspaceSetupChatKickoffEffect } from '@/onboarding/effect-components/WorkspaceSetupChatKickoffEffect';-import { shouldOpenAiChatAfterOnboardingState } from '@/onboarding/states/shouldOpenAiChatAfterOnboardingState';-import { companyEnrichmentState } from '@/onboarding/states/companyEnrichmentState';-import { isCompanyEnrichmentFetchInFlightState } from '@/onboarding/states/isCompanyEnrichmentFetchInFlightState';-import { personEnrichmentState } from '@/onboarding/states/personEnrichmentState';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';-import { StartWorkspaceSetupChatDocument } from '~/generated-metadata/graphql';--const threadId = '20202020-aaaa-4aaa-8aaa-202020202020';-const threadTitle = 'Configuration du workspace';--const enrichment: WorkspaceCompanyEnrichment = {- domain: 'acme.com',- enrichedAt: '2026-07-21T10:00:00.000Z',- name: 'Acme Inc',- website: null,- industry: null,- employeeCount: null,- size: null,- founded: null,- headline: null,- summary: null,- tags: [],- locality: null,- region: null,- country: null,-};--const buildKickoffMock = ({- outcome,- countCall,- captureVariables,-}: {- outcome: 'STARTED' | 'ALREADY_STARTED' | 'UNAVAILABLE';- countCall?: () => void;- captureVariables?: (variables: Record<string, unknown>) => void;-}) => ({- request: {- query: StartWorkspaceSetupChatDocument,- variables: (variables: Record<string, unknown>) => {- captureVariables?.(variables);- return true;- },- },- maxUsageCount: 2,- result: () => {- countCall?.();-- return {- data: {- startWorkspaceSetupChat: {- __typename: 'StartWorkspaceSetupChatResult',- outcome,- thread:- outcome === 'UNAVAILABLE'- ? null- : {- __typename: 'AgentChatThread',- id: threadId,- title: threadTitle,- totalInputTokens: 0,- totalOutputTokens: 0,- contextWindowTokens: null,- conversationSize: 0,- totalInputCredits: 0,- totalOutputCredits: 0,- deletedAt: null,- createdAt: '2026-07-21T10:00:00.000Z',- updatedAt: '2026-07-21T10:00:00.000Z',- },- },- },- };- },-});--const renderKickoffEffect = (mocks: readonly unknown[]) =>- render(- <MockedProvider mocks={mocks as never}>- <JotaiProvider store={jotaiStore}>- <StrictMode>- <WorkspaceSetupChatKickoffEffect />- </StrictMode>- </JotaiProvider>- </MockedProvider>,- );--const flushMutation = async () => {- await act(async () => {- await new Promise((resolve) => setTimeout(resolve, 100));- });-};--describe('WorkspaceSetupChatKickoffEffect', () => {- beforeEach(() => {- resetJotaiStore();- sessionStorage.clear();- localStorage.clear();- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);- });-- afterEach(() => {- jest.clearAllMocks();- });-- it('preserves the selected conversation when setup finishes after leaving onboarding', async () => {- const mocks = [{ ...buildKickoffMock({ outcome: 'STARTED' }), delay: 50 }];- const tree = (showSetup: boolean) => (- <MockedProvider mocks={mocks as never}>- <JotaiProvider store={jotaiStore}>- {showSetup && <WorkspaceSetupChatKickoffEffect />}- </JotaiProvider>- </MockedProvider>- );- const { rerender } = render(tree(true));-- act(() => {- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, false);- jotaiStore.set(currentAiChatThreadState.atom, 'new-conversation');- });- rerender(tree(false));- await flushMutation();-- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBe(- 'new-conversation',- );- expect(jotaiStore.get(skipMessagesSkeletonUntilLoadedState.atom)).toBe(- false,- );- });-- it('should wait for an in-flight company enrichment before starting the chat', async () => {- jotaiStore.set(isCompanyEnrichmentFetchInFlightState.atom, true);-- const capturedVariablesList: Record<string, unknown>[] = [];- let callCount = 0;-- renderKickoffEffect([- buildKickoffMock({- outcome: 'STARTED',- countCall: () => {- callCount += 1;- },- captureVariables: (variables) => {- capturedVariablesList.push(variables);- },- }),- ]);-- await flushMutation();-- expect(callCount).toBe(0);-- await act(async () => {- jotaiStore.set(companyEnrichmentState.atom, enrichment);- jotaiStore.set(isCompanyEnrichmentFetchInFlightState.atom, false);- });- await flushMutation();-- expect(callCount).toBe(1);- expect(capturedVariablesList[0].companyContext).toEqual(enrichment);- });-- it('should start the workspace setup chat only once when the effect renders twice', async () => {- let callCount = 0;- const { rerender } = renderKickoffEffect([- buildKickoffMock({- outcome: 'STARTED',- countCall: () => {- callCount += 1;- },- }),- ]);-- await flushMutation();-- rerender(- <MockedProvider mocks={[] as never}>- <JotaiProvider store={jotaiStore}>- <StrictMode>- <WorkspaceSetupChatKickoffEffect />- </StrictMode>- </JotaiProvider>- </MockedProvider>,- );- await flushMutation();-- expect(callCount).toBe(1);- });-- it('should select the thread with its server title and mark it awaiting the first chunk when the chat is started', async () => {- renderKickoffEffect([buildKickoffMock({ outcome: 'STARTED' })]);-- await flushMutation();-- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBe(threadId);- expect(jotaiStore.get(hasInitializedAgentChatThreadsState.atom)).toBe(true);- expect(jotaiStore.get(skipMessagesSkeletonUntilLoadedState.atom)).toBe(- true,- );- expect(- jotaiStore.get(- agentChatIsAwaitingFirstChunkComponentFamilyState.atomFamily({- instanceId: AGENT_CHAT_INSTANCE_ID,- familyKey: { threadId },- }),- ),- ).toBe(true);- expect(- jotaiStore.get(- currentAiChatThreadTitleComponentFamilyState.atomFamily({- instanceId: AGENT_CHAT_INSTANCE_ID,- familyKey: { threadId },- }),- ),- ).toBe(threadTitle);- });-- it('should select the thread without awaiting a first chunk when the chat was already started', async () => {- renderKickoffEffect([buildKickoffMock({ outcome: 'ALREADY_STARTED' })]);-- await flushMutation();-- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBe(threadId);- expect(- jotaiStore.get(- agentChatIsAwaitingFirstChunkComponentFamilyState.atomFamily({- instanceId: AGENT_CHAT_INSTANCE_ID,- familyKey: { threadId },- }),- ),- ).toBe(false);- });-- it('should pass the stored enrichment as the companyContext variable when one is stored', async () => {- jotaiStore.set(companyEnrichmentState.atom, enrichment);-- const capturedVariablesList: Record<string, unknown>[] = [];- renderKickoffEffect([- buildKickoffMock({- outcome: 'STARTED',- captureVariables: (variables) => {- capturedVariablesList.push(variables);- },- }),- ]);-- await flushMutation();-- expect(capturedVariablesList[0].companyContext).toEqual(enrichment);- });-- it('should send an undefined companyContext variable when no enrichment is stored', async () => {- const capturedVariablesList: Record<string, unknown>[] = [];- renderKickoffEffect([- buildKickoffMock({- outcome: 'STARTED',- captureVariables: (variables) => {- capturedVariablesList.push(variables);- },- }),- ]);-- await flushMutation();-- expect(capturedVariablesList.length).toBeGreaterThan(0);- expect(capturedVariablesList[0].companyContext).toBeUndefined();- expect(capturedVariablesList[0].personContext).toBeUndefined();- });-- it('should pass the stored person enrichment as the personContext variable when one is stored', async () => {- const personEnrichment: WorkspacePersonEnrichment = {- email: '[email protected]',- enrichedAt: '2026-07-21T10:00:00.000Z',- fullName: 'Ada Lovelace',- jobTitle: 'Head of Sales',- jobTitleLevels: [],- jobCompanyName: null,- industry: null,- headline: null,- linkedinUrl: null,- skills: [],- locality: null,- region: null,- country: null,- };-- jotaiStore.set(personEnrichmentState.atom, personEnrichment);-- const capturedVariablesList: Record<string, unknown>[] = [];- renderKickoffEffect([- buildKickoffMock({- outcome: 'STARTED',- captureVariables: (variables) => {- capturedVariablesList.push(variables);- },- }),- ]);-- await flushMutation();-- expect(capturedVariablesList[0].personContext).toEqual(personEnrichment);- });-- it('should not touch the chat state when the chat is unavailable', async () => {- renderKickoffEffect([buildKickoffMock({ outcome: 'UNAVAILABLE' })]);-- await flushMutation();-- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBeNull();- expect(jotaiStore.get(hasInitializedAgentChatThreadsState.atom)).toBe(- false,- );- expect(jotaiStore.get(skipMessagesSkeletonUntilLoadedState.atom)).toBe(- false,- );- });-- it('should retry on a later effect run when the mutation fails', async () => {- let callCount = 0;-- renderKickoffEffect([- {- request: { query: StartWorkspaceSetupChatDocument },- error: new Error('Network error'),- },- buildKickoffMock({- outcome: 'STARTED',- countCall: () => {- callCount += 1;- },- }),- ]);-- await flushMutation();-- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBeNull();-- await act(async () => {- jotaiStore.set(isCompanyEnrichmentFetchInFlightState.atom, true);- });- await act(async () => {- jotaiStore.set(isCompanyEnrichmentFetchInFlightState.atom, false);- });- await flushMutation();-- expect(callCount).toBe(1);- expect(jotaiStore.get(currentAiChatThreadState.atom)).toBe(threadId);- });-});diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutRecordPageCustomizationSessionRegistrationEffect.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutRecordPageCustomizationSessionRegistrationEffect.test.tsxdeleted file mode 100644index f186df5ac28..00000000000--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutRecordPageCustomizationSessionRegistrationEffect.test.tsx+++ /dev/null@@ -1,115 +0,0 @@-import { activeCustomizationPageLayoutIdsState } from '@/layout-customization/states/activeCustomizationPageLayoutIdsState';-import { isLayoutCustomizationModeEnabledState } from '@/layout-customization/states/isLayoutCustomizationModeEnabledState';-import { PageLayoutRecordPageCustomizationSessionRegistrationEffect } from '@/page-layout/components/PageLayoutRecordPageCustomizationSessionRegistrationEffect';-import { useIsPageLayoutInEditMode } from '@/page-layout/hooks/useIsPageLayoutInEditMode';-import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';-import { pageLayoutDraftComponentState } from '@/page-layout/states/pageLayoutDraftComponentState';-import { pageLayoutPersistedComponentState } from '@/page-layout/states/pageLayoutPersistedComponentState';-import {- makeDraft,- makeTab,- makeWidget,-} from '@/page-layout/testing/pageLayoutDraftFixtures';-import { type PageLayout } from '@/page-layout/types/PageLayout';-import { render, waitFor } from '@testing-library/react';-import { createStore, Provider as JotaiProvider } from 'jotai';-import { PageLayoutType, WidgetType } from '~/generated-metadata/graphql';--const PAGE_LAYOUT_ID = 'page-layout-id';--jest.mock('@/page-layout/hooks/useIsPageLayoutInEditMode');--const mockUseIsPageLayoutInEditMode =- useIsPageLayoutInEditMode as jest.MockedFunction<- typeof useIsPageLayoutInEditMode- >;--const setupPageLayout = () => {- const store = createStore();- const timelineWidget = {- ...makeWidget('timeline', 0),- type: WidgetType.TIMELINE,- };- const fieldsWidget = makeWidget('fields', 1);- const verticalListTab = makeTab('vertical-list-tab', [- timelineWidget,- fieldsWidget,- ]);- const persistedPageLayout = {- id: PAGE_LAYOUT_ID,- name: 'Record Page',- type: PageLayoutType.RECORD_PAGE,- objectMetadataId: 'object-metadata-id',- tabs: [verticalListTab],- } as PageLayout;-- store.set(isLayoutCustomizationModeEnabledState.atom, true);- store.set(- pageLayoutPersistedComponentState.atomFamily({- instanceId: PAGE_LAYOUT_ID,- }),- persistedPageLayout,- );- store.set(- pageLayoutDraftComponentState.atomFamily({- instanceId: PAGE_LAYOUT_ID,- }),- makeDraft([verticalListTab]),- );-- return store;-};--const renderRegistrationEffect = (store: ReturnType<typeof createStore>) =>- render(- <JotaiProvider store={store}>- <PageLayoutComponentInstanceContext.Provider- value={{ instanceId: PAGE_LAYOUT_ID }}- >- <PageLayoutRecordPageCustomizationSessionRegistrationEffect />- </PageLayoutComponentInstanceContext.Provider>- </JotaiProvider>,- );--const getDraftWidgetIds = (store: ReturnType<typeof createStore>) =>- store- .get(- pageLayoutDraftComponentState.atomFamily({- instanceId: PAGE_LAYOUT_ID,- }),- )- .tabs[0].widgets.map((widget) => widget.id);--const waitForPageLayoutRegistration = (store: ReturnType<typeof createStore>) =>- waitFor(() => {- expect(store.get(activeCustomizationPageLayoutIdsState.atom)).toEqual([- PAGE_LAYOUT_ID,- ]);- });--describe('PageLayoutRecordPageCustomizationSessionRegistrationEffect', () => {- beforeEach(() => {- mockUseIsPageLayoutInEditMode.mockReturnValue(true);- });-- it('normalizes the draft when the record page enters edit mode', async () => {- const store = setupPageLayout();-- renderRegistrationEffect(store);-- await waitFor(() => {- expect(getDraftWidgetIds(store)).toEqual(['fields', 'timeline']);- });- await waitForPageLayoutRegistration(store);- });-- it('does not normalize a record page mounted outside edit mode', async () => {- mockUseIsPageLayoutInEditMode.mockReturnValue(false);- const store = setupPageLayout();-- renderRegistrationEffect(store);-- await waitForPageLayoutRegistration(store);- expect(getDraftWidgetIds(store)).toEqual(['timeline', 'fields']);- });-});diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsxdeleted file mode 100644index a1d9aeef115..00000000000--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabListEffect.test.tsx+++ /dev/null@@ -1,222 +0,0 @@-import { PageLayoutTabListEffect } from '@/page-layout/components/PageLayoutTabListEffect';-import { makeTab } from '@/page-layout/testing/pageLayoutDraftFixtures';-import { LayoutRenderingProvider } from '@/ui/layout/contexts/LayoutRenderingContext';-import { WorkspaceSurfaceContext } from '@/ui/layout/contexts/WorkspaceSurfaceContext';-import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';-import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext';-import { render, screen } from '@testing-library/react';-import { createStore, Provider } from 'jotai';-import { StrictMode } from 'react';-import { MemoryRouter, useLocation, useNavigationType } from 'react-router-dom';-import { PageLayoutType } from '~/generated-metadata/graphql';--const TAB_LIST_INSTANCE_ID = 'record-tabs';--const CurrentLocation = () => {- const { pathname, search, hash } = useLocation();- const navigationType = useNavigationType();-- return (- <>- <output aria-label="Current URL">{pathname + search + hash}</output>- <output aria-label="Navigation type">{navigationType}</output>- </>- );-};--describe('PageLayoutTabListEffect', () => {- it.each([- {- name: 'replaces the hash when the active tab becomes pinned',- activeTabId: 'home',- hash: '#home',- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '#timeline',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'REPLACE',- },- {- name: 'does not rewrite the main URL for a side-panel fallback',- activeTabId: 'home',- hash: '#home',- isInSidePanel: true,- ownsRouteLocation: false,- expectedHash: '#home',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'POP',- },- {- name: 'does not add a hash when there was no tab in the URL',- activeTabId: 'home',- hash: '',- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'POP',- },- {- name: 'preserves a valid deep link while replacing a stale active tab',- activeTabId: 'home',- hash: '#notes',- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '#notes',- expectedActiveTabId: 'notes',- expectedNavigationType: 'POP',- },- {- name: 'preserves a valid deep link on initial load',- activeTabId: null,- hash: '#notes',- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '#notes',- expectedActiveTabId: 'notes',- expectedNavigationType: 'POP',- },- {- name: 'keeps a valid active tab and its hash',- activeTabId: 'notes',- hash: '#notes',- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '#notes',- expectedActiveTabId: 'notes',- expectedNavigationType: 'POP',- },- {- name: 'honors a deep-linked tab in a routed side panel',- activeTabId: null,- hash: '#notes',- isInSidePanel: true,- ownsRouteLocation: true,- expectedHash: '#notes',- expectedActiveTabId: 'notes',- expectedNavigationType: 'POP',- },- {- name: 'replaces a stale hash in the current routed side-panel page',- activeTabId: 'home',- hash: '#home',- isInSidePanel: true,- ownsRouteLocation: true,- expectedHash: '#timeline',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'REPLACE',- },- {- name: 'ignores a deep link while editing',- activeTabId: 'timeline',- hash: '#notes',- isInEditMode: true,- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '#notes',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'POP',- },- {- name: 'does not rewrite a stale hash while editing',- activeTabId: 'home',- hash: '#home',- isInEditMode: true,- isInSidePanel: false,- ownsRouteLocation: true,- expectedHash: '#home',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'POP',- },- {- name: 'ignores the main URL when initializing an embedded side panel',- activeTabId: null,- hash: '#notes',- isInSidePanel: true,- ownsRouteLocation: false,- expectedHash: '#notes',- expectedActiveTabId: 'timeline',- expectedNavigationType: 'POP',- },- ])(- '$name',- ({- activeTabId,- hash,- isInSidePanel,- isInEditMode = false,- ownsRouteLocation,- expectedHash,- expectedActiveTabId,- expectedNavigationType,- }) => {- const store = createStore();- const onChangeTab = jest.fn();- const surfaceInstanceId = isInSidePanel ? 'side-panel-page-1' : 'main';- const activeTabAtom = activeTabIdComponentState.atomFamily({- instanceId: TAB_LIST_INSTANCE_ID,- });- store.set(activeTabAtom, activeTabId);-- render(- <StrictMode>- <Provider store={store}>- <MemoryRouter- initialEntries={[- `/object/company/record-id?viewId=company-view${hash}`,- ]}- >- <WorkspaceSurfaceContext.Provider- value={{- type: isInSidePanel ? 'side-panel' : 'main',- instanceId: surfaceInstanceId,- ownsRouteLocation,- }}- >- <LayoutRenderingProvider- value={{- layoutType: PageLayoutType.RECORD_PAGE,- targetRecordIdentifier: {- id: 'record-id',- targetObjectNameSingular: 'company',- },- }}- >- <TabListComponentInstanceContext.Provider- value={{- instanceId: TAB_LIST_INSTANCE_ID,- }}- >- <PageLayoutTabListEffect- isInEditMode={isInEditMode}- onChangeTab={onChangeTab}- tabs={[makeTab('timeline', []), makeTab('notes', [], 1)]}- componentInstanceId={TAB_LIST_INSTANCE_ID}- />- <CurrentLocation />- </TabListComponentInstanceContext.Provider>- </LayoutRenderingProvider>- </WorkspaceSurfaceContext.Provider>- </MemoryRouter>- </Provider>- </StrictMode>,- );-- expect(- screen.getByRole('status', { name: 'Current URL' }),- ).toHaveTextContent(- `/object/company/record-id?viewId=company-view${expectedHash}`,- );- expect(store.get(activeTabAtom)).toBe(expectedActiveTabId);- expect(onChangeTab).toHaveBeenCalledTimes(- activeTabId === expectedActiveTabId ? 0 : 1,- );- if (activeTabId !== expectedActiveTabId) {- expect(onChangeTab).toHaveBeenCalledWith(expectedActiveTabId);- }- expect(- screen.getByRole('status', { name: 'Navigation type' }),- ).toHaveTextContent(expectedNavigationType);- },- );-});diff --git a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelAskAiHandoffEffect.test.tsx b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelAskAiHandoffEffect.test.tsxdeleted file mode 100644index 6e4082c8403..00000000000--- a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelAskAiHandoffEffect.test.tsx+++ /dev/null@@ -1,174 +0,0 @@-import { act, render, screen } from '@testing-library/react';-import { Provider as JotaiProvider } from 'jotai';-import { MemoryRouter, Route, Routes, useNavigate } from 'react-router-dom';--import { AiChatPageContinueInSidePanelEffect } from '@/ai/components/AiChatPageContinueInSidePanelEffect';-import { shouldContinueAiChatInSidePanelState } from '@/ai/states/shouldContinueAiChatInSidePanelState';-import { shouldOpenAiChatAfterOnboardingState } from '@/onboarding/states/shouldOpenAiChatAfterOnboardingState';-import { WorkspaceSetupChatSidePanelEffect } from '@/onboarding/effect-components/WorkspaceSetupChatSidePanelEffect';-import { SidePanelAskAiHandoffEffect } from '@/side-panel/components/SidePanelAskAiHandoffEffect';-import {- jotaiStore,- resetJotaiStore,-} from '@/ui/utilities/state/jotai/jotaiStore';--let defaultHomePagePath = '/objects/companies';-jest.mock('@/navigation/hooks/useDefaultHomePagePath', () => ({- useDefaultHomePagePath: () => ({ defaultHomePagePath }),-}));--const openAskAiPageMock = jest.fn();--jest.mock('@/side-panel/hooks/useOpenAskAiPageInSidePanel', () => ({- useOpenAskAiPageInSidePanel: () => ({ openAskAiPage: openAskAiPageMock }),-}));--const onContinueChatFromFullWidthMock = jest.fn();--let navigateAwayFromChatPage: ((pathname?: string) => void) | undefined;--const ChatPageRoute = () => {- const navigate = useNavigate();-- navigateAwayFromChatPage = (pathname = '/objects/companies') =>- navigate(pathname);-- return (- <>- <AiChatPageContinueInSidePanelEffect />- <div>Setup conversation</div>- </>- );-};--const RouterUnderTest = ({ initialPath }: { initialPath: string }) => (- <JotaiProvider store={jotaiStore}>- <MemoryRouter initialEntries={[initialPath]}>- {/* The handoff lives in the persistent layout, outside the routes. */}- <WorkspaceSetupChatSidePanelEffect />- <SidePanelAskAiHandoffEffect- onContinueChatFromFullWidth={onContinueChatFromFullWidthMock}- />- <Routes>- <Route path="/chat/:threadId?" element={<ChatPageRoute />} />- <Route- path="/objects/companies"- element={<div>Companies homepage</div>}- />- <Route path="/settings/*" element={<div />} />- </Routes>- </MemoryRouter>- </JotaiProvider>-);--describe('SidePanelAskAiHandoffEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- sessionStorage.clear();- resetJotaiStore();- navigateAwayFromChatPage = undefined;- defaultHomePagePath = '/objects/companies';- });-- it('opens setup on the homepage after returning to settings', () => {- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);- render(<RouterUnderTest initialPath="/settings/profile" />);- expect(screen.getByText('Companies homepage')).toBeInTheDocument();- expect(openAskAiPageMock).toHaveBeenCalledTimes(1);- });-- it('uses the chat page when no readable object homepage exists', () => {- defaultHomePagePath = '/settings/profile';- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);- render(<RouterUnderTest initialPath="/settings/profile" />);- expect(screen.getByText('Setup conversation')).toBeInTheDocument();- expect(openAskAiPageMock).not.toHaveBeenCalled();- expect(jotaiStore.get(shouldOpenAiChatAfterOnboardingState.atom)).toBe(- true,- );- });-- it('preserves dismissal across remounts but opens again after an application reload', () => {- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);- const first = render(<RouterUnderTest initialPath="/objects/companies" />);- first.unmount();- const second = render(<RouterUnderTest initialPath="/objects/companies" />);- expect(openAskAiPageMock).toHaveBeenCalledTimes(1);- second.unmount();- resetJotaiStore();- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);- render(<RouterUnderTest initialPath="/objects/companies" />);- expect(openAskAiPageMock).toHaveBeenCalledTimes(2);- });-- it('should continue the chat in the side panel on the navigation leaving the chat page', () => {- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);-- render(<RouterUnderTest initialPath="/chat" />);-- expect(jotaiStore.get(shouldContinueAiChatInSidePanelState.atom)).toBe(- true,- );- expect(openAskAiPageMock).not.toHaveBeenCalled();-- act(() => {- navigateAwayFromChatPage?.();- });-- expect(openAskAiPageMock).toHaveBeenCalledTimes(1);- expect(openAskAiPageMock).toHaveBeenCalledWith({- resetNavigationStack: true,- });- expect(onContinueChatFromFullWidthMock).toHaveBeenCalled();- expect(jotaiStore.get(shouldContinueAiChatInSidePanelState.atom)).toBe(- false,- );- expect(jotaiStore.get(shouldOpenAiChatAfterOnboardingState.atom)).toBe(- false,- );- });-- it('should stay silent when the continuation marker was cleared before leaving', () => {- render(<RouterUnderTest initialPath="/chat" />);-- act(() => {- jotaiStore.set(shouldContinueAiChatInSidePanelState.atom, false);- navigateAwayFromChatPage?.();- });-- expect(openAskAiPageMock).not.toHaveBeenCalled();- expect(onContinueChatFromFullWidthMock).not.toHaveBeenCalled();- });-- it.each(['/chat', '/chat/existing-thread'])(- 'does not move the chat from %s into the side panel when opening settings or leaving them',- (initialPath) => {- jotaiStore.set(shouldOpenAiChatAfterOnboardingState.atom, true);-- render(<RouterUnderTest initialPath={initialPath} />);-- act(() => navigateAwayFromChatPage?.('/settings/profile'));-- expect(openAskAiPageMock).not.toHaveBeenCalled();- expect(onContinueChatFromFullWidthMock).not.toHaveBeenCalled();- expect(jotaiStore.get(shouldContinueAiChatInSidePanelState.atom)).toBe(- false,- );- expect(jotaiStore.get(shouldOpenAiChatAfterOnboardingState.atom)).toBe(- false,- );-- act(() => navigateAwayFromChatPage?.());-- expect(openAskAiPageMock).not.toHaveBeenCalled();- expect(onContinueChatFromFullWidthMock).not.toHaveBeenCalled();- },- );-- it('should do nothing away from the chat page when the marker is not set', () => {- render(<RouterUnderTest initialPath="/objects/companies" />);-- expect(openAskAiPageMock).not.toHaveBeenCalled();- expect(onContinueChatFromFullWidthMock).not.toHaveBeenCalled();- });-});diff --git a/packages/twenty-front/src/modules/sse-db-event/components/__tests__/SSEClientEffect.test.tsx b/packages/twenty-front/src/modules/sse-db-event/components/__tests__/SSEClientEffect.test.tsxdeleted file mode 100644index 36aeaf17ae5..00000000000--- a/packages/twenty-front/src/modules/sse-db-event/components/__tests__/SSEClientEffect.test.tsx+++ /dev/null@@ -1,59 +0,0 @@-import { render } from '@testing-library/react';-import { type ClientOptions } from 'graphql-sse';-import { createStore, Provider } from 'jotai';-import { createElement } from 'react';--import { isCookieAuthActiveState } from '@/auth/states/isCookieAuthActiveState';-import { SSEClientEffect } from '@/sse-db-event/components/SSEClientEffect';-import { REACT_APP_SERVER_BASE_URL } from '~/config';--const createClientMock = jest.fn();--jest.mock('graphql-sse', () => ({- createClient: (options: ClientOptions) => {- createClientMock(options);-- return {- subscribe: () => () => {},- iterate: async function* () {},- dispose: () => {},- };- },-}));--jest.mock('@/metadata-store/hooks/useResyncMetadataStore', () => ({- useResyncMetadataStore: () => ({ resyncMetadataStore: jest.fn() }),-}));--const renderSseClient = () => {- const store = createStore();-- store.set(isCookieAuthActiveState.atom, true);-- render(- createElement(Provider, { store }, createElement(SSEClientEffect, null)),- );-- expect(createClientMock).toHaveBeenCalledTimes(1);-- return createClientMock.mock.calls[0]?.[0] as ClientOptions;-};--describe('SSEClientEffect', () => {- beforeEach(() => {- jest.clearAllMocks();- });-- // The session cookie travels with the request, so the stream needs no header- // of its own.- it('should authenticate the stream with the session cookie alone', () => {- const options = renderSseClient();-- expect(options).toMatchObject({- url: `${REACT_APP_SERVER_BASE_URL}/metadata`,- credentials: 'include',- retryAttempts: Infinity,- });- expect(options.headers).toBeUndefined();- });-});diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/__tests__/WorkflowEditActionFilterBodyEffect.test.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/__tests__/WorkflowEditActionFilterBodyEffect.test.tsxdeleted file mode 100644index 2c69b147c7e..00000000000--- a/packages/twenty-front/src/modules/workflow/workflow-steps/filters/components/__tests__/WorkflowEditActionFilterBodyEffect.test.tsx+++ /dev/null@@ -1,160 +0,0 @@-import { render } from '@testing-library/react';-import { act } from 'react';-import {- type StepFilter,- type StepFilterGroup,- StepLogicalOperator,- ViewFilterOperand,-} from 'twenty-shared/types';-import { convertViewFilterOperandToCoreOperand } from 'twenty-shared/utils';--import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';-import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';-import { WorkflowEditActionFilterBodyEffect } from '@/workflow/workflow-steps/filters/components/WorkflowEditActionFilterBodyEffect';-import { StepFilterGroupsComponentInstanceContext } from '@/workflow/workflow-steps/filters/states/context/StepFilterGroupsComponentInstanceContext';-import { StepFiltersComponentInstanceContext } from '@/workflow/workflow-steps/filters/states/context/StepFiltersComponentInstanceContext';-import { currentStepFilterGroupsComponentState } from '@/workflow/workflow-steps/filters/states/currentStepFilterGroupsComponentState';-import { currentStepFiltersComponentState } from '@/workflow/workflow-steps/filters/states/currentStepFiltersComponentState';-import { type FilterSettingsWithPotentiallyDeprecatedOperand } from '@/workflow/workflow-steps/filters/types/FilterSettings';--const makeStepFilterGroup = (id: string): StepFilterGroup => ({- id,- logicalOperator: StepLogicalOperator.AND,-});--const makeStepFilter = (id: string, stepFilterGroupId: string): StepFilter => ({- id,- type: 'unknown',- stepOutputKey: '',- operand: ViewFilterOperand.IS,- value: '',- stepFilterGroupId,- positionInStepFilterGroup: 0,-});--// `defaultValue` filters are stored with potentially deprecated operands and are-// normalized to core operands when synced into the atoms.-const toExpectedSyncedFilter = (filter: StepFilter) => ({- ...filter,- operand: convertViewFilterOperandToCoreOperand(filter.operand),-});--type Captured = {- filters: StepFilter[];- filterGroups: StepFilterGroup[];- setFilters: (value: StepFilter[]) => void;- setFilterGroups: (value: StepFilterGroup[]) => void;-};--const renderBodyEffect = (- instanceId: string,- defaultValue?: FilterSettingsWithPotentiallyDeprecatedOperand,-) => {- const captured: Captured = {} as Captured;-- const ProbeEffect = () => {- captured.filters = useAtomComponentStateValue(- currentStepFiltersComponentState,- );- captured.filterGroups = useAtomComponentStateValue(- currentStepFilterGroupsComponentState,- );- captured.setFilters = useSetAtomComponentState(- currentStepFiltersComponentState,- );- captured.setFilterGroups = useSetAtomComponentState(- currentStepFilterGroupsComponentState,- );-- return null;- };-- const Harness = ({- value,- }: {- value?: FilterSettingsWithPotentiallyDeprecatedOperand;- }) => (- <StepFiltersComponentInstanceContext.Provider value={{ instanceId }}>- <StepFilterGroupsComponentInstanceContext.Provider value={{ instanceId }}>- <WorkflowEditActionFilterBodyEffect defaultValue={value} />- <ProbeEffect />- </StepFilterGroupsComponentInstanceContext.Provider>- </StepFiltersComponentInstanceContext.Provider>- );-- const utils = render(<Harness value={defaultValue} />);-- return {- captured,- rerender: (value?: FilterSettingsWithPotentiallyDeprecatedOperand) =>- utils.rerender(<Harness value={value} />),- };-};--describe('WorkflowEditActionFilterBodyEffect', () => {- it('seeds the local atoms from defaultValue on mount', () => {- const stepFilterGroup = makeStepFilterGroup('group-1');- const stepFilter = makeStepFilter('filter-1', 'group-1');-- const { captured } = renderBodyEffect('seed', {- stepFilterGroups: [stepFilterGroup],- stepFilters: [stepFilter],- });-- expect(captured.filterGroups).toEqual([stepFilterGroup]);- expect(captured.filters).toEqual([toExpectedSyncedFilter(stepFilter)]);- });-- // Regression test for the "Conditions" flash: when the user adds a condition,- // the local atoms are updated synchronously while the persisted value (passed- // as defaultValue) only catches up after an async save. The effect must not- // overwrite the local edit during that window.- it('does not overwrite a local edit while defaultValue is still stale', () => {- const { captured, rerender } = renderBodyEffect('no-clobber', {- stepFilterGroups: [],- stepFilters: [],- });-- expect(captured.filters).toEqual([]);- expect(captured.filterGroups).toEqual([]);-- const editedGroup = makeStepFilterGroup('edited-group');- const editedFilter = makeStepFilter('edited-filter', 'edited-group');-- act(() => {- captured.setFilterGroups([editedGroup]);- captured.setFilters([editedFilter]);- });-- expect(captured.filters).toEqual([editedFilter]);- expect(captured.filterGroups).toEqual([editedGroup]);-- // The save has not landed yet, so defaultValue is still the stale empty value.- act(() => {- rerender({ stepFilterGroups: [], stepFilters: [] });- });-- expect(captured.filters).toEqual([editedFilter]);- expect(captured.filterGroups).toEqual([editedGroup]);- });-- it('resyncs the atoms when defaultValue actually changes', () => {- const { captured, rerender } = renderBodyEffect('resync', {- stepFilterGroups: [],- stepFilters: [],- });-- const nextGroup = makeStepFilterGroup('group-2');- const nextFilter = makeStepFilter('filter-2', 'group-2');-- act(() => {- rerender({- stepFilterGroups: [nextGroup],- stepFilters: [nextFilter],- });- });-- expect(captured.filterGroups).toEqual([nextGroup]);- expect(captured.filters).toEqual([toExpectedSyncedFilter(nextFilter)]);- });-});