Skip to content

Commit 422e6fe

Browse files
Anton StandrikAnton Standrik
authored andcommitted
.
1 parent aeddd30 commit 422e6fe

File tree

8 files changed

+91
-34
lines changed

8 files changed

+91
-34
lines changed

src/containers/Tenant/Query/ExecuteResult/PlanToSvgButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface PlanToSvgButtonProps {
2323
export function PlanToSvgButton({plan, database}: PlanToSvgButtonProps) {
2424
const [error, setError] = React.useState<string | null>(null);
2525
const [blobUrl, setBlobUrl] = React.useState<string | null>(null);
26-
const [getPlanToSvg, {isLoading}] = planToSvgApi.usePlanToSvgQueryMutation();
26+
const [getPlanToSvg, {isLoading}] = planToSvgApi.useLazyPlanToSvgQueryQuery();
2727

2828
const handleClick = React.useCallback(() => {
2929
getPlanToSvg({plan, database})

src/containers/Tenant/Query/ExecuteResult/TraceButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function TraceButton({traceId, isTraceReady}: TraceUrlButtonProps) {
2020
const checkTraceUrl = traceCheck?.url ? replaceParams(traceCheck.url, {traceId}) : '';
2121
const traceUrl = traceView?.url ? replaceParams(traceView.url, {traceId}) : '';
2222

23-
const [checkTrace, {isLoading, isUninitialized}] = traceApi.useCheckTraceMutation();
23+
const [checkTrace, {isLoading, isUninitialized}] = traceApi.useLazyCheckTraceQuery();
2424

2525
React.useEffect(() => {
2626
let checkTraceMutation: {abort: () => void} | null;

src/store/reducers/planToSvg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface PlanToSvgQueryParams {
99

1010
export const planToSvgApi = api.injectEndpoints({
1111
endpoints: (build) => ({
12-
planToSvgQuery: build.mutation<string, PlanToSvgQueryParams>({
12+
planToSvgQuery: build.query<string, PlanToSvgQueryParams>({
1313
queryFn: async ({plan, database}, {signal}) => {
1414
try {
1515
const response = await window.api.planToSvg(

src/store/reducers/trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface CheckTraceParams {
77

88
export const traceApi = api.injectEndpoints({
99
endpoints: (build) => ({
10-
checkTrace: build.mutation({
10+
checkTrace: build.query({
1111
queryFn: async ({url}: CheckTraceParams, {signal, dispatch}) => {
1212
try {
1313
const response = await window.api.checkTrace({url}, {signal});

tests/suites/nodes/nodes.test.ts

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

3+
import {toggleExperiment} from '../../utils/toggleExperiment';
34
import {NodesPage} from '../nodes/NodesPage';
45
import {PaginatedTable} from '../paginatedTable/paginatedTable';
56

@@ -28,12 +29,7 @@ test.describe('Test Nodes Paginated Table', async () => {
2829
expect(response?.ok()).toBe(true);
2930

3031
// Wil be removed since it's an experiment
31-
await page.evaluate(() => {
32-
localStorage.setItem('useBackendParamsForTables', 'true');
33-
location.reload();
34-
});
35-
36-
await page.waitForLoadState('networkidle');
32+
await toggleExperiment(page, 'on', 'Use paginated tables');
3733
});
3834

3935
test('Table loads and displays data', async ({page}) => {

tests/suites/sidebar/sidebar.test.ts

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

33
import {PageModel} from '../../models/PageModel';
4+
import {toggleExperiment} from '../../utils/toggleExperiment';
45

56
import {Sidebar} from './Sidebar';
67

@@ -92,32 +93,13 @@ test.describe('Test Sidebar', async () => {
9293

9394
test('Can toggle experiments in settings', async ({page}) => {
9495
const sidebar = new Sidebar(page);
95-
await sidebar.waitForSidebarToLoad();
96-
97-
// Open settings
98-
await sidebar.clickSettings();
99-
await page.waitForTimeout(500); // Wait for animation
100-
101-
// Click experiments section
102-
await sidebar.clickExperimentsSection();
103-
await page.waitForTimeout(500); // Wait for animation
104-
105-
// Toggle "Use paginated tables" experiment
106-
const experimentTitle = 'Use paginated tables';
107-
const initialState = await sidebar.isExperimentEnabled(experimentTitle);
108-
await sidebar.toggleExperimentByTitle(experimentTitle);
109-
await page.waitForTimeout(500); // Wait for animation
110-
111-
// Verify the state has changed
96+
const experimentTitle = 'Plan to SVG';
97+
await toggleExperiment(page, 'on', experimentTitle);
11298
const newState = await sidebar.isExperimentEnabled(experimentTitle);
113-
expect(newState).not.toBe(initialState);
114-
115-
// Toggle back
116-
await sidebar.toggleExperimentByTitle(experimentTitle);
117-
await page.waitForTimeout(500); // Wait for animation
99+
expect(newState).toBe(true);
118100

119-
// Verify it's back to initial state
101+
await toggleExperiment(page, 'off', experimentTitle);
120102
const finalState = await sidebar.isExperimentEnabled(experimentTitle);
121-
expect(finalState).toBe(initialState);
103+
expect(finalState).toBe(false);
122104
});
123105
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
});

tests/utils/toggleExperiment.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type {Page} from '@playwright/test';
2+
3+
import {Sidebar} from '../suites/sidebar/Sidebar';
4+
5+
export const toggleExperiment = async (page: Page, state: 'on' | 'off', title: string) => {
6+
const sidebar = new Sidebar(page);
7+
await sidebar.waitForSidebarToLoad();
8+
if (!(await sidebar.isDrawerVisible())) {
9+
await sidebar.clickSettings();
10+
await page.waitForTimeout(500); // Wait for animation
11+
}
12+
await sidebar.clickExperimentsSection();
13+
await page.waitForTimeout(500); // Wait for animation
14+
const currentState = await sidebar.isExperimentEnabled(title);
15+
const desiredState = state === 'on';
16+
17+
if (currentState !== desiredState) {
18+
await sidebar.toggleExperimentByTitle(title);
19+
await page.waitForTimeout(500); // Wait for animation
20+
}
21+
22+
if (await sidebar.isDrawerVisible()) {
23+
await sidebar.clickSettings();
24+
await page.waitForTimeout(500); // Wait for animation
25+
}
26+
};

0 commit comments

Comments
 (0)