From 9b971f0b7fa4a7eb6d245cd72e6af89d24efb176 Mon Sep 17 00:00:00 2001 From: ktx-akshay Date: Thu, 25 Sep 2025 13:37:11 +0530 Subject: [PATCH] test: add camelCase test scenarios (#8570) ### **PR Type** Tests, Enhancement ___ ### **Description** - Add transpose custom SQL dashboard test - Extend error checking return structure - Validate no errors post-transpose - Optimize test flow and assertions ___ ### Diagram Walkthrough ```mermaid flowchart LR Tests["Dashboards transpose test"] -- "enable transpose via config" --> Transpose["Apply transpose"] Transpose -- "check errors" --> ErrorCheck["Enhanced error results"] ErrorCheck -- "assert zero errors" --> Save["Save panel and cleanup"] ```

File Walkthrough

Relevant files
Enhancement
visualise.js
Enrich dashboard error check return payload                           

tests/ui-testing/pages/dashboardPages/visualise.js
  • Extend error result object.
  • Include errorTextCount and errorListCount.
  • Preserve existing no-error logic.
+2/-2     
Tests
dashboard-transpose.spec.js
New E2E test: transpose with custom SQL                                   

tests/ui-testing/playwright-tests/dashboards/dashboard-transpose.spec.js
  • Add test for transpose with custom SQL.
  • Configure fields, time range, and transpose.
  • Use enhanced error counts for assertions.
  • Save and cleanup created dashboard.
+88/-0   
___ --- .../pages/dashboardPages/visualise.js | 4 +- .../dashboards/dashboard-transpose.spec.js | 81 +++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/tests/ui-testing/pages/dashboardPages/visualise.js b/tests/ui-testing/pages/dashboardPages/visualise.js index 7f054267f3..74a9a862ef 100644 --- a/tests/ui-testing/pages/dashboardPages/visualise.js +++ b/tests/ui-testing/pages/dashboardPages/visualise.js @@ -252,12 +252,12 @@ export default class LogsVisualise { const errorContainerExists = await dashboardErrorContainer.count(); if (errorContainerExists === 0) { - return { hasErrors: false, errors: [] }; + return { hasErrors: false, errors: [], errorTextCount: 0, errorListCount: 0 }; } const isErrorVisible = await dashboardErrorContainer.first().isVisible(); if (!isErrorVisible) { - return { hasErrors: false, errors: [] }; + return { hasErrors: false, errors: [], errorTextCount: 0, errorListCount: 0 }; } const errors = []; diff --git a/tests/ui-testing/playwright-tests/dashboards/dashboard-transpose.spec.js b/tests/ui-testing/playwright-tests/dashboards/dashboard-transpose.spec.js index 0185c47241..2a90eda4c4 100644 --- a/tests/ui-testing/playwright-tests/dashboards/dashboard-transpose.spec.js +++ b/tests/ui-testing/playwright-tests/dashboards/dashboard-transpose.spec.js @@ -250,4 +250,85 @@ test.describe("dashboard UI testcases", () => { await pm.dashboardCreate.backToDashboardList(); await deleteDashboard(page, randomDashboardName); }); + + test("should not show an error when transpose is enabled from config with custom SQL query", async ({ + page, + }) => { + // Instantiate PageManager with the current page + const pm = new PageManager(page); + + const panelName = + pm.dashboardPanelActions.generateUniquePanelName("panel-test"); + + // Navigate to the dashboards list + await pm.dashboardList.menuItem("dashboards-item"); + await waitForDashboardPage(page); + + // Create a new dashboard and add a panel + await pm.dashboardCreate.createDashboard(randomDashboardName); + await pm.dashboardCreate.addPanel(); + await pm.dashboardPanelActions.addPanelName(panelName); + + // Select table chart type + await pm.chartTypeSelector.selectChartType("table"); + + // Now we can access the field removal buttons + await pm.chartTypeSelector.removeField("_timestamp", "x"); + + // Open Custom SQL editor + await page.locator('[data-test="dashboard-customSql"]').click(); + + // Focus on the editor and enter the custom SQL query + await page.locator(".view-line").first().click(); + await page + .locator('[data-test="dashboard-panel-query-editor"]') + .locator(".monaco-editor") + .click(); + await page + .locator('[data-test="dashboard-panel-query-editor"]') + .locator(".inputarea") + .fill( + 'SELECT kubernetes_namespace_name as "xAxis", count(kubernetes_namespace_name) as "y_axis_1" FROM "e2e_automate" GROUP BY "xAxis"' + ); + + await pm.chartTypeSelector.searchAndAddField("y_axis_1", "x"); + await pm.chartTypeSelector.searchAndAddField("xAxis", "y"); + + // Set relative time range + await pm.dashboardTimeRefresh.setRelative("6", "w"); + + await pm.dashboardPanelActions.waitForChartToRender(); + + // Open the configuration panel and enable transpose + await pm.dashboardPanelConfigs.openConfigPanel(); + await pm.dashboardPanelConfigs.selectTranspose(); + await pm.dashboardPanelActions.applyDashboardBtn(); + + // Wait for chart to render after transpose and check for errors + await pm.dashboardPanelActions.waitForChartToRender(); + + // await page.waitForLoadState("networkidle"); + await page.waitForTimeout(1000); + + // Check for dashboard errors ONLY after transpose is applied + const transposeErrorResult = await pm.logsVisualise.checkDashboardErrors( + page, + "Table (After Transpose)" + ); + + if (transposeErrorResult.hasErrors) { + transposeErrorResult.errors.forEach((error, index) => { + testLogger.error(`Transpose Error ${index + 1}: ${error}`);}); + + // Fail the test with detailed error information + expect(transposeErrorResult.errorTextCount).toBe(0); + expect(transposeErrorResult.errorListCount).toBe(0); + } + + // Save the panel + await pm.dashboardPanelActions.savePanel(); + // Delete the created dashboard + await pm.dashboardCreate.backToDashboardList(); + await deleteDashboard(page, randomDashboardName); + }); });