Skip to content

Commit 11390dc

Browse files
committed
fix: add tests
1 parent d1aa264 commit 11390dc

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

tests/suites/tenant/constants.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,35 @@ const simpleQuery = 'SELECT 1;';
55

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

tests/suites/tenant/queryEditor/QueryEditor.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ class PaneWrapper {
140140
export class ResultTable {
141141
private table: Locator;
142142
private preview: Locator;
143+
private resultHead: Locator;
143144

144145
constructor(selector: Locator) {
145146
this.table = selector.locator('.ydb-query-execute-result__result');
146147
this.preview = selector.locator('.kv-preview__result');
148+
this.resultHead = selector.locator('.ydb-query-execute-result__result-head');
147149
}
148150

149151
async isVisible() {
@@ -175,6 +177,16 @@ export class ResultTable {
175177
const cell = this.table.locator(`tr:nth-child(${row}) td:nth-child(${col})`);
176178
return cell.innerText();
177179
}
180+
181+
async isResultHeaderHidden() {
182+
await this.resultHead.waitFor({state: 'hidden', timeout: VISIBILITY_TIMEOUT});
183+
return true;
184+
}
185+
186+
async getResultHeadText() {
187+
await this.resultHead.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
188+
return this.resultHead.innerText();
189+
}
178190
}
179191

180192
export class QueryEditor {

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

Lines changed: 16 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} from '../constants';
66

77
import {
88
ButtonNames,
@@ -377,4 +377,19 @@ 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+
});
380395
});

0 commit comments

Comments
 (0)