sadpandajoe commented on code in PR #44838:
URL: https://github.com/apache/superset/pull/44838#discussion_r4167642530


##########
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:
   Leaving this inline. `jest.mock('src/core/editors', ...)` is declared per 
file in 8 test files across explore, SqlLab and dashboard, and the stubs differ 
in shape (textarea with an imperative `resize` handle here, a `<div>` echoing 
the value in `DndFilterSelect`/`TemplateParamsEditor`, a `requireActual` spread 
in `EditorWrapper`). Two of the three files named already existed on master. 
Pulling out one shared helper would mean rewriting those unrelated tests in a 
PR that only adds tests ported from the deleted Cypress specs. A shared 
editor-mock helper would fit better as a separate cleanup covering all eight.



-- 
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]

Reply via email to