|
1 | 1 | import {expect, test} from '@playwright/test'; |
2 | 2 |
|
3 | 3 | import {QUERY_MODES, STATISTICS_MODES} from '../../../../src/utils/query'; |
| 4 | +import {getClipboardContent} from '../../../utils/clipboard'; |
4 | 5 | import {tenantName} from '../../../utils/constants'; |
5 | 6 | import {NavigationTabs, TenantPage, VISIBILITY_TIMEOUT} from '../TenantPage'; |
6 | 7 | import {createTableQuery, longRunningQuery, longTableSelect} from '../constants'; |
@@ -317,4 +318,33 @@ test.describe('Test Query Editor', async () => { |
317 | 318 | await queryEditor.expandResultsControls(); |
318 | 319 | await expect(queryEditor.isResultsControlsCollapsed()).resolves.toBe(false); |
319 | 320 | }); |
| 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 | + }); |
320 | 350 | }); |
0 commit comments