You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(agentflow): update canvas add node drag and drop behaviour (#5774)
* feat(agentflow): update canvas add node drag and drop behaviour
- fix style issues and refactor components using design token with dark mode theme support
- add and update tests with additional jest config to mock canvas and libs
* fix lint error on test
* address gemini review comments
* update README Props to match actual implementation
Prevents the `canvas` native module from being loaded during jsdom initialization. The canvas package requires native compilation which fails in many environments, but it's only an optional dependency of jsdom and not needed for React component tests.
101
+
102
+
This custom environment intercepts `require('canvas')` at the module level and returns a mock before jsdom tries to load the native binary.
103
+
104
+
### Module Mocks
105
+
106
+
**ReactFlow Mock** (`src/__mocks__/reactflow.tsx`): Provides mock implementations of ReactFlow components and hooks.
107
+
108
+
Key features:
109
+
- Uses `forwardRef` for MUI `styled()` compatibility (prevents emotion errors)
**Axios Mock** (`src/__mocks__/axios.ts`): Prevents network errors by mocking all HTTP requests. Returns empty arrays/objects for all API calls to silence network warnings in tests.
115
+
116
+
**CSS Mock** (`src/__mocks__/styleMock.js`): Empty object export for CSS imports.
117
+
71
118
## Configuration
72
119
73
-
-**Jest config**: `jest.config.js` — two projects: `unit` (node env, `.test.ts`) and `components` (jsdom env, `.test.tsx`)
120
+
-**Jest config**: `jest.config.js` — two projects: `unit` (node env, `.test.ts`) and `components` (custom jsdom env, `.test.tsx`)
121
+
-**Test environment**: Component tests use custom jsdom environment (`src/__test_utils__/jest-environment-jsdom.js`) to handle canvas loading
122
+
-**Import aliases**: `@test-utils` maps to `src/__test_utils__` for convenient imports
-**Exclusions**: `src/infrastructure/api/hooks/useApi.ts` is excluded from coverage collection (potentially deprecated — check before investing in tests)
0 commit comments