mirror of
https://github.com/apache/superset.git
synced 2026-09-01 21:11:28 +00:00
fix(sqllab): preserve saved query description when editing (#41685)
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user