|
| 1 | +import {expect, test} from '@playwright/test'; |
| 2 | + |
| 3 | +import {tenantName} from '../../../utils/constants'; |
| 4 | +import {toggleExperiment} from '../../../utils/toggleExperiment'; |
| 5 | +import {TenantPage} from '../TenantPage'; |
| 6 | +import {ButtonNames, QueryEditor} from '../queryEditor/QueryEditor'; |
| 7 | + |
| 8 | +test.describe('Test Plan to SVG functionality', async () => { |
| 9 | + const testQuery = 'SELECT 1;'; // Simple query that will generate a plan |
| 10 | + |
| 11 | + test.beforeEach(async ({page}) => { |
| 12 | + const pageQueryParams = { |
| 13 | + schema: tenantName, |
| 14 | + database: tenantName, |
| 15 | + general: 'query', |
| 16 | + }; |
| 17 | + |
| 18 | + const tenantPage = new TenantPage(page); |
| 19 | + await tenantPage.goto(pageQueryParams); |
| 20 | + }); |
| 21 | + |
| 22 | + test('Plan to SVG experiment shows execution plan in new tab', async ({page}) => { |
| 23 | + const queryEditor = new QueryEditor(page); |
| 24 | + |
| 25 | + // 1. Turn on Plan to SVG experiment |
| 26 | + await toggleExperiment(page, 'on', 'Plan to SVG'); |
| 27 | + |
| 28 | + // 2. Set stats level to Full |
| 29 | + await queryEditor.clickGearButton(); |
| 30 | + await queryEditor.settingsDialog.changeStatsLevel('Full'); |
| 31 | + await queryEditor.settingsDialog.clickButton(ButtonNames.Save); |
| 32 | + |
| 33 | + // 3. Set query and run it |
| 34 | + await queryEditor.setQuery(testQuery); |
| 35 | + await queryEditor.clickRunButton(); |
| 36 | + |
| 37 | + // 4. Wait for query execution to complete |
| 38 | + await expect(async () => { |
| 39 | + const status = await queryEditor.getExecutionStatus(); |
| 40 | + expect(status).toBe('Completed'); |
| 41 | + }).toPass(); |
| 42 | + |
| 43 | + // 5. Check if Execution Plan button appears and click it |
| 44 | + const executionPlanButton = page.locator('button:has-text("Execution plan")'); |
| 45 | + await expect(executionPlanButton).toBeVisible(); |
| 46 | + await executionPlanButton.click(); |
| 47 | + await page.waitForTimeout(1000); // Wait for new tab to open |
| 48 | + |
| 49 | + // 6. Verify we're taken to a new tab with SVG content |
| 50 | + const svgElement = page.locator('svg').first(); |
| 51 | + await expect(svgElement).toBeVisible(); |
| 52 | + }); |
| 53 | +}); |
0 commit comments