()
| 1471 | } |
| 1472 | |
| 1473 | async function setupWithProjectContext() { |
| 1474 | const workspaceRef = { current: null as WorkspaceContext | null }; |
| 1475 | const projectRef = { current: null as ReturnType<typeof useProjectContext> | null }; |
| 1476 | |
| 1477 | function ContextCapture() { |
| 1478 | workspaceRef.current = useWorkspaceContext(); |
| 1479 | projectRef.current = useProjectContext(); |
| 1480 | return null; |
| 1481 | } |
| 1482 | |
| 1483 | render( |
| 1484 | <APIProvider client={currentClientMock as APIClient}> |
| 1485 | <RouterProvider> |
| 1486 | <ProjectProvider> |
| 1487 | <WorkspaceProvider> |
| 1488 | <ContextCapture /> |
| 1489 | </WorkspaceProvider> |
| 1490 | </ProjectProvider> |
| 1491 | </RouterProvider> |
| 1492 | </APIProvider> |
| 1493 | ); |
| 1494 | |
| 1495 | // Inject client immediately to handle race conditions where effects run before store update. |
| 1496 | getWorkspaceStoreRaw().setClient(currentClientMock as APIClient); |
| 1497 | await waitFor(() => expect(workspaceRef.current).toBeTruthy()); |
| 1498 | await waitFor(() => expect(projectRef.current).toBeTruthy()); |
| 1499 | |
| 1500 | return { workspace: () => workspaceRef.current!, project: () => projectRef.current! }; |
| 1501 | } |
| 1502 | |
| 1503 | interface MockAPIOptions { |
| 1504 | workspace?: RecursivePartial<APIClient["workspace"]>; |
no test coverage detected