Skip to content

Commit 4088438

Browse files
Anton StandrikAnton Standrik
authored andcommitted
fix: dont save full plan
1 parent 8e1587b commit 4088438

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/utils/hooks/useQueryExecutionSettings.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import {useTracingLevelOptionAvailable} from '../../store/reducers/capabilities/hooks';
24
import type {QuerySettings} from '../../types/store/query';
35
import {QUERY_EXECUTION_SETTINGS_KEY, USE_SHOW_PLAN_SVG_KEY} from '../constants';
@@ -12,6 +14,18 @@ export const useQueryExecutionSettings = () => {
1214
const validatedSettings = querySettingsRestoreSchema.parse(storageSettings);
1315
const [useShowPlanToSvg] = useSetting<boolean>(USE_SHOW_PLAN_SVG_KEY);
1416

17+
const setQueryExecutionSettings = React.useCallback(
18+
(settings: QuerySettings) => {
19+
setSettings({
20+
...settings,
21+
statisticsMode: useShowPlanToSvg
22+
? validatedSettings.statisticsMode
23+
: settings.statisticsMode,
24+
});
25+
},
26+
[setSettings, useShowPlanToSvg, validatedSettings.statisticsMode],
27+
);
28+
1529
const settings: QuerySettings = {
1630
...validatedSettings,
1731
statisticsMode: useShowPlanToSvg ? STATISTICS_MODES.full : validatedSettings.statisticsMode,
@@ -20,5 +34,5 @@ export const useQueryExecutionSettings = () => {
2034
: DEFAULT_QUERY_SETTINGS.tracingLevel,
2135
};
2236

23-
return [settings, setSettings] as const;
37+
return [settings, setQueryExecutionSettings] as const;
2438
};

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {tenantName} from '../../../utils/constants';
44
import {toggleExperiment} from '../../../utils/toggleExperiment';
55
import {TenantPage} from '../TenantPage';
66

7-
import {ButtonNames, QueryEditor} from './models/QueryEditor';
7+
import {QueryEditor} from './models/QueryEditor';
88

99
test.describe('Test Plan to SVG functionality', async () => {
1010
const testQuery = 'SELECT 1;'; // Simple query that will generate a plan
@@ -24,30 +24,25 @@ test.describe('Test Plan to SVG functionality', async () => {
2424
const queryEditor = new QueryEditor(page);
2525

2626
// 1. Turn on Plan to SVG experiment
27-
await toggleExperiment(page, 'on', 'Plan to SVG');
27+
await toggleExperiment(page, 'on', 'Execution plan');
2828

29-
// 2. Set stats level to Full
30-
await queryEditor.clickGearButton();
31-
await queryEditor.settingsDialog.changeStatsLevel('Full');
32-
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
33-
34-
// 3. Set query and run it
29+
// 2. Set query and run it
3530
await queryEditor.setQuery(testQuery);
3631
await queryEditor.clickRunButton();
3732

38-
// 4. Wait for query execution to complete
33+
// 3. Wait for query execution to complete
3934
await expect(async () => {
4035
const status = await queryEditor.getExecutionStatus();
4136
expect(status).toBe('Completed');
4237
}).toPass();
4338

44-
// 5. Check if Execution Plan button appears and click it
39+
// 4. Check if Execution Plan button appears and click it
4540
const executionPlanButton = page.locator('button:has-text("Execution plan")');
4641
await expect(executionPlanButton).toBeVisible();
4742
await executionPlanButton.click();
4843
await page.waitForTimeout(1000); // Wait for new tab to open
4944

50-
// 6. Verify we're taken to a new tab with SVG content
45+
// 5. Verify we're taken to a new tab with SVG content
5146
const svgElement = page.locator('svg').first();
5247
await expect(svgElement).toBeVisible();
5348
});

0 commit comments

Comments
 (0)