bito-code-review[bot] commented on code in PR #40012:
URL: https://github.com/apache/superset/pull/40012#discussion_r3246923191
##########
superset-frontend/packages/superset-core/src/utils/logging.test.ts:
##########
@@ -50,20 +50,24 @@ test('should pipe to `console` methods', () => {
});
test('should use noop functions when console unavailable', () => {
+ const originalConsole = window.console;
Object.assign(window, { console: undefined });
- const { logging } = require('@apache-superset/core/utils');
+ try {
+ const { logging } = require('@apache-superset/core/utils');
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CommonJS require() import forbidden in
TypeScript</b></div>
<div id="fix">
The `require()` statement on line 56 violates the
`@typescript-eslint/no-require-imports` rule. Replace with ES6 `import`
statement to maintain consistency with TypeScript best practices.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
Object.assign(window, { console: undefined });
+ jest.resetModules();
try {
- const { logging } = require('@apache-superset/core/utils');
+ const { logging } = await import('@apache-superset/core/utils');
expect(() => {
logging.debug();
logging.log();
logging.info();
logging.warn('warn');
logging.error('error');
logging.trace();
logging.table([
[1, 2],
[3, 4],
]);
}).not.toThrow();
} finally {
+ jest.resetModules();
Object.assign(window, { console: originalConsole });
}
});
```
</div>
</details>
</div>
<small><i>Code Review Run #749712</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
##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnMetricSelect.test.tsx:
##########
@@ -224,10 +228,24 @@ test('can drag and reorder items', async () => {
expect(within(firstItem).getByText('column_a')).toBeVisible();
expect(within(lastItem).getByText('Column B')).toBeVisible();
- fireEvent.dragStart(firstItem);
- fireEvent.dragEnter(lastItem);
- fireEvent.dragOver(lastItem);
- fireEvent.drop(lastItem);
+ const sourceId = firstItem
+ .querySelector('[data-drag-source-id]')!
+ .getAttribute('data-drag-source-id')!;
+ const targetId = lastItem
+ .querySelector('[data-drop-target-id]')!
+ .getAttribute('data-drop-target-id')!;
+ const backend = getTestBackend()!;
+ act(() => {
+ backend.simulateBeginDrag([sourceId]);
+ // Pass a clientOffset past the hover midpoint so OptionWrapper.hover /
+ // OptionControls.hover fire the reorder instead of bailing on the
+ // jsdom zero-rect.
+ backend.simulateHover([targetId], {
+ clientOffset: { x: 0, y: 100 },
+ } as any);
+ backend.simulateDrop();
+ backend.simulateEndDrag();
+ });
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incomplete Test Assertion</b></div>
<div id="fix">
The test 'can drag and reorder items' simulates a drag-and-drop operation
but only checks that the container renders, not that reordering occurred. Add
assertions to validate the new order of items after the drag.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
backend.simulateEndDrag();
});
expect(within(firstItem).getByText('metric_a')).toBeVisible();
expect(within(lastItem).getByText('column_a')).toBeVisible();
````
</div>
</details>
</div>
<small><i>Code Review Run #749712</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]