bito-code-review[bot] commented on code in PR #44838:
URL: https://github.com/apache/superset/pull/44838#discussion_r4150454729
##########
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/AdhocFilterEditPopover.test.tsx:
##########
@@ -17,14 +17,47 @@
* under the License.
*/
import type React from 'react';
-import { render, screen, fireEvent } from 'spec/helpers/testing-library';
-import userEvent from '@testing-library/user-event';
+import {
+ render,
+ screen,
+ fireEvent,
+ userEvent,
+ waitFor,
+} from 'spec/helpers/testing-library';
import { AGGREGATES } from 'src/explore/constants';
import AdhocMetric from
'src/explore/components/controls/MetricControl/AdhocMetric';
import AdhocFilterEditPopover from '.';
import AdhocFilter from '../AdhocFilter';
import { Clauses, ExpressionTypes } from '../types';
+// The real editor is an Ace instance that loads asynchronously and exposes no
+// DOM input, so a plain textarea stands in for it.
+jest.mock('src/core/editors', () => {
+ const React = require('react');
+ return {
+ EditorHost: React.forwardRef(
+ (
+ {
+ value,
+ onChange,
+ }: {
+ value: string;
+ onChange: (v: string) => void;
+ },
+ ref: React.Ref<{ resize: () => void }>,
+ ) => {
+ React.useImperativeHandle(ref, () => ({ resize: jest.fn() }));
+ return (
+ <textarea
+ defaultValue={value}
+ onChange={e => onChange?.(e.target.value)}
+ />
+ );
+ },
+ ),
+ };
+});
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Duplicated EditorHost mock</b></div>
<div id="fix">
This `EditorHost` stub block is copy-pasted verbatim:
`AdhocFilterControl.test.tsx:27` and
`AdhocFilterEditPopoverSqlTabContent.test.tsx:35` already contain the identical
`jest.mock('src/core/editors', ...)` factory (the SqlTabContent copy
additionally wires a shared `mockResize`). A third inline copy invites
divergence — e.g. a future prop like `language` or `resize` behavior would need
three edits. Extract the factory into `spec/helpers` and reference it from all
three files.
</div>
</div>
<small><i>Code Review Run #3c8a38</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]