mirror of
https://github.com/apache/superset.git
synced 2026-05-21 15:55:10 +00:00
fix(lint,test): unblock CI on chore/fc-10-explore-sqllab-misc
Two failures from the latest commits on this branch:
1. oxlint no-use-before-define on DatasourceEditor.tsx — the
isEditModeRef / onQueryFormatRef declarations sat after the
componentDidMount useEffect that closes over them. JavaScript closes
over the names at call time so it ran fine, but oxlint reads top-down
and flags the order. Move the ref declarations and their sync useEffect
ahead of the componentDidMount effect; lint clean and behavior
identical.
2. CopyToClipboard.test.tsx used userEvent.keyboard('{enter}'), an API
added in @testing-library/user-event v13.4. The pinned version in this
repo is v12.8.3, so the call resolves to undefined and the test
crashes with TypeError. Switch to fireEvent.keyDown(button, {key:
'Enter'}), which is v12-compatible and directly exercises the
component's onKeyDown handler we're testing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import {
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
@@ -59,7 +60,9 @@ test('non-element copyNode wrapper is keyboard-activatable', async () => {
|
||||
const button = screen.getByRole('button');
|
||||
expect(button).toHaveAttribute('tabIndex', '0');
|
||||
button.focus();
|
||||
await userEvent.keyboard('{enter}');
|
||||
// user-event v12 (pinned in this repo) doesn't expose .keyboard(); use
|
||||
// fireEvent to dispatch the Enter keydown directly to the focused button.
|
||||
fireEvent.keyDown(button, { key: 'Enter' });
|
||||
await waitFor(() => expect(onCopyEnd).toHaveBeenCalled());
|
||||
});
|
||||
|
||||
|
||||
@@ -1360,6 +1360,14 @@ function DatasourceEditor({
|
||||
[],
|
||||
);
|
||||
|
||||
// Keep the refs read by the (one-shot) Mousetrap handler up to date.
|
||||
const isEditModeRef = useRef(isEditMode);
|
||||
const onQueryFormatRef = useRef(onQueryFormat);
|
||||
useEffect(() => {
|
||||
isEditModeRef.current = isEditMode;
|
||||
onQueryFormatRef.current = onQueryFormat;
|
||||
}, [isEditMode, onQueryFormat]);
|
||||
|
||||
// componentDidMount
|
||||
useEffect(() => {
|
||||
isComponentMounted.current = true;
|
||||
@@ -1394,14 +1402,6 @@ function DatasourceEditor({
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Keep the refs read by the (one-shot) Mousetrap handler up to date.
|
||||
const isEditModeRef = useRef(isEditMode);
|
||||
const onQueryFormatRef = useRef(onQueryFormat);
|
||||
useEffect(() => {
|
||||
isEditModeRef.current = isEditMode;
|
||||
onQueryFormatRef.current = onQueryFormat;
|
||||
}, [isEditMode, onQueryFormat]);
|
||||
|
||||
// componentDidUpdate for props.datasource changes
|
||||
// Only run when the props.datasource reference actually changes from parent
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user