Skip to content

Commit 2ec6985

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(mothership): use shared mocks for editable panel coverage
1 parent 62f063f commit 2ec6985

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/components/credential-detail/hooks/use-unsaved-changes-guard.test.tsx‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
*/
44

55
import { act } from 'react'
6+
import { nextNavigationMock } from '@sim/testing/mocks/next-navigation.mock'
67
import { createRoot, type Root } from 'react-dom/client'
7-
import { afterEach, describe, expect, it, vi } from 'vitest'
8+
import { describe, expect, it, vi } from 'vitest'
89

9-
const { mockPush } = vi.hoisted(() => ({ mockPush: vi.fn() }))
10-
11-
vi.mock('next/navigation', () => ({
12-
useRouter: () => ({ push: mockPush }),
13-
}))
10+
vi.mock('next/navigation', () => nextNavigationMock)
1411

1512
import { useUnsavedChangesGuard } from '@/app/workspace/[workspaceId]/components/credential-detail/hooks/use-unsaved-changes-guard'
1613

@@ -32,10 +29,6 @@ function mountDisabledDirtyGuard(): () => void {
3229
}
3330

3431
describe('useUnsavedChangesGuard', () => {
35-
afterEach(() => {
36-
vi.restoreAllMocks()
37-
})
38-
3932
it('installs no nested navigation guard when its embedded host owns transitions', () => {
4033
const pushState = vi.spyOn(window.history, 'pushState')
4134
const unmount = mountDisabledDirtyGuard()

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/panel-resource-groups.test.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @vitest-environment jsdom
33
*/
44
import { act } from 'react'
5+
import { integrationMatcherMock } from '@sim/testing/mocks/integration-matcher.mock'
56
import { createRoot } from 'react-dom/client'
67
import { describe, expect, it, vi } from 'vitest'
78

@@ -13,7 +14,7 @@ vi.mock('@/app/workspace/[workspaceId]/providers/feature-flags-provider', () =>
1314
vi.mock('@/hooks/queries/dashboards', () => ({
1415
useWorkspaceDashboard: () => ({ data: undefined, isPending: false }),
1516
}))
16-
vi.mock('@/blocks/integration-matcher', () => ({ listIntegrationsByPopularity: () => [] }))
17+
vi.mock('@/blocks/integration-matcher', () => integrationMatcherMock)
1718
vi.mock('@/hooks/queries/custom-tools', () => ({
1819
useCustomTools: () => ({
1920
data: [{ id: 'tool-1', title: 'Lookup order' }],

‎apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor.test.tsx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ describe.each([{ workspaceId: 'ws-1' }, { workspaceId: '', organizationId: 'org-
223223
)
224224

225225
describe('usePromptEditor context insertion', () => {
226-
afterEach(() => {
227-
vi.restoreAllMocks()
228-
})
229-
230226
it.each(['skill', 'custom_tool', 'mcp_server'] as const)(
231227
'does not insert panel-only %s resources into the prompt',
232228
(type) => {

‎packages/testing/src/mocks/integration-matcher.mock.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ import { vi } from 'vitest'
1313
*/
1414
export const integrationMatcherMock = {
1515
getIntegrationMatcher: vi.fn(() => ({ regex: null, byName: new Map() })),
16+
listIntegrationsByPopularity: vi.fn(() => []),
1617
mentionifyIntegrations: vi.fn((text: string) => text),
1718
}

0 commit comments

Comments
 (0)