Skip to content

Commit 887426c

Browse files
committed
fix: try no unsaved for templates
1 parent 88c214f commit 887426c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,20 @@ test.describe('Query Templates', () => {
8282
}
8383
});
8484

85-
test('Unsaved changes modal appears when switching between templates', async ({page}) => {
85+
test('Unsaved changes modal appears when switching between templates if query was edited', async ({
86+
page,
87+
}) => {
8688
const objectSummary = new ObjectSummary(page);
8789
const unsavedChangesModal = new UnsavedChangesModal(page);
90+
const queryEditor = new QueryEditor(page);
8891

8992
// First action - Add index
9093
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.AddIndex);
9194
await page.waitForTimeout(500);
9295

96+
// First set some content
97+
await queryEditor.setQuery('SELECT 1;');
98+
9399
// Try to switch to Select query
94100
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.SelectQuery);
95101
await page.waitForTimeout(500);
@@ -107,8 +113,7 @@ test.describe('Query Templates', () => {
107113
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.AddIndex);
108114
await page.waitForTimeout(500);
109115

110-
// Store initial editor content
111-
const initialContent = await queryEditor.editorTextArea.inputValue();
116+
await queryEditor.setQuery('SELECT 1;');
112117

113118
// Try to switch to Select query
114119
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.SelectQuery);
@@ -118,7 +123,7 @@ test.describe('Query Templates', () => {
118123
await unsavedChangesModal.clickCancel();
119124

120125
// Verify editor content remains unchanged
121-
await expect(queryEditor.editorTextArea).toHaveValue(initialContent);
126+
await expect(queryEditor.editorTextArea).toHaveValue('SELECT 1;');
122127
});
123128

124129
test('Dont save button in unsaved changes modal allows to change text', async ({page}) => {
@@ -130,6 +135,7 @@ test.describe('Query Templates', () => {
130135
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.AddIndex);
131136
await page.waitForTimeout(500);
132137

138+
await queryEditor.setQuery('SELECT 1;');
133139
// Store initial editor content
134140
const initialContent = await queryEditor.editorTextArea.inputValue();
135141

@@ -157,6 +163,8 @@ test.describe('Query Templates', () => {
157163
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.AddIndex);
158164
await page.waitForTimeout(500);
159165

166+
await queryEditor.setQuery('SELECT 1;');
167+
160168
// Try to switch to Select query
161169
await objectSummary.clickActionMenuItem(dsVslotsTableName, RowTableAction.SelectQuery);
162170
await page.waitForTimeout(500);

0 commit comments

Comments
 (0)