Skip to content

Commit 3b554c8

Browse files
authored
fix: check stats independently of plan (#2413)
1 parent 5aa7188 commit 3b554c8

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

src/store/reducers/query/streamingReducers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export const setStreamQueryResponse = (
5353
state.result.data.preparedPlan = Object.keys(planData).length > 0 ? planData : undefined;
5454
state.result.data.simplifiedPlan = simplifiedPlan;
5555
state.result.data.plan = chunk.plan;
56+
}
57+
58+
if ('stats' in chunk) {
59+
if (!state.result.data) {
60+
state.result.data = prepareQueryData(null);
61+
}
62+
5663
state.result.data.stats = chunk.stats;
5764
}
5865

tests/suites/tenant/queryEditor/models/QueryEditor.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,29 @@ export class QueryEditor {
349349

350350
throw new Error(`Status did not change to ${expectedStatus} within ${timeout}ms`);
351351
}
352+
353+
async getStatsTabContent() {
354+
// First navigate to Stats tab
355+
await this.paneWrapper.selectTab(ResultTabNames.Stats);
356+
357+
// Get the stats content area
358+
const statsContent = this.selector.locator('.ydb-query-result__result');
359+
await statsContent.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
360+
361+
return statsContent.innerText();
362+
}
363+
364+
async hasStatsJsonViewer() {
365+
// First navigate to Stats tab
366+
await this.paneWrapper.selectTab(ResultTabNames.Stats);
367+
368+
// Check for JSON viewer element
369+
const jsonViewer = this.selector.locator('.ydb-json-viewer');
370+
try {
371+
await jsonViewer.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
372+
return true;
373+
} catch {
374+
return false;
375+
}
376+
}
352377
}

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
longRunningStreamQuery,
1212
longTableSelect,
1313
longerRunningStreamQuery,
14+
simpleQuery,
1415
} from '../constants';
1516

1617
import {
@@ -407,4 +408,42 @@ test.describe('Test Query Editor', async () => {
407408
// Verify clipboard contains the query result
408409
expect(clipboardContent).toContain('42');
409410
});
411+
412+
test.describe('Statistics Modes Tests', async () => {
413+
test('Stats tab shows no stats message when STATISTICS_MODES.none', async ({page}) => {
414+
const queryEditor = new QueryEditor(page);
415+
416+
// Set query and configure statistics mode to none
417+
await queryEditor.setQuery(simpleQuery);
418+
await queryEditor.clickGearButton();
419+
await queryEditor.settingsDialog.changeStatsLevel(STATISTICS_MODES.none);
420+
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
421+
422+
// Execute query
423+
await queryEditor.clickRunButton();
424+
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
425+
426+
// Check Stats tab content
427+
const statsContent = await queryEditor.getStatsTabContent();
428+
expect(statsContent).toContain('There is no Stats for the request');
429+
});
430+
431+
test('Stats tab shows JSON viewer when STATISTICS_MODES.basic', async ({page}) => {
432+
const queryEditor = new QueryEditor(page);
433+
434+
// Set query and configure statistics mode to basic
435+
await queryEditor.setQuery(simpleQuery);
436+
await queryEditor.clickGearButton();
437+
await queryEditor.settingsDialog.changeStatsLevel(STATISTICS_MODES.basic);
438+
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
439+
440+
// Execute query
441+
await queryEditor.clickRunButton();
442+
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
443+
444+
// Check that Stats tab contains JSON viewer
445+
const hasJsonViewer = await queryEditor.hasStatsJsonViewer();
446+
expect(hasJsonViewer).toBe(true);
447+
});
448+
});
410449
});

0 commit comments

Comments
 (0)