From efd2bab4a7aab64e0b6562fc4645d3bb3344e8f7 Mon Sep 17 00:00:00 2001
From: Neha P <144308844+neha00290@users.noreply.github.com>
Date: Thu, 3 Jul 2025 17:30:27 +0530
Subject: [PATCH] test: e2e- sortorder-testcases (#7445)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
### **PR Type**
Tests, Enhancement
___
### **Description**
- Add case-insensitive search helper methods
- Implement log count ordering verification
- Refactor tests to use new page-object methods
- Add 15-minute relative time selector helper
___
### **Changes diagram**
```mermaid
flowchart LR
A["LogsPage page object"]
B["playwright tests"]
A -- "add search & ordering methods" --> B
B -- "invoke helpers in specs" --> C["Improved test coverage"]
```
___
### **Changes walkthrough** 📝
| Relevant
files |
|---|
| Enhancement |
logsPage.jsAdd log ordering and
ignore-case helpers
tests/ui-testing/pages/logsPage.js
Added locators for query editor and refresh button
Implemented verifyLogCountOrdering (asc/desc) Added
searchWithStringMatchIgnoreCase method Added
setDateTimeTo15Minutes helper
|
+74/-0
|
|
| Tests |
logsqueries.spec.jsUse new page
helpers in specs
tests/ui-testing/playwright-tests/logsqueries.spec.js
Refactored string-match tests to use page methods Replaced
inline date-time selection with helper Added test for logcount
ordering verification Cleaned up test formatting and timeouts
|
+24/-50
|
|
___
> Need help?
Type /help how to
... in the comments thread for any questions about PR-Agent
usage.Check out the documentation
for more information.
---
tests/ui-testing/pages/logsPage.js | 74 +++++++++++++++++++
.../playwright-tests/logsqueries.spec.js | 72 ++++++------------
2 files changed, 96 insertions(+), 50 deletions(-)
diff --git a/tests/ui-testing/pages/logsPage.js b/tests/ui-testing/pages/logsPage.js
index 6eecd45eee..405ce5bebd 100644
--- a/tests/ui-testing/pages/logsPage.js
+++ b/tests/ui-testing/pages/logsPage.js
@@ -60,6 +60,11 @@ export class LogsPage {
this.partitionActiveIndicator = page.locator('[data-test="logs-search-partition-active"]');
this.resultText = '[data-test="logs-search-search-result"]';
+ // String match ignore case locators
+ this.logsSearchBarQueryEditor = '[data-test="logs-search-bar-query-editor"]';
+ this.searchBarRefreshButton = '[data-cy="search-bar-refresh-button"] > .q-btn__content';
+ this.logTableColumnSource = '[data-test="log-table-column-0-source"]';
+
}
async selectOrganization() {
@@ -752,5 +757,74 @@ async pageNotVisible() {
await expect(fastRewindElement).not.toBeVisible();
}
+async verifyLogCountOrdering(orderType) {
+ // Type and execute the query
+ const query = orderType === 'desc'
+ ? `SELECT MAX(_timestamp) as ts, count(_timestamp) as logcount,kubernetes_container_name FROM 'e2e_automate' where log is not null GROUP BY kubernetes_container_name order by logcount desc`
+ : `SELECT MAX(_timestamp) as ts, count(_timestamp) as logcount,kubernetes_container_name FROM 'e2e_automate' where log is not null GROUP BY kubernetes_container_name order by logcount asc`;
+ await this.clearAndFillQueryEditor(query);
+ await this.page.waitForTimeout(2000);
+
+ // Enable SQL mode if not already enabled
+ const sqlModeSwitch = this.page.getByRole('switch', { name: 'SQL Mode' });
+ const isSqlEnabled = await sqlModeSwitch.isChecked();
+ if (!isSqlEnabled) {
+ await sqlModeSwitch.click();
+ await this.page.waitForTimeout(1000);
+ }
+
+ // Run the query
+ await this.page.locator("[data-test='logs-search-bar-refresh-btn']").click({ force: true });
+ await this.page.waitForTimeout(2000);
+
+ // Get all table rows and verify order
+ const rows = await this.page.locator('[data-test^="logs-search-result-detail-"]').all();
+ let previousValue = orderType === 'desc' ? Number.MAX_SAFE_INTEGER : Number.MIN_SAFE_INTEGER;
+
+ for (const row of rows) {
+ const sourceCell = await row.locator('[data-test^="log-table-column-"][data-test$="-source"]').textContent();
+ try {
+ const logcountMatch = sourceCell.match(/logcount":(\d+)/);
+ const currentValue = logcountMatch ? parseInt(logcountMatch[1]) : 0;
+
+ if (orderType === 'desc') {
+ expect(currentValue).toBeLessThanOrEqual(previousValue);
+ } else {
+ expect(currentValue).toBeGreaterThanOrEqual(previousValue);
+ }
+ previousValue = currentValue;
+ } catch (error) {
+ console.error('Error parsing cell content:', sourceCell);
+ throw error;
+ }
+ }
+
+ // Verify we have results
+ expect(rows.length).toBeGreaterThan(0);
+}
+
+async verifyLogCountOrderingDescending() {
+ await this.verifyLogCountOrdering('desc');
+}
+
+ async verifyLogCountOrderingAscending() {
+ await this.verifyLogCountOrdering('asc');
+ }
+
+ // String match ignore case methods
+ async searchWithStringMatchIgnoreCase(searchText) {
+ await this.page.locator(this.logsSearchBarQueryEditor).click();
+ await this.page.keyboard.press(process.platform === "darwin" ? "Meta+A" : "Control+A");
+ await this.page.keyboard.press("Backspace");
+ await this.page.keyboard.type(`str_match_ignore_case('${searchText}')`);
+ await this.page.locator(this.searchBarRefreshButton).click();
+ await this.page.waitForTimeout(3000);
+ await expect(this.page.locator(this.logTableColumnSource)).toBeVisible();
+ }
+
+ async setDateTimeTo15Minutes() {
+ await this.page.locator(this.dateTimeButton).click();
+ await this.page.locator('[data-test="date-time-relative-15-m-btn"] > .q-btn__content > .block').click();
+ }
}
diff --git a/tests/ui-testing/playwright-tests/logsqueries.spec.js b/tests/ui-testing/playwright-tests/logsqueries.spec.js
index de19eb4ed5..a938343f6f 100644
--- a/tests/ui-testing/playwright-tests/logsqueries.spec.js
+++ b/tests/ui-testing/playwright-tests/logsqueries.spec.js
@@ -99,17 +99,15 @@ test.describe("Logs Queries testcases", () => {
await page.waitForTimeout(3000);
await page.locator('[data-test="log-table-column-0-source"]').click();
- await page.locator(':nth-child(1) > [data-test="log-details-include-exclude-field-btn"] > .q-btn__content > .q-icon').click(); await page.locator(
- '[data-test="log-details-include-field-btn"]').click(); await page.locator(
- '[data-test="close-dialog"] > .q-btn__content').click(); await page.locator(
- '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)').click(); await page.locator(
- '[data-test="add-alert-name-input"]').fill("e2etimestamp"); await page.locator(
- '[data-test="saved-view-dialog-save-btn"] > .q-btn__content').click(); await page.locator(
-
- '[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon').click(); await page.locator(
- '.q-item__label').getByText(/timestamp/).first().click({ force: true });
- await page.waitForTimeout(
- 3000);
+ await page.locator(':nth-child(1) > [data-test="log-details-include-exclude-field-btn"] > .q-btn__content > .q-icon').click();
+ await page.locator('[data-test="log-details-include-field-btn"]').click();
+ await page.locator('[data-test="close-dialog"] > .q-btn__content').click();
+ await page.locator('[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown--current > .q-btn__content > :nth-child(1)').click();
+ await page.locator('[data-test="add-alert-name-input"]').fill("e2etimestamp");
+ await page.locator('[data-test="saved-view-dialog-save-btn"] > .q-btn__content').click();
+ await page.locator('[data-test="logs-search-saved-views-btn"] > .q-btn-dropdown__arrow-container > .q-btn__content > .q-icon').click();
+ await page.locator('.q-item__label').getByText(/timestamp/).first().click({ force: true });
+ await page.waitForTimeout(3000);
await page.locator('[data-test="logs-search-saved-views-btn"]').getByLabel('Expand').click();
await page.locator('[data-test="log-search-saved-view-field-search-input"]').click();
await page.locator('[data-test="log-search-saved-view-field-search-input"]').fill('e2e');
@@ -120,7 +118,6 @@ test.describe("Logs Queries testcases", () => {
// await page.locator('[data-test="logs-search-saved-views-btn"]').getByLabel('Expand').click();
await page.getByText('delete').click();
await page.locator('[data-test="confirm-button"]').click();
-
});
test("should redirect to logs after clicking on stream explorer via stream page", async ({ page }) => {
@@ -287,7 +284,7 @@ test.describe("Logs Queries testcases", () => {
const targetElement = page.locator('[data-test="logs-search-subfield-add-kubernetes_pod_name-ziox-ingester-0"]').getByText('ziox-ingester-');
await expect(targetElement).toBeVisible(); // Assertion to ensure visibility
await targetElement.click()
- })
+ });
test("should display results in selected time", async ({
page,
@@ -299,46 +296,13 @@ test.describe("Logs Queries testcases", () => {
});
test("should display results if stringmatch ignorecase lowercase added in log query search", async ({ page }) => {
- // Type the value of a variable into an input field
- await page.locator('[data-test="date-time-btn"]').click({ force: true });
- await 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 = page.locator('[data-test="logs-search-bar-query-editor"]');
- await expect(queryEditor).toBeVisible();
- await queryEditor.click();
- await page.keyboard.type("str_match_ignore_case(kubernetes_container_name, 'ziox')");
- await page.waitForTimeout(4000);
-
- // Ensure the refresh button is visible and clickable before clicking
- const refreshButton = page.locator('[data-cy="search-bar-refresh-button"] > .q-btn__content');
- await expect(refreshButton).toBeVisible();
- await refreshButton.click({ force: true });
-
- // Verify that the expected log table column is visible
- await expect(page.locator('[data-test="log-table-column-0-source"]')).toBeVisible();
+ await logsPage.setDateTimeTo15Minutes();
+ await logsPage.searchWithStringMatchIgnoreCase('ziox');
});
-
test("should display results if stringmatch ignorecase uppercase added in log query search", async ({ page }) => {
- // Type the value of a variable into an input field
- await page.locator('[data-test="date-time-btn"]').click({ force: true });
- await 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 = page.locator('[data-test="logs-search-bar-query-editor"]');
- await expect(queryEditor).toBeVisible();
- await queryEditor.click();
- await page.keyboard.type("str_match_ignore_case(kubernetes_container_name, 'Ziox')");
- await page.waitForTimeout(4000);
-
- // Ensure the refresh button is visible and clickable before clicking
- const refreshButton = page.locator('[data-cy="search-bar-refresh-button"] > .q-btn__content');
- await expect(refreshButton).toBeVisible();
- await refreshButton.click({ force: true });
-
- // Verify that the expected log table column is visible
- await expect(page.locator('[data-test="log-table-column-0-source"]')).toBeVisible();
+ await logsPage.setDateTimeTo15Minutes();
+ await logsPage.searchWithStringMatchIgnoreCase('Ziox');
});
test("should trigger search results when pressing Cmd+Enter or Ctrl+Enter", async ({ page }) => {
@@ -356,4 +320,12 @@ test.describe("Logs Queries testcases", () => {
test("should execute SQL query with keyboard shortcut (Cmd+Enter or Ctrl+Enter)", async ({ page }) => {
await logsPage.executeQueryWithKeyboardShortcutWithSQLMode();
});
+
+ test("should verify logcount ordering in ascending and descending order", async ({ page }) => {
+ // Verify descending order
+ await logsPage.verifyLogCountOrderingDescending();
+
+ // Verify ascending order
+ await logsPage.verifyLogCountOrderingAscending();
+ });
})
\ No newline at end of file