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
yarn test against main crashes inside FailedTestCaseSampleData.test.tsx with:
TypeError: Cannot read properties of null (reading 'useContext')
at Object.useContext (.../openmetadata-ui-core-components/.../node_modules/react/cjs/react.development.js:1618:21)
at .../openmetadata-ui-core-components/.../dist/SnackbarContent.cjs.js:1:302310
The above error occurred in the <Table> component:
at className (.../openmetadata-ui-core-components/.../dist/SnackbarContent.cjs.js:1:302232)
at FailedTestCaseSampleData (.../FailedTestCaseSampleData.component.tsx:68:3)
The test was added in PR #27956 and passed in that PR's CI. PR #27985 — merged one day earlier — swapped the component's Table import from antd → @openmetadata/ui-core-components. Neither PR's CI exercised the post-merge state, so the regression slipped onto main.
Root cause
@openmetadata/ui-core-components ships a prebuilt CJS bundle resolved against its own nested node_modules/react, separate from the React copy Jest runs with. When the test renders a real export from the package, two React instances co-exist in the same process; the dispatcher in the package's React copy is null, so the first useContext call inside the bundle throws.
The test was written when the component still imported Table from antd (which has no nested React), so the dual-React condition didn't exist on PR #27956's branch.
To Reproduce
cd openmetadata-ui/src/main/resources/ui
yarn install
yarn test --testPathPattern=FailedTestCaseSampleData
Result:
FAIL src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.test.tsx
● Test suite failed to run
TypeError: Cannot read properties of null (reading 'useContext')
Expected behavior
The test should pass. The @openmetadata/ui-core-components package should not be reachable as a real (un-mocked) dependency inside Jest, or the package should not bundle its own React copy.
Added the test. On this PR's branch the component still imported antd's Table
Test passed — CI stack shows `rc-table/lib/Table.js`, `antd/lib/spin`
Direct evidence — PR #27956's CI log (run 25601970266):
PASS src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.test.tsx
at Table (.../node_modules/rc-table/lib/Table.js:141:25) ← antd
at Spin (.../node_modules/antd/lib/spin/index.js)
at InternalTable (.../node_modules/antd/lib/table/Table.js:39)
at testCaseData (FailedTestCaseSampleData.component.tsx:60:3)
Git auto-merged the two PRs without conflict (different parts of the same file), so no human noticed the interaction.
Process gap
The yarn-coverage workflow uses pull_request_target and checks out github.event.pull_request.head.sha — i.e. the PR head, not a trial merge with main. Two PRs that pass individually can still produce a broken main when their changes are logically (not textually) intertwined. Running UI tests against refs/pull/N/merge would surface this class of regression pre-merge.
Suggested fixes
Immediate — mock @openmetadata/ui-core-components in FailedTestCaseSampleData.test.tsx. This is the existing convention; ~30 other tests in the repo do the same (IncidentManager.test.tsx, ColumnDetailPanel.test.tsx, etc.).
Medium-term — openmetadata-ui-core-components should declare react/react-dom as peerDependencies only (not as a direct dependency that gets installed into its own node_modules). The preinstall script in openmetadata-ui/src/main/resources/ui/package.json currently runs yarn install inside the core-components package, which creates the nested copy that breaks Jest.
Affected module
UI
Describe the bug
yarn testagainstmaincrashes insideFailedTestCaseSampleData.test.tsxwith:The test was added in PR #27956 and passed in that PR's CI. PR #27985 — merged one day earlier — swapped the component's
Tableimport fromantd→@openmetadata/ui-core-components. Neither PR's CI exercised the post-merge state, so the regression slipped ontomain.Root cause
@openmetadata/ui-core-componentsships a prebuilt CJS bundle resolved against its own nestednode_modules/react, separate from the React copy Jest runs with. When the test renders a real export from the package, two React instances co-exist in the same process; the dispatcher in the package's React copy isnull, so the firstuseContextcall inside the bundle throws.The test was written when the component still imported
Tablefrom antd (which has no nested React), so the dual-React condition didn't exist on PR #27956's branch.To Reproduce
Result:
Expected behavior
The test should pass. The
@openmetadata/ui-core-componentspackage should not be reachable as a real (un-mocked) dependency inside Jest, or the package should not bundle its own React copy.Additional context
Two-PR interaction (why CI was green on both PRs)
Direct evidence — PR #27956's CI log (run
25601970266):Git auto-merged the two PRs without conflict (different parts of the same file), so no human noticed the interaction.
Process gap
The
yarn-coverageworkflow usespull_request_targetand checks outgithub.event.pull_request.head.sha— i.e. the PR head, not a trial merge withmain. Two PRs that pass individually can still produce a brokenmainwhen their changes are logically (not textually) intertwined. Running UI tests againstrefs/pull/N/mergewould surface this class of regression pre-merge.Suggested fixes
Immediate — mock
@openmetadata/ui-core-componentsinFailedTestCaseSampleData.test.tsx. This is the existing convention; ~30 other tests in the repo do the same (IncidentManager.test.tsx,ColumnDetailPanel.test.tsx, etc.).Medium-term —
openmetadata-ui-core-componentsshould declarereact/react-domas peerDependencies only (not as a direct dependency that gets installed into its ownnode_modules). Thepreinstallscript inopenmetadata-ui/src/main/resources/ui/package.jsoncurrently runsyarn installinside the core-components package, which creates the nested copy that breaks Jest.Long-term — switch
yarn-coverage.ymlto check out the merge ref so PR pairs like Migrate FailedTestCaseSampleData table to core-ui Table component #27985 + refactor: replace RouterUtils with ObservabilityRouterClassBase for navigation paths #27956 are validated together:```yaml
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
```
OS
macOS (also reproduces on Ubuntu CI when running off
maindirectly)OpenMetadata version
main(as of commit 2967a7f and later)