|
1 | | -import type { FrontendWorkspaceMetadata } from "@/common/types/workspace"; |
| 1 | +import type { |
| 2 | + FrontendWorkspaceMetadata, |
| 3 | + WorkspaceActivitySnapshot, |
| 4 | +} from "@/common/types/workspace"; |
2 | 5 | import type { IPCApi } from "@/common/types/ipc"; |
3 | 6 | import type { ProjectConfig } from "@/common/types/project"; |
4 | 7 | import { act, cleanup, render, waitFor } from "@testing-library/react"; |
@@ -974,6 +977,17 @@ function createMockAPI(options: MockAPIOptions = {}) { |
974 | 977 | } |
975 | 978 |
|
976 | 979 | // Create workspace API with proper types |
| 980 | + const defaultActivityList: IPCApi["workspace"]["activity"]["list"] = () => |
| 981 | + Promise.resolve({} as Record<string, WorkspaceActivitySnapshot>); |
| 982 | + const defaultActivitySubscribe: IPCApi["workspace"]["activity"]["subscribe"] = () => () => |
| 983 | + undefined; |
| 984 | + |
| 985 | + const workspaceActivity = options.workspace?.activity; |
| 986 | + const activityListImpl: IPCApi["workspace"]["activity"]["list"] = |
| 987 | + workspaceActivity?.list?.bind(workspaceActivity) ?? defaultActivityList; |
| 988 | + const activitySubscribeImpl: IPCApi["workspace"]["activity"]["subscribe"] = |
| 989 | + workspaceActivity?.subscribe?.bind(workspaceActivity) ?? defaultActivitySubscribe; |
| 990 | + |
977 | 991 | const workspace: MockedWorkspaceAPI = { |
978 | 992 | create: mock( |
979 | 993 | options.workspace?.create ?? |
@@ -1010,8 +1024,8 @@ function createMockAPI(options: MockAPIOptions = {}) { |
1010 | 1024 | }) |
1011 | 1025 | ), |
1012 | 1026 | activity: { |
1013 | | - list: mock(options.workspace?.activity?.list ?? (() => Promise.resolve({}))), |
1014 | | - subscribe: mock(options.workspace?.activity?.subscribe ?? (() => () => undefined)), |
| 1027 | + list: mock(activityListImpl), |
| 1028 | + subscribe: mock(activitySubscribeImpl), |
1015 | 1029 | }, |
1016 | 1030 | }; |
1017 | 1031 |
|
|
0 commit comments