Skip to content

Commit 84182da

Browse files
committed
fix(tests): isolate organization layout event subscriptions
1 parent 794ebf1 commit 84182da

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

apps/sim/app/o/[organizationId]/layout.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ import { authMockFns } from '@sim/testing'
77
import { dehydrate } from '@tanstack/react-query'
88
import { renderToStaticMarkup } from 'react-dom/server'
99
import { beforeEach, describe, expect, it, vi } from 'vitest'
10+
import { isChatEnabled } from '@/lib/core/config/env-flags'
1011

1112
const {
1213
mockGetOrganizationSurfaceContext,
1314
mockWorkspaceChrome,
1415
mockPrefetchOrganizationSidebar,
1516
mockUseSession,
17+
mockUseMothershipChatEvents,
1618
} = vi.hoisted(() => ({
1719
mockGetOrganizationSurfaceContext: vi.fn(),
1820
mockWorkspaceChrome: vi.fn(({ children }: { children: ReactNode }) => children),
1921
mockPrefetchOrganizationSidebar: vi.fn(async () => undefined),
2022
mockUseSession: vi.fn(),
23+
mockUseMothershipChatEvents: vi.fn(),
24+
}))
25+
26+
vi.mock('@/hooks/use-mothership-chat-events', () => ({
27+
useMothershipChatEvents: mockUseMothershipChatEvents,
2128
}))
2229

2330
vi.mock('@/lib/auth/auth-client', () => ({ useSession: mockUseSession }))
@@ -118,6 +125,10 @@ describe('OrganizationLayout', () => {
118125
'active-org'
119126
)
120127
expect(html).toContain('Organization child')
128+
expect(mockUseMothershipChatEvents).toHaveBeenCalledWith(
129+
{ organizationId: 'org-1' },
130+
isChatEnabled
131+
)
121132
expect(html).not.toContain('Stop impersonating')
122133
expect(mockWorkspaceChrome).toHaveBeenCalledWith(
123134
expect.objectContaining({ initialSidebarCollapsed: true }),

0 commit comments

Comments
 (0)