codeant-ai-for-open-source[bot] commented on code in PR #41636:
URL: https://github.com/apache/superset/pull/41636#discussion_r3531606466
##########
superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.test.tsx:
##########
@@ -82,8 +82,10 @@ test('collapses on click', async () => {
await userEvent.click(screen.getAllByRole('button')[0]);
- expect(screen.getByText('Content 1').parentNode).toHaveClass(
- 'ant-collapse-content-hidden',
+ // antd v6 moved the hidden state to the panel wrapper element
+ // (ant-collapse-panel-hidden) instead of the content wrapper.
+ expect(screen.getByText('Content 1').parentElement).toHaveClass(
+ 'ant-collapse-panel-hidden',
);
Review Comment:
**Suggestion:** The assertion targets the wrong DOM node: `parentElement` of
the content text is the body node, while the hidden state class is applied on
the panel wrapper. This makes the test fail even when collapse behavior is
correct. Assert against the closest panel wrapper element (for example via
`closest('.ant-collapse-panel')`) instead of the immediate parent. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Collapse collapse-on-click test fails after AntD v6 upgrade.
- ⚠️ Superset UI core test suite unreliable around Collapse behavior.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In
`superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.test.tsx`
lines 23-41, the helper `renderCollapse` renders the local `Collapse`
wrapper with `items`
containing `"Content 1"` and `"Content 2"` (verified via Read tool).
2. The `Collapse` component implementation at
`superset-frontend/packages/superset-ui-core/src/components/Collapse/Collapse.tsx`
lines
18-24 wraps Ant Design’s `Collapse` (`import { Collapse as AntdCollapse }
from 'antd';`
then `<AntdCollapse {...props} />`), so DOM structure and hidden-state
classes come
directly from AntD v6 (verified via Read tool).
3. AntD v6 applies the hidden-state class `ant-collapse-panel-hidden` to the
panel wrapper
element, not to the innermost content node containing the text `"Content
1"`. The test’s
own comment at lines 26-27 in `Collapse.test.tsx` documents this move from
the content
wrapper to the panel wrapper.
4. When the Jest test `'collapses on click'` (lines 77-32 in
`Collapse.test.tsx`) runs, it
clicks the first header button, then executes
`expect(screen.getByText('Content
1').parentElement).toHaveClass('ant-collapse-panel-hidden', );` on lines
87-89.
`screen.getByText('Content 1').parentElement` resolves to the immediate
content wrapper,
which does not receive `ant-collapse-panel-hidden`, so the assertion fails
even though the
panel wrapper higher in the DOM has the correct hidden-state class. Updating
the assertion
to target the closest panel wrapper (e.g., `screen.getByText('Content
1').closest('.ant-collapse-panel')`) would align the test with actual AntD
v6 behavior.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=50df5eb7ade7471484ae3f73232b2558&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=50df5eb7ade7471484ae3f73232b2558&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/src/components/Collapse/Collapse.test.tsx
**Line:** 87:89
**Comment:**
*Logic Error: The assertion targets the wrong DOM node: `parentElement`
of the content text is the body node, while the hidden state class is applied
on the panel wrapper. This makes the test fail even when collapse behavior is
correct. Assert against the closest panel wrapper element (for example via
`closest('.ant-collapse-panel')`) instead of the immediate parent.
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%2F41636&comment_hash=3f8ce87d52791cbb57290961e77a1b680a0b2fb3076af0b2a23816f61a6580fa&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41636&comment_hash=3f8ce87d52791cbb57290961e77a1b680a0b2fb3076af0b2a23816f61a6580fa&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]