Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqllab): Revert "rendering performance regression (#23653)" #23671

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import fetchMock from 'fetch-mock';
import {
SET_QUERY_EDITOR_SQL_DEBOUNCE_MS,
SQL_EDITOR_GUTTER_HEIGHT,
SQL_EDITOR_GUTTER_MARGIN,
SQL_TOOLBAR_HEIGHT,
Expand All @@ -44,14 +43,8 @@ import {

jest.mock('src/components/AsyncAceEditor', () => ({
...jest.requireActual('src/components/AsyncAceEditor'),
FullSQLEditor: ({ onChange, onBlur, value }) => (
<textarea
data-test="react-ace"
onChange={evt => onChange(evt.target.value)}
onBlur={onBlur}
>
{value}
</textarea>
FullSQLEditor: props => (
<div data-test="react-ace">{JSON.stringify(props)}</div>
),
}));
jest.mock('src/SqlLab/components/SqlEditorLeftBar', () => () => (
Expand Down Expand Up @@ -173,8 +166,10 @@ describe('SqlEditor', () => {
},
}),
);
const editor = await findByTestId('react-ace');
expect(editor).toHaveValue(expectedSql);

expect(await findByTestId('react-ace')).toHaveTextContent(
JSON.stringify({ value: expectedSql }).slice(1, -1),
);
});

it('render a SouthPane', async () => {
Expand All @@ -184,28 +179,6 @@ describe('SqlEditor', () => {
).toBeInTheDocument();
});

it('triggers setQueryEditorAndSaveSql with debounced call to avoid performance regression', async () => {
const { findByTestId } = setup(mockedProps, store);
const editor = await findByTestId('react-ace');
const sql = 'select *';
fireEvent.change(editor, { target: { value: sql } });
// Verify no immediate sql update triggered
expect(
store.getActions().filter(({ type }) => type === 'QUERY_EDITOR_SET_SQL'),
).toHaveLength(0);
await waitFor(
() =>
expect(
store
.getActions()
.filter(({ type }) => type === 'QUERY_EDITOR_SET_SQL'),
).toHaveLength(1),
{
timeout: SET_QUERY_EDITOR_SQL_DEBOUNCE_MS + 100,
},
);
});

it('runs query action with ctas false', async () => {
const expectedStore = mockStore({
...initialState,
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
persistEditorHeight,
postStopQuery,
queryEditorSetAutorun,
queryEditorSetSql,
queryEditorSetAndSaveSql,
queryEditorSetTemplateParams,
runQueryFromSqlEditor,
Expand Down Expand Up @@ -455,6 +456,7 @@ const SqlEditor = ({
);

const onSqlChanged = sql => {
dispatch(queryEditorSetSql(queryEditor, sql));
setQueryEditorAndSaveSqlWithDebounce(sql);
// Request server-side validation of the query text
if (canValidateQuery()) {
Expand Down