codeant-ai-for-open-source[bot] commented on code in PR #40823:
URL: https://github.com/apache/superset/pull/40823#discussion_r3366619482


##########
superset-frontend/packages/superset-ui-core/test/chart/components/SuperChart.test.tsx:
##########
@@ -19,7 +19,9 @@
 
 import '@testing-library/jest-dom';
 import { render, screen } from '@superset-ui/core/spec';
-import { triggerResizeObserver } from 'resize-observer-polyfill';
+import MockResizeObserver, {
+  triggerResizeObserver,
+} from 'resize-observer-polyfill';

Review Comment:
   **Suggestion:** The test imports `triggerResizeObserver` from 
`resize-observer-polyfill`, but this package normally exposes a default 
`ResizeObserver` export only unless you explicitly mock/remap it. Without an 
explicit `jest.mock('resize-observer-polyfill')` (or moduleNameMapper), 
`triggerResizeObserver` will be `undefined` at runtime and the `beforeEach` 
call will throw. Use the local mock module explicitly or add a Jest module 
mapping so the named helper is guaranteed to exist. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ SuperChart Jest suite crashes in global beforeEach hook.
   - ⚠️ ResizeObserver-driven layout behavior remains untested and unverified.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Run the Jest suite configured by `superset-frontend/jest.config.js` 
(lines 2–3), whose
   `testRegex` includes
   `packages/superset-ui-core/test/chart/components/SuperChart.test.tsx`.
   
   2. Jest loads `SuperChart.test.tsx` and executes the import at lines 20–24: 
`import
   MockResizeObserver, { triggerResizeObserver } from 
'resize-observer-polyfill';`.
   
   3. At runtime, module `resize-observer-polyfill` (declared as dependency in
   `packages/superset-ui-core/package.json:87` with version `1.5.1`) provides a 
default
   `ResizeObserver` export but no `triggerResizeObserver` named export, and 
there is no
   `jest.mock('resize-observer-polyfill')` anywhere in the repo (verified by 
Grep over
   `/workspace/superset`), so `triggerResizeObserver` is `undefined`.
   
   4. Before each test in `SuperChart.test.tsx`, the `beforeEach` hook at lines 
89–91 calls
   `triggerResizeObserver([]);`, which invokes `undefined` as a function and 
causes a
   `TypeError` before any test assertions execute, failing the entire 
`SuperChart` test
   suite.
   ```
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9786958143c244b3b47f418e9fa1652f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9786958143c244b3b47f418e9fa1652f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/test/chart/components/SuperChart.test.tsx
   **Line:** 22:24
   **Comment:**
        *Api Mismatch: The test imports `triggerResizeObserver` from 
`resize-observer-polyfill`, but this package normally exposes a default 
`ResizeObserver` export only unless you explicitly mock/remap it. Without an 
explicit `jest.mock('resize-observer-polyfill')` (or moduleNameMapper), 
`triggerResizeObserver` will be `undefined` at runtime and the `beforeEach` 
call will throw. Use the local mock module explicitly or add a Jest module 
mapping so the named helper is guaranteed to exist.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40823&comment_hash=22ede0a60fab21eff2ec4d90f87bb1c44d133ebfd81a9cfa4d410fbc9e94dd59&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40823&comment_hash=22ede0a60fab21eff2ec4d90f87bb1c44d133ebfd81a9cfa4d410fbc9e94dd59&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to