diff --git a/tests/ui-testing/pages/logsPage.js b/tests/ui-testing/pages/logsPage.js index 3f236f23d1..437c372c7d 100644 --- a/tests/ui-testing/pages/logsPage.js +++ b/tests/ui-testing/pages/logsPage.js @@ -481,5 +481,87 @@ async waitForSearchResultAndCheckText(expectedText) { await expect(locator).toContainText(expectedText); } +async executeQueryWithKeyboardShortcut() { + // Press Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux) + await this.page.keyboard.press(process.platform === "darwin" ? "Meta+Enter" : "Control+Enter"); +} + +async executeQueryWithKeyboardShortcutTest() { + // Set up date/time filter + await this.page.locator('[data-test="date-time-btn"]').click({ force: true }); + await this.page.locator('[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block').click({ force: true }); + + // Ensure the query editor is visible and clickable before typing + const queryEditor = this.page.locator('[data-test="logs-search-bar-query-editor"]'); + await expect(queryEditor).toBeVisible(); + await queryEditor.click(); + await this.page.keyboard.type("match_all('code')"); + + // Execute query using keyboard shortcut + await this.executeQueryWithKeyboardShortcut(); + + // Verify that the expected log table column is visible + await expect(this.page.locator('[data-test="log-table-column-0-source"]')).toBeVisible(); +} + +async executeQueryWithKeyboardShortcutAfterClickingElsewhere() { + // Set up date/time filter + await this.page.locator('[data-test="date-time-btn"]').click({ force: true }); + await this.page.locator('[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block').click({ force: true }); + + // Click elsewhere on the screen first + await this.page.locator('[data-test="logs-search-bar"]').click(); + + // Ensure the query editor is visible and clickable before typing + const queryEditor = this.page.locator('[data-test="logs-search-bar-query-editor"]'); + await expect(queryEditor).toBeVisible(); + await queryEditor.click(); + await this.page.keyboard.type("match_all('code')"); + + // Execute query using keyboard shortcut + await this.executeQueryWithKeyboardShortcut(); + + // Verify that the expected log table column is visible + await expect(this.page.locator('[data-test="log-table-column-0-source"]')).toBeVisible(); +} + +async executeQueryWithKeyboardShortcutWithDifferentQuery() { + // Set up date/time filter + await this.page.locator('[data-test="date-time-btn"]').click({ force: true }); + await this.page.locator('[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block').click({ force: true }); + + // Ensure the query editor is visible and clickable before typing + const queryEditor = this.page.locator('[data-test="logs-search-bar-query-editor"]'); + await expect(queryEditor).toBeVisible(); + await queryEditor.click(); + await this.page.keyboard.type("str_match_ignore_case(kubernetes_container_name, 'ziox')"); + + // Execute query using keyboard shortcut + await this.executeQueryWithKeyboardShortcut(); + + // Verify that the expected log table column is visible + await expect(this.page.locator('[data-test="log-table-column-0-source"]')).toBeVisible(); +} + +async executeQueryWithKeyboardShortcutWithSQLMode() { + // Set up date/time filter + await this.page.locator('[data-test="date-time-btn"]').click({ force: true }); + await this.page.locator('[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block').click({ force: true }); + + // Enable SQL mode + await this.sqlModeToggle.click(); + + // Ensure the query editor is visible and clickable before typing + const queryEditor = this.page.locator('[data-test="logs-search-bar-query-editor"]'); + await expect(queryEditor).toBeVisible(); + await queryEditor.click(); + await this.page.keyboard.type('SELECT COUNT(_timestamp) AS xyz, _timestamp FROM "e2e_automate" Group by _timestamp ORDER BY _timestamp DESC'); + + // Execute query using keyboard shortcut + await this.executeQueryWithKeyboardShortcut(); + + // Verify that the expected log table column is visible + await expect(this.page.locator('[data-test="logs-search-result-bar-chart"]')).toBeVisible(); +} } diff --git a/tests/ui-testing/playwright-tests/logsqueries.spec.js b/tests/ui-testing/playwright-tests/logsqueries.spec.js index dffc5bc6cc..e61b534826 100644 --- a/tests/ui-testing/playwright-tests/logsqueries.spec.js +++ b/tests/ui-testing/playwright-tests/logsqueries.spec.js @@ -343,4 +343,19 @@ test.describe("Logs Queries testcases", () => { await expect(page.locator('[data-test="log-table-column-0-source"]')).toBeVisible(); }); + test("should trigger search results when pressing Cmd+Enter or Ctrl+Enter", async ({ page }) => { + await logsPage.executeQueryWithKeyboardShortcutTest(); + }); + + test("should execute query with keyboard shortcut (Cmd+Enter or Ctrl+Enter) after clicking elsewhere ", async ({ page }) => { + await logsPage.executeQueryWithKeyboardShortcutAfterClickingElsewhere(); + }); + + test("should execute different query with keyboard shortcut (Cmd+Enter or Ctrl+Enter)", async ({ page }) => { + await logsPage.executeQueryWithKeyboardShortcutWithDifferentQuery(); + }); + + test("should execute SQL query with keyboard shortcut (Cmd+Enter or Ctrl+Enter)", async ({ page }) => { + await logsPage.executeQueryWithKeyboardShortcutWithSQLMode(); + }); }) \ No newline at end of file