Skip to content

Commit 88c214f

Browse files
committed
fix: try no unsaved for templates
1 parent 2e6051b commit 88c214f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export function YqlEditor({
9999
editor.focus();
100100
editor.setValue('');
101101
contribution.insert(input);
102+
dispatch(setIsDirty(false));
102103
}
103104
});
104105

tests/suites/tenant/queryEditor/queryTemplates.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,54 @@ test.describe('Query Templates', () => {
214214
// Verify unsaved changes modal appears
215215
await expect(unsavedChangesModal.isVisible()).resolves.toBe(true);
216216
});
217+
test('Switching between templates does not trigger unsaved changes modal', async ({page}) => {
218+
const objectSummary = new ObjectSummary(page);
219+
const tenantPage = new TenantPage(page);
220+
221+
// First select a template (Add Index)
222+
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.AddIndex);
223+
await page.waitForTimeout(500);
224+
225+
// Without editing the template, switch to another template (Select Query)
226+
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.SelectQuery);
227+
await page.waitForTimeout(500);
228+
229+
// Verify unsaved changes modal does not appear
230+
const isModalHidden = await tenantPage.isUnsavedChangesModalHidden();
231+
expect(isModalHidden).toBe(true);
232+
});
233+
234+
test('Selecting a template and then opening history query does not trigger unsaved changes modal', async ({
235+
page,
236+
}) => {
237+
const objectSummary = new ObjectSummary(page);
238+
const queryEditor = new QueryEditor(page);
239+
const tenantPage = new TenantPage(page);
240+
241+
// First, run a query to ensure we have history to select from
242+
const testQuery = 'SELECT 1 AS test_column;';
243+
await queryEditor.setQuery(testQuery);
244+
await queryEditor.clickRunButton();
245+
await page.waitForTimeout(1000); // Wait for the query to complete
246+
247+
// Next, select a template
248+
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.AddIndex);
249+
await page.waitForTimeout(500);
250+
251+
// Navigate to history tab
252+
await queryEditor.queryTabs.selectTab(QueryTabs.History);
253+
await queryEditor.historyQueries.isVisible();
254+
255+
// Select the query from history
256+
await queryEditor.historyQueries.selectQuery(testQuery);
257+
await page.waitForTimeout(500);
258+
259+
// Verify no unsaved changes modal appeared
260+
const isModalHidden = await tenantPage.isUnsavedChangesModalHidden();
261+
expect(isModalHidden).toBe(true);
262+
263+
// Verify the query was loaded into the editor
264+
const editorValue = await queryEditor.editorTextArea.inputValue();
265+
expect(editorValue.trim()).toBe(testQuery.trim());
266+
});
217267
});

0 commit comments

Comments
 (0)