bito-code-review[bot] commented on code in PR #35218:
URL: https://github.com/apache/superset/pull/35218#discussion_r3253777739
##########
superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx:
##########
@@ -1294,6 +1294,33 @@ describe('grouped options search', () => {
});
});
+test('should not call search after unmount', async () => {
+ const mockOnSearch = jest.fn();
+ const { unmount, rerender } = render(
+ <Select
+ {...defaultProps}
+ allowNewOptions
+ mode="multiple"
+ onSearch={mockOnSearch}
+ />,
+ );
+ await type('12', 0);
+ unmount();
+ await new Promise(resolve => setTimeout(resolve, 300));
+ expect(mockOnSearch).toHaveBeenCalledWith('12');
+ rerender(
+ <Select
+ {...defaultProps}
+ allowNewOptions
+ mode="multiple"
+ onSearch={mockOnSearch}
+ />,
+ );
+ await type('1234', 0);
+ unmount();
+ await new Promise(resolve => setTimeout(resolve, 300));
+ expect(mockOnSearch).toHaveBeenCalledWith('1234');
+});
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Test name contradicts assertion</b></div>
<div id="fix">
The test name 'should not call search after unmount' contradicts its
assertions. Line 1310 asserts `toHaveBeenCalledWith('12')` expecting onSearch
to be called, which verifies the opposite of the test name. Either rename the
test (e.g., 'calls onSearch with typed text') or restructure the assertions to
actually verify that callbacks are silenced post-unmount by checking the mock
wasn't called during the delay period.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
---
a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx
+++
b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx
@@ -1294,7 +1294,7 @@ describe('Select', () => {
});
});
-test('should not call search after unmount', async () => {
+test('calls onSearch with typed text before unmount', async () => {
const mockOnSearch = jest.fn();
const { unmount, rerender } = render(
<Select
@@ -1309,7 +1309,7 @@ test('should not call search after unmount', async ()
=> {
await new Promise(resolve => setTimeout(resolve, 300));
expect(mockOnSearch).toHaveBeenCalledWith('12');
rerender(
<Select
{...defaultProps}
allowNewOptions
mode="multiple"
onSearch={mockOnSearch}
/>,
);
await type('1234', 0);
unmount();
await new Promise(resolve => setTimeout(resolve, 300));
expect(mockOnSearch).toHaveBeenCalledWith('1234');
});
```
</div>
</details>
</div>
<small><i>Code Review Run #a2ad48</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]