test: e2e-cmd+enter-test (#6802)

- Verify search results are triggered when pressing Cmd+Enter or
Ctrl+Enter
- Verify query executes with keyboard shortcut after clicking elsewhere
- Verify different query executes with keyboard shortcut
- Verify SQL query executes with keyboard shortcut
This commit is contained in:
Neha P
2025-05-14 15:01:41 +05:30
committed by GitHub
parent 8eed07fbb6
commit e40ecdcdcd
2 changed files with 97 additions and 0 deletions
+82
View File
@@ -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();
}
}
@@ -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();
});
})