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.
This commit is contained in:
Jinwoo Hong
2026-10-04 21:39:22 -04:00
committed by GitHub
parent 0a8c5722f3
commit d9846e64fe
3 changed files with 18 additions and 3 deletions
@@ -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', () => ({
@@ -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', () => ({
@@ -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', () => ({