-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(QueryHistory): query history not saving (#1111)
- Loading branch information
Showing
5 changed files
with
128 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import {expect, test} from '@playwright/test'; | ||
|
||
import {tenantName} from '../../../utils/constants'; | ||
import {TenantPage} from '../TenantPage'; | ||
import {QueryEditor, QueryMode} from '../queryEditor/QueryEditor'; | ||
|
||
import executeQueryWithKeybinding from './utils'; | ||
|
||
export const VISIBILITY_TIMEOUT = 5000; | ||
|
||
test.describe('Query History', () => { | ||
let tenantPage: TenantPage; | ||
let queryEditor: QueryEditor; | ||
|
||
test.beforeEach(async ({page}) => { | ||
const pageQueryParams = { | ||
schema: tenantName, | ||
name: tenantName, | ||
general: 'query', | ||
}; | ||
|
||
tenantPage = new TenantPage(page); | ||
await tenantPage.goto(pageQueryParams); | ||
queryEditor = new QueryEditor(page); | ||
}); | ||
|
||
test('New query appears in history after execution', async ({page}) => { | ||
const testQuery = 'SELECT 1 AS test_column;'; | ||
|
||
// Execute the query | ||
await queryEditor.run(testQuery, QueryMode.YQLScript); | ||
|
||
// Navigate to the history tab | ||
await page.click('text=History'); | ||
|
||
// Check if the query appears in the history | ||
const historyTable = page.locator('.ydb-queries-history table'); | ||
await expect(historyTable.locator(`text="${testQuery}"`)).toBeVisible({ | ||
timeout: VISIBILITY_TIMEOUT, | ||
}); | ||
}); | ||
|
||
test('Multiple queries appear in correct order in history', async ({page}) => { | ||
const queries = [ | ||
'SELECT 1 AS first_query;', | ||
'SELECT 2 AS second_query;', | ||
'SELECT 3 AS third_query;', | ||
]; | ||
|
||
// Execute multiple queries | ||
for (const query of queries) { | ||
await queryEditor.run(query, QueryMode.YQLScript); | ||
} | ||
|
||
// Navigate to the history tab | ||
await page.click('text=History'); | ||
|
||
// Check if queries appear in reverse order (most recent first) | ||
const historyTable = page.locator('.ydb-queries-history table'); | ||
const rows = historyTable.locator('tbody tr'); | ||
|
||
await expect(rows).toHaveCount(queries.length); | ||
|
||
for (let i = 0; i < queries.length; i++) { | ||
await expect(rows.nth(i)).toContainText(queries[queries.length - 1 - i]); | ||
} | ||
}); | ||
|
||
test('Query executed with keybinding is saved in history', async ({page, browserName}) => { | ||
const testQuery = 'SELECT 1 AS keybinding_test;'; | ||
|
||
// Focus on the query editor | ||
await queryEditor.focusEditor(); | ||
|
||
// Type the query | ||
await page.keyboard.type(testQuery); | ||
|
||
// Use the keybinding to execute the query | ||
await executeQueryWithKeybinding(page, browserName); | ||
|
||
// Wait for the query to be executed | ||
await page.waitForSelector('.ydb-query-execute-result__result', {timeout: 10000}); | ||
|
||
// Navigate to the history tab | ||
await page.click('text=History'); | ||
|
||
// Check if the query appears in the history | ||
const historyTable = page.locator('.ydb-queries-history table'); | ||
await expect(historyTable.locator(`text="${testQuery}"`)).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type {Page} from '@playwright/test'; | ||
|
||
// eslint-disable-next-line no-implicit-globals | ||
export default async function executeQueryWithKeybinding(page: Page, browserName: string) { | ||
const isMac = process.platform === 'darwin'; | ||
const modifierKey = browserName === 'webkit' ? 'Meta' : 'Control'; | ||
|
||
if (browserName !== 'webkit' || isMac) { | ||
await page.keyboard.down(modifierKey); | ||
await page.keyboard.press('Enter'); | ||
await page.keyboard.up(modifierKey); | ||
} else { | ||
await page.keyboard.press('Meta+Enter'); | ||
} | ||
|
||
// Add a small delay to ensure the event is processed | ||
await page.waitForTimeout(1000); | ||
} |