Skip to content

Commit 519729c

Browse files
committed
chore: Copy results to the clipboard
1 parent 65ec827 commit 519729c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ export class QueryEditor {
262262
}
263263
}
264264

265+
async clickCopyResultButton() {
266+
const copyButton = this.resultsControls.locator('button[title="Copy result"]');
267+
await copyButton.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
268+
await copyButton.click();
269+
}
270+
265271
async isRunButtonEnabled() {
266272
return this.runButton.isEnabled({timeout: VISIBILITY_TIMEOUT});
267273
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {expect, test} from '@playwright/test';
22

33
import {QUERY_MODES, STATISTICS_MODES} from '../../../../src/utils/query';
4+
import {getClipboardContent} from '../../../utils/clipboard';
45
import {tenantName} from '../../../utils/constants';
56
import {NavigationTabs, TenantPage, VISIBILITY_TIMEOUT} from '../TenantPage';
67
import {createTableQuery, longRunningQuery, longTableSelect} from '../constants';
@@ -317,4 +318,33 @@ test.describe('Test Query Editor', async () => {
317318
await queryEditor.expandResultsControls();
318319
await expect(queryEditor.isResultsControlsCollapsed()).resolves.toBe(false);
319320
});
321+
322+
test('Copy result button copies to clipboard', async ({page}) => {
323+
const queryEditor = new QueryEditor(page);
324+
const query = 'SELECT 42 as answer;';
325+
326+
// Run query to get results
327+
await queryEditor.setQuery(query);
328+
await queryEditor.clickRunButton();
329+
await queryEditor.waitForStatus('Completed');
330+
331+
// Click copy button
332+
await queryEditor.clickCopyResultButton();
333+
334+
// Wait for clipboard operation to complete
335+
await page.waitForTimeout(2000);
336+
337+
// Retry clipboard read a few times if needed
338+
let clipboardContent = '';
339+
for (let i = 0; i < 3; i++) {
340+
clipboardContent = await getClipboardContent(page);
341+
if (clipboardContent) {
342+
break;
343+
}
344+
await page.waitForTimeout(500);
345+
}
346+
347+
// Verify clipboard contains the query result
348+
expect(clipboardContent).toContain('42');
349+
});
320350
});

0 commit comments

Comments
 (0)