Skip to content

Commit 7642003

Browse files
committed
chore: run selected part of the query
1 parent 922e758 commit 7642003

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

tests/suites/tenant/queryEditor/models/QueryEditor.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ export class QueryEditor {
165165
await this.editorTextArea.press(key);
166166
}
167167

168+
async runSelectedQueryViaContextMenu() {
169+
await this.editorTextArea.evaluate(() => {
170+
const editor = window.ydbEditor;
171+
if (editor) {
172+
// Trigger the sendSelectedQuery action directly
173+
editor.trigger('contextMenu', 'sendSelectedQuery', null);
174+
}
175+
});
176+
}
177+
168178
async closeSettingsDialog() {
169179
await this.settingsDialog.clickButton(ButtonNames.Cancel);
170180
}

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ test.describe('Test Query Editor', async () => {
243243
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
244244
});
245245

246-
test('Running selected query executes only selected part', async ({page}) => {
246+
test('Running selected query via keyboard shortcut executes only selected part', async ({
247+
page,
248+
}) => {
247249
const queryEditor = new QueryEditor(page);
248250
const multiQuery = 'SELECT 1;\nSELECT 2;';
249251

@@ -268,4 +270,30 @@ test.describe('Test Query Editor', async () => {
268270
await expect(queryEditor.resultTable.hasMultipleResultTabs()).resolves.toBe(false);
269271
await expect(queryEditor.resultTable.getResultHeadText()).resolves.toBe('Result(1)');
270272
});
273+
274+
test('Running selected query via context menu executes only selected part', async ({page}) => {
275+
const queryEditor = new QueryEditor(page);
276+
const multiQuery = 'SELECT 1;\nSELECT 2;';
277+
278+
// First verify running the entire query produces two results with tabs
279+
await queryEditor.setQuery(multiQuery);
280+
await queryEditor.clickRunButton();
281+
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
282+
283+
// Verify there are two result tabs
284+
await expect(queryEditor.resultTable.getResultTabsCount()).resolves.toBe(2);
285+
await expect(queryEditor.resultTable.getResultTabTitle(0)).resolves.toBe('Result #1');
286+
await expect(queryEditor.resultTable.getResultTabTitle(1)).resolves.toBe('Result #2');
287+
288+
// Then verify running only selected part produces one result without tabs
289+
await queryEditor.focusEditor();
290+
await queryEditor.selectText(1, 1, 1, 9);
291+
292+
// Use context menu to run selected query
293+
await queryEditor.runSelectedQueryViaContextMenu();
294+
295+
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
296+
await expect(queryEditor.resultTable.hasMultipleResultTabs()).resolves.toBe(false);
297+
await expect(queryEditor.resultTable.getResultHeadText()).resolves.toBe('Result(1)');
298+
});
271299
});

0 commit comments

Comments
 (0)