Skip to content

Commit 78cd713

Browse files
Raubzeugastandrik
andauthored
fix(ExecuteResult): do not show title if no result (#1444)
Co-authored-by: Anton Standrik <[email protected]>
1 parent f349bcd commit 78cd713

File tree

4 files changed

+99
-19
lines changed

4 files changed

+99
-19
lines changed

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,28 @@ export function ExecuteResult({
119119
/>
120120
</div>
121121
)}
122-
<div className={b('result')}>
123-
<div className={b('result-head')}>
124-
<Text variant="subheader-3">
125-
{currentResult?.truncated
126-
? i18n('title.truncated')
127-
: i18n('title.result')}
128-
</Text>
129-
<Text
130-
color="secondary"
131-
variant="body-2"
132-
className={b('row-count')}
133-
>{`(${currentResult?.result?.length})`}</Text>
122+
{currentResult && (
123+
<div className={b('result')}>
124+
<div className={b('result-head')}>
125+
<Text variant="subheader-3">
126+
{currentResult?.truncated
127+
? i18n('title.truncated')
128+
: i18n('title.result')}
129+
</Text>
130+
{currentResult.result && (
131+
<Text
132+
color="secondary"
133+
variant="body-2"
134+
className={b('row-count')}
135+
>{`(${currentResult.result.length})`}</Text>
136+
)}
137+
</div>
138+
<QueryResultTable
139+
data={currentResult.result}
140+
columns={currentResult.columns}
141+
/>
134142
</div>
135-
<QueryResultTable
136-
data={currentResult?.result}
137-
columns={currentResult?.columns}
138-
/>
139-
</div>
143+
)}
140144
</div>
141145
);
142146
};

tests/suites/tenant/constants.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
11
// Long running query for tests
22
// May cause Memory exceed on real database
33

4-
const simpleQuery = 'SELECT 1;';
4+
export const simpleQuery = 'SELECT 1;';
5+
export const longTableSelect = 'SELECT * FROM `.sys/pg_class`';
56

67
// 400 is pretty enough
78
export const longRunningQuery = new Array(400).fill(simpleQuery).join('');
9+
10+
export const createTableQuery = `
11+
CREATE TABLE \`/local/ydb_row_table\` (
12+
category_id Uint64 NOT NULL,
13+
id Uint64,
14+
expire_at Datetime,
15+
updated_on Datetime,
16+
name Text,
17+
\`binary-payload\` Bytes,
18+
attributes JsonDocument,
19+
-- uncomment to add a secondary index
20+
-- INDEX idx_row_table_id GLOBAL SYNC ON ( id ) COVER ( name, attributes ), -- Secondary indexes docs https://ydb.tech/en/docs/yql/reference/syntax/create_table#secondary_index
21+
PRIMARY KEY (category_id, id)
22+
)
23+
WITH (
24+
AUTO_PARTITIONING_BY_SIZE = ENABLED,
25+
AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048,
26+
AUTO_PARTITIONING_BY_LOAD = ENABLED,
27+
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4,
28+
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024
29+
-- uncomment to create a table with predefined partitions
30+
-- , UNIFORM_PARTITIONS = 4 -- The number of partitions for uniform initial table partitioning.
31+
-- The primary key's first column must have type Uint64 or Uint32.
32+
-- A created table is immediately divided into the specified number of partitions
33+
-- uncomment to launch read only replicas in every AZ
34+
-- , READ_REPLICAS_SETTINGS = 'PER_AZ:1' -- Enable read replicas for stale read, launch one replica in every availability zone
35+
-- uncomment to enable ttl
36+
-- , TTL = Interval("PT1H") ON expire_at -- Enable background deletion of expired rows https://ydb.tech/en/docs/concepts/ttl
37+
-- uncomment to create a table with a bloom filter
38+
-- , KEY_BLOOM_FILTER = ENABLED -- With a Bloom filter, you can more efficiently determine
39+
-- if some keys are missing in a table when making multiple single queries by the primary key.
40+
)`;

tests/suites/tenant/queryEditor/QueryEditor.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ export class SettingsDialog {
104104
await this.page.waitForTimeout(1000);
105105
}
106106

107+
async changeLimitRows(limitRows: number) {
108+
const limitRowsInput = this.dialog.locator('.ydb-query-settings-dialog__limit-rows input');
109+
await limitRowsInput.fill(limitRows.toString());
110+
await this.page.waitForTimeout(1000);
111+
}
112+
107113
async clickButton(buttonName: ButtonNames) {
108114
const button = this.dialog.getByRole('button', {name: buttonName});
109115
await button.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
@@ -140,10 +146,12 @@ class PaneWrapper {
140146
export class ResultTable {
141147
private table: Locator;
142148
private preview: Locator;
149+
private resultHead: Locator;
143150

144151
constructor(selector: Locator) {
145152
this.table = selector.locator('.ydb-query-execute-result__result');
146153
this.preview = selector.locator('.kv-preview__result');
154+
this.resultHead = selector.locator('.ydb-query-execute-result__result-head');
147155
}
148156

149157
async isVisible() {
@@ -175,6 +183,16 @@ export class ResultTable {
175183
const cell = this.table.locator(`tr:nth-child(${row}) td:nth-child(${col})`);
176184
return cell.innerText();
177185
}
186+
187+
async isResultHeaderHidden() {
188+
await this.resultHead.waitFor({state: 'hidden', timeout: VISIBILITY_TIMEOUT});
189+
return true;
190+
}
191+
192+
async getResultHeadText() {
193+
await this.resultHead.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
194+
return this.resultHead.innerText();
195+
}
178196
}
179197

180198
export class QueryEditor {

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {expect, test} from '@playwright/test';
22

33
import {tenantName} from '../../../utils/constants';
44
import {NavigationTabs, TenantPage, VISIBILITY_TIMEOUT} from '../TenantPage';
5-
import {longRunningQuery} from '../constants';
5+
import {createTableQuery, longRunningQuery, longTableSelect} from '../constants';
66

77
import {
88
ButtonNames,
@@ -377,4 +377,29 @@ test.describe('Test Query Editor', async () => {
377377
await tenantPage.selectNavigationTab(NavigationTabs.Query);
378378
await expect(queryEditor.resultTable.isVisible()).resolves.toBe(true);
379379
});
380+
381+
test('Result head value is 1 for 1 row result', async ({page}) => {
382+
const queryEditor = new QueryEditor(page);
383+
await queryEditor.setQuery(testQuery);
384+
await queryEditor.clickRunButton();
385+
await expect(queryEditor.resultTable.getResultHeadText()).resolves.toBe('Result(1)');
386+
});
387+
388+
test('No result head value for no result', async ({page}) => {
389+
const queryEditor = new QueryEditor(page);
390+
await queryEditor.setQuery(createTableQuery);
391+
await queryEditor.clickRunButton();
392+
await page.waitForTimeout(1000);
393+
await expect(queryEditor.resultTable.isResultHeaderHidden()).resolves.toBe(true);
394+
});
395+
396+
test('Truncated head value is 1 for 1 row truncated result', async ({page}) => {
397+
const queryEditor = new QueryEditor(page);
398+
await queryEditor.setQuery(longTableSelect);
399+
await queryEditor.clickGearButton();
400+
await queryEditor.settingsDialog.changeLimitRows(1);
401+
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
402+
await queryEditor.clickRunButton();
403+
await expect(queryEditor.resultTable.getResultHeadText()).resolves.toBe('Truncated(1)');
404+
});
380405
});

0 commit comments

Comments
 (0)