Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/store/reducers/query/streamingReducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export const setStreamQueryResponse = (
state.result.data.preparedPlan = Object.keys(planData).length > 0 ? planData : undefined;
state.result.data.simplifiedPlan = simplifiedPlan;
state.result.data.plan = chunk.plan;
}

if ('stats' in chunk) {
if (!state.result.data) {
state.result.data = prepareQueryData(null);
}

state.result.data.stats = chunk.stats;
}

Expand Down
25 changes: 25 additions & 0 deletions tests/suites/tenant/queryEditor/models/QueryEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,29 @@ export class QueryEditor {

throw new Error(`Status did not change to ${expectedStatus} within ${timeout}ms`);
}

async getStatsTabContent() {
// First navigate to Stats tab
await this.paneWrapper.selectTab(ResultTabNames.Stats);

// Get the stats content area
const statsContent = this.selector.locator('.ydb-query-result__result');
await statsContent.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});

return statsContent.innerText();
}

async hasStatsJsonViewer() {
// First navigate to Stats tab
await this.paneWrapper.selectTab(ResultTabNames.Stats);

// Check for JSON viewer element
const jsonViewer = this.selector.locator('.ydb-json-viewer');
try {
await jsonViewer.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
return true;
} catch {
return false;
}
}
}
39 changes: 39 additions & 0 deletions tests/suites/tenant/queryEditor/queryEditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
longRunningStreamQuery,
longTableSelect,
longerRunningStreamQuery,
simpleQuery,
} from '../constants';

import {
Expand Down Expand Up @@ -407,4 +408,42 @@ test.describe('Test Query Editor', async () => {
// Verify clipboard contains the query result
expect(clipboardContent).toContain('42');
});

test.describe('Statistics Modes Tests', async () => {
test('Stats tab shows no stats message when STATISTICS_MODES.none', async ({page}) => {
const queryEditor = new QueryEditor(page);

// Set query and configure statistics mode to none
await queryEditor.setQuery(simpleQuery);
await queryEditor.clickGearButton();
await queryEditor.settingsDialog.changeStatsLevel(STATISTICS_MODES.none);
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);

// Execute query
await queryEditor.clickRunButton();
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);

// Check Stats tab content
const statsContent = await queryEditor.getStatsTabContent();
expect(statsContent).toContain('There is no Stats for the request');
});

test('Stats tab shows JSON viewer when STATISTICS_MODES.basic', async ({page}) => {
const queryEditor = new QueryEditor(page);

// Set query and configure statistics mode to basic
await queryEditor.setQuery(simpleQuery);
await queryEditor.clickGearButton();
await queryEditor.settingsDialog.changeStatsLevel(STATISTICS_MODES.basic);
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);

// Execute query
await queryEditor.clickRunButton();
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);

// Check that Stats tab contains JSON viewer
const hasJsonViewer = await queryEditor.hasStatsJsonViewer();
expect(hasJsonViewer).toBe(true);
});
});
});
Loading