Skip to content

Commit 2bf5ffa

Browse files
committed
fix: tests
1 parent 100f05a commit 2bf5ffa

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

src/containers/Tenant/Query/QueryResult/components/ResultSetsViewer/ResultSetsViewer.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
}
99

1010
&__title {
11-
display: flex;
12-
align-items: center;
13-
gap: var(--g-spacing-2);
14-
1511
padding-top: var(--g-spacing-4);
1612
padding-bottom: var(--g-spacing-4);
1713
padding-left: var(--g-spacing-4);

src/containers/Tenant/Query/QueryResult/components/ResultSetsViewer/ResultSetsViewer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export function ResultSetsViewer(props: ResultSetsViewerProps) {
5555
const renderSingleResult = () => {
5656
const result = resultSets?.[0];
5757
return (
58-
<div className={b('title')}>
59-
<Text>{`Result ${result?.truncated ? '(T)' : ''}`}</Text>
58+
<Flex gap={2} alignItems="center" className={b('title')}>
59+
<Text>{result?.truncated ? 'Truncated' : 'Result'}</Text>
6060
<Text color="secondary">{result?.result?.length || 0}</Text>
61-
</div>
61+
</Flex>
6262
);
6363
};
6464

tests/suites/tenant/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// May cause Memory exceed on real database
33

44
export const simpleQuery = 'SELECT 1;';
5-
export const longTableSelect = 'SELECT * FROM `.sys/pg_class`';
5+
export const longTableSelect = (limit?: number) =>
6+
'SELECT * FROM `.sys/pg_class`' + (limit ? ` LIMIT ${limit};` : ';');
67

78
// 400 is pretty enough
89
export const longRunningQuery = new Array(400).fill(simpleQuery).join('');

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ export class ResultTable {
2525
private preview: Locator;
2626
private resultHead: Locator;
2727
private resultWrapper: Locator;
28+
private resultTitle: Locator;
2829

2930
constructor(selector: Locator) {
3031
this.table = selector.locator('.ydb-query-result-sets-viewer__result');
3132
this.preview = selector.locator('.kv-preview__result');
3233
this.resultHead = selector.locator('.ydb-query-result-sets-viewer__head');
34+
this.resultTitle = selector.locator('.ydb-query-result-sets-viewer__title');
3335
this.resultWrapper = selector.locator('.ydb-query-result-sets-viewer__result-wrapper');
3436
}
3537

@@ -81,6 +83,16 @@ export class ResultTable {
8183
return tabs.count();
8284
}
8385

86+
async getResultTitleText() {
87+
await this.resultTitle.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
88+
return this.resultTitle.locator('.g-text').first().textContent();
89+
}
90+
91+
async getResultTitleCount() {
92+
await this.resultTitle.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
93+
return this.resultTitle.locator('.g-text').nth(1).textContent();
94+
}
95+
8496
async getResultTabTitleText(index: number) {
8597
const tabs = await this.getResultTabs();
8698
const tab = tabs.nth(index);

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,8 @@ test.describe('Test Query Editor', async () => {
217217
const queryEditor = new QueryEditor(page);
218218
await queryEditor.setQuery(testQuery);
219219
await queryEditor.clickRunButton();
220-
await expect(queryEditor.resultTable.getResultTabsCount()).resolves.toBe(1);
221-
await expect(queryEditor.resultTable.getResultTabTitleText(0)).resolves.toBe('Result');
222-
await expect(queryEditor.resultTable.getResultTabTitleCount(0)).resolves.toBe('1');
220+
await expect(queryEditor.resultTable.getResultTitleText()).resolves.toBe('Result');
221+
await expect(queryEditor.resultTable.getResultTitleCount()).resolves.toBe('1');
223222
});
224223

225224
test('No result head value for no result', async ({page}) => {
@@ -232,14 +231,27 @@ test.describe('Test Query Editor', async () => {
232231

233232
test('Truncated head value is 1 for 1 row truncated result', async ({page}) => {
234233
const queryEditor = new QueryEditor(page);
235-
await queryEditor.setQuery(longTableSelect);
234+
await queryEditor.setQuery(longTableSelect());
236235
await queryEditor.clickGearButton();
237236
await queryEditor.settingsDialog.changeLimitRows(1);
238237
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
239238
await queryEditor.clickRunButton();
240-
await expect(queryEditor.resultTable.getResultTabsCount()).resolves.toBe(1);
241-
await expect(queryEditor.resultTable.getResultTabTitleText(0)).resolves.toBe('Result(T)');
242-
await expect(queryEditor.resultTable.getResultTabTitleCount(0)).resolves.toBe('1');
239+
await expect(queryEditor.resultTable.getResultTitleText()).resolves.toBe('Truncated');
240+
await expect(queryEditor.resultTable.getResultTitleCount()).resolves.toBe('1');
241+
});
242+
243+
test('Truncated results for multiple tabs', async ({page}) => {
244+
const queryEditor = new QueryEditor(page);
245+
await queryEditor.setQuery(`${longTableSelect(2)}${longTableSelect(2)}`);
246+
await queryEditor.clickGearButton();
247+
await queryEditor.settingsDialog.changeLimitRows(3);
248+
await queryEditor.settingsDialog.clickButton(ButtonNames.Save);
249+
await queryEditor.clickRunButton();
250+
await expect(queryEditor.resultTable.getResultTabsCount()).resolves.toBe(2);
251+
await expect(queryEditor.resultTable.getResultTabTitleText(1)).resolves.toBe(
252+
'Result #2(T)',
253+
);
254+
await expect(queryEditor.resultTable.getResultTabTitleCount(1)).resolves.toBe('1');
243255
});
244256

245257
test('Query execution status changes correctly', async ({page}) => {
@@ -274,9 +286,8 @@ test.describe('Test Query Editor', async () => {
274286
await executeSelectedQueryWithKeybinding(page);
275287

276288
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
277-
await expect(queryEditor.resultTable.getResultTabsCount()).resolves.toBe(1);
278-
await expect(queryEditor.resultTable.getResultTabTitleText(0)).resolves.toBe('Result');
279-
await expect(queryEditor.resultTable.getResultTabTitleCount(0)).resolves.toBe('1');
289+
await expect(queryEditor.resultTable.getResultTitleText()).resolves.toBe('Result');
290+
await expect(queryEditor.resultTable.getResultTitleCount()).resolves.toBe('1');
280291
});
281292

282293
test('Running selected query via context menu executes only selected part', async ({page}) => {
@@ -301,9 +312,8 @@ test.describe('Test Query Editor', async () => {
301312
await queryEditor.runSelectedQueryViaContextMenu();
302313

303314
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
304-
await expect(queryEditor.resultTable.getResultTabsCount()).resolves.toBe(1);
305-
await expect(queryEditor.resultTable.getResultTabTitleText(0)).resolves.toBe('Result');
306-
await expect(queryEditor.resultTable.getResultTabTitleCount(0)).resolves.toBe('1');
315+
await expect(queryEditor.resultTable.getResultTitleText()).resolves.toBe('Result');
316+
await expect(queryEditor.resultTable.getResultTitleCount()).resolves.toBe('1');
307317
});
308318

309319
test('Results controls collapse and expand functionality', async ({page}) => {

0 commit comments

Comments
 (0)