bito-code-review[bot] commented on code in PR #35447:
URL: https://github.com/apache/superset/pull/35447#discussion_r2396025685
##########
superset-frontend/src/hooks/useUnsavedChangesPrompt/useUnsavedChangesPrompt.test.tsx:
##########
@@ -30,107 +30,104 @@ const wrapper = ({ children }: { children:
React.ReactNode }) => (
<Router history={history}>{children}</Router>
);
-// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from
describe blocks
-describe('useUnsavedChangesPrompt', () => {
- test('should not show modal initially', () => {
- const { result } = renderHook(
- () =>
- useUnsavedChangesPrompt({
- hasUnsavedChanges: true,
- onSave: jest.fn(),
- }),
- { wrapper },
- );
-
- expect(result.current.showModal).toBe(false);
- });
+test('should not show modal initially', () => {
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Test isolation failure</b></div>
<div id="fix">
The PR removes the describe block wrapper and converts tests to standalone
test functions, but this creates a critical test isolation issue. All tests now
share the same `history` instance and `wrapper` configuration, which can cause
test pollution where state from one test affects subsequent tests. The
`history` object accumulates navigation state across tests, and the shared
`wrapper` component may retain state. This will lead to flaky tests and false
positives/negatives in CI/CD pipelines. Add proper test isolation by
reinitializing the history instance before each test using `beforeEach`.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
-
-const history = createMemoryHistory({
- initialEntries: ['/dashboard'],
-});
-
+let history = createMemoryHistory({
+ initialEntries: ['/dashboard'],
+});
+
+beforeEach(() => {
+ history = createMemoryHistory({ initialEntries: ['/dashboard'] });
+});
+
```
</div>
</details>
</div>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/35447#issuecomment-3358322061>#c65c3d</a></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]