From d9846e64feaed910b058c4128eb4d46ed8e2c4c8 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Sun, 4 Oct 2026 21:39:22 -0400 Subject: [PATCH] fix(test): give async image-insert store mocks the openFiles list (#25357) #25176 and #24489 landed together and collided in insertRichMarkdownImageFromPath. #25176 added three test files whose @/store mock returns { settings, folderWorkspaces, worktreesByRepo }. #24489 made the same function look up the open document with state.openFiles.find(...) to pass document-folder access to the import. Under the mock, openFiles is undefined, so the lookup throws, the catch shows "Failed to insert image", and no image is inserted -- 38 tests fail on main. The real store always carries openFiles, so production behavior of both PRs is intact; the mocks were just written against the pre-#24489 shape. Add openFiles: [] to the three mocks. --- .../editor/rich-markdown-async-image-paste.test.ts | 7 ++++++- .../editor/rich-markdown-async-image-table.test.ts | 7 ++++++- .../src/components/editor/useLocalImagePick.test.tsx | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/editor/rich-markdown-async-image-paste.test.ts b/src/renderer/src/components/editor/rich-markdown-async-image-paste.test.ts index 9b13ee256d2..aba0e4b9d26 100644 --- a/src/renderer/src/components/editor/rich-markdown-async-image-paste.test.ts +++ b/src/renderer/src/components/editor/rich-markdown-async-image-paste.test.ts @@ -17,7 +17,12 @@ vi.mock('@/runtime/runtime-file-client', () => ({ importExternalPathsToRuntime: vi.mock('@/lib/connection-context', () => ({ getConnectionId: vi.fn(() => null) })) vi.mock('@/store', () => ({ useAppStore: { - getState: vi.fn(() => ({ settings: null, folderWorkspaces: [], worktreesByRepo: {} })) + getState: vi.fn(() => ({ + settings: null, + folderWorkspaces: [], + worktreesByRepo: {}, + openFiles: [] + })) } })) vi.mock('@/runtime/runtime-rpc-client', () => ({ diff --git a/src/renderer/src/components/editor/rich-markdown-async-image-table.test.ts b/src/renderer/src/components/editor/rich-markdown-async-image-table.test.ts index eb6de2b96de..9c973af78d1 100644 --- a/src/renderer/src/components/editor/rich-markdown-async-image-table.test.ts +++ b/src/renderer/src/components/editor/rich-markdown-async-image-table.test.ts @@ -11,7 +11,12 @@ vi.mock('@/runtime/runtime-file-client', () => ({ importExternalPathsToRuntime: vi.mock('@/lib/connection-context', () => ({ getConnectionId: vi.fn(() => null) })) vi.mock('@/store', () => ({ useAppStore: { - getState: vi.fn(() => ({ settings: null, folderWorkspaces: [], worktreesByRepo: {} })) + getState: vi.fn(() => ({ + settings: null, + folderWorkspaces: [], + worktreesByRepo: {}, + openFiles: [] + })) } })) vi.mock('@/runtime/runtime-rpc-client', () => ({ diff --git a/src/renderer/src/components/editor/useLocalImagePick.test.tsx b/src/renderer/src/components/editor/useLocalImagePick.test.tsx index b22a85c9cb0..0ea9dcab5d8 100644 --- a/src/renderer/src/components/editor/useLocalImagePick.test.tsx +++ b/src/renderer/src/components/editor/useLocalImagePick.test.tsx @@ -13,7 +13,12 @@ vi.mock('@/runtime/runtime-file-client', () => ({ importExternalPathsToRuntime: vi.mock('@/lib/connection-context', () => ({ getConnectionId: vi.fn(() => null) })) vi.mock('@/store', () => ({ useAppStore: { - getState: vi.fn(() => ({ settings: null, folderWorkspaces: [], worktreesByRepo: {} })) + getState: vi.fn(() => ({ + settings: null, + folderWorkspaces: [], + worktreesByRepo: {}, + openFiles: [] + })) } })) vi.mock('@/runtime/runtime-rpc-client', () => ({