fix(sqllab): preserve saved query description when editing (#41685)

This commit is contained in:
Mehmet Salih Yavuz
2026-07-07 09:19:25 +02:00
committed by GitHub
parent c846da8dfb
commit de5a233ccf
4 changed files with 53 additions and 4 deletions
@@ -172,6 +172,47 @@ describe('SavedQuery', () => {
expect(updateBtn).toBeInTheDocument();
});
test('pre-fills the description from an existing saved query and updates with it unchanged', async () => {
const storedDescription = 'This is the stored description';
const mockOnUpdate = jest.fn();
render(<SaveQuery {...mockedProps} onUpdate={mockOnUpdate} />, {
useRedux: true,
store: mockStore({
...mockState,
sqlLab: {
...mockState.sqlLab,
queryEditors: [
{
id: mockedProps.queryEditorId,
dbId: 1,
catalog: null,
schema: 'main',
sql: 'SELECT * FROM t',
name: 'My saved query',
description: storedDescription,
remoteId: 42,
},
],
},
}),
});
userEvent.click(screen.getByRole('button', { name: /save/i }));
const descriptionTextbox = screen.getByRole('textbox', {
name: 'Description',
});
expect(descriptionTextbox).toHaveValue(storedDescription);
userEvent.click(screen.getByRole('button', { name: /update/i }));
await waitFor(() => expect(mockOnUpdate).toHaveBeenCalled());
expect(mockOnUpdate.mock.calls[0][0]).toEqual(
expect.objectContaining({ description: storedDescription }),
);
});
test('renders a split save button when allows_virtual_table_explore is enabled', async () => {
render(<SaveQuery {...splitSaveBtnProps} />, {
useRedux: true,
@@ -162,16 +162,22 @@ const SaveQuery = ({
<Form layout="vertical">
<Row>
<Col xs={24}>
<FormItem label={t('Name')}>
<Input type="text" value={label} onChange={onLabelChange} />
<FormItem label={t('Name')} htmlFor="save-query-name">
<Input
id="save-query-name"
type="text"
value={label}
onChange={onLabelChange}
/>
</FormItem>
</Col>
</Row>
<br />
<Row>
<Col xs={24}>
<FormItem label={t('Description')}>
<FormItem label={t('Description')} htmlFor="save-query-description">
<Input.TextArea
id="save-query-description"
rows={4}
value={description}
onChange={onDescriptionChange}