Skip to content

Commit ef22acc

Browse files
committed
fix: review fix
1 parent 23fad9f commit ef22acc

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ export default function QueryEditor(props: QueryEditorProps) {
174174
if (!partial) {
175175
if (text !== historyQueries[historyCurrentIndex]?.queryText) {
176176
dispatch(saveQueryToHistory({queryText: text, queryId}));
177-
dispatch(setIsDirty(false));
178177
}
178+
dispatch(setIsDirty(false));
179179
}
180180
dispatchResultVisibilityState(PaneVisibilityActionTypes.triggerExpand);
181181
});

tests/suites/tenant/queryHistory/queryHistory.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,33 @@ test.describe('Query History', () => {
164164
expect(editorValue.trim()).toBe(firstQuery.trim());
165165
});
166166

167+
test('No unsaved changes modal when running a query that is identical to last in history', async () => {
168+
// Run first query
169+
const firstQuery = 'SELECT 10 AS first_history_query;';
170+
await queryEditor.run(firstQuery, QUERY_MODES.script);
171+
172+
// Set some other query
173+
const secondQuery = 'SELECT 20 AS second_history_query;';
174+
await queryEditor.setQuery(secondQuery);
175+
176+
// Run the first query again
177+
await queryEditor.run(firstQuery, QUERY_MODES.script);
178+
179+
// Navigate to history tab
180+
await queryEditor.queryTabs.selectTab(QueryTabs.History);
181+
await queryEditor.historyQueries.isVisible();
182+
183+
// Select the first query from history
184+
await queryEditor.historyQueries.selectQuery(firstQuery);
185+
186+
// Verify no unsaved changes modal appeared
187+
const isModalHidden = await tenantPage.isUnsavedChangesModalHidden();
188+
expect(isModalHidden).toBe(true);
189+
// Verify query is loaded in editor
190+
const editorValue = await queryEditor.editorTextArea.inputValue();
191+
expect(editorValue.trim()).toBe(firstQuery.trim());
192+
});
193+
167194
test('Unsaved changes modal appears when modifying a query and selecting from history', async () => {
168195
// Run a query
169196
const originalQuery = 'SELECT 30 AS original_history_query;';

0 commit comments

Comments
 (0)