Skip to content

Conversation

@ktx-akshay
Copy link
Collaborator

@ktx-akshay ktx-akshay commented May 15, 2025

PR Type

Tests, Enhancement


Description

  • Add dashboard max query range UI test

  • Introduce StreamSettingsPage page object

  • Enhance ManagementPage with streaming toggles

  • Include maxquery test in CI workflow


Diagram Walkthrough

flowchart LR
  spec["Add maxquery Playwright spec"] -- uses --> pm["PageManager utilities"]
  spec -- updates --> streamPage["StreamSettingsPage (new)"]
  spec -- verifies --> uiWarn["Max duration warning visible"]
  pm -- ensures --> streamingDisabled["Streaming disabled via ManagementPage"]
  ci["GitHub Actions workflow"] -- includes --> spec
Loading

File Walkthrough

Relevant files
Enhancement
streams.js
New StreamSettingsPage for stream max query updates           

tests/ui-testing/pages/dashboardPages/streams.js

  • Add StreamSettingsPage class
  • Implement max query range update flow
  • Add stable locators and waits
  • Handle modal close after save
+57/-0   
managementPage.js
ManagementPage refactor and streaming toggle helpers         

tests/ui-testing/pages/generalPages/managementPage.js

  • Refactor to modern style and quotes
  • Add navigation helpers with validation
  • Add enable/disable streaming utilities
  • Improve selectors and waits
+162/-89
Tests
maxquery.spec.js
Playwright spec for dashboard max query warning                   

tests/ui-testing/playwright-tests/dashboards/maxquery.spec.js

  • Add end-to-end test for max query limit
  • Use PageManager and StreamSettingsPage
  • Validate warning visibility and API response
  • Restore stream setting after test
+107/-0 
Configuration changes
playwright.yml
CI includes max query dashboard test                                         

.github/workflows/playwright.yml

  • Add maxquery.spec.js to Dashboards-Core matrix
  • Minor YAML formatting adjustments
  • Preserve existing test matrices
+75/-70 

@ktx-akshay ktx-akshay force-pushed the test--dashboard-max-query-range-limit branch 3 times, most recently from 80b9c93 to c2425b2 Compare May 22, 2025 09:28
@ktx-akshay ktx-akshay force-pushed the test--dashboard-max-query-range-limit branch 3 times, most recently from e0ff378 to 230ad8e Compare July 17, 2025 07:27
@ktx-akshay ktx-akshay force-pushed the test--dashboard-max-query-range-limit branch 2 times, most recently from 651be45 to 4850684 Compare August 5, 2025 05:04
@ktx-akshay ktx-akshay force-pushed the test--dashboard-max-query-range-limit branch from dafd257 to 586e496 Compare September 3, 2025 08:51
@ktx-akshay ktx-akshay marked this pull request as ready for review September 3, 2025 09:42
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR adds comprehensive UI test coverage for the dashboard max query range limit functionality. The changes include:

  1. New Test File: maxquery.spec.js is added to validate that dashboards properly display warning messages when query time ranges exceed stream-configured limits (e.g., warning appears for 6-week queries when stream limit is 4 days, and disappears when reduced to 2 hours).

  2. Page Object Pattern Enhancement: A new StreamSettingsPage class is created to encapsulate stream configuration UI interactions, following established testing patterns in the codebase. This provides reusable methods for updating stream max query range settings.

  3. Management Page Extension: The ManagementPage class gains streaming control methods (checkStreaming() and ensureStreamingDisabled()) to ensure consistent test environment setup by managing the streaming feature state.

  4. CI Integration: The new test is integrated into the GitHub Actions Playwright workflow under the Dashboards-Core test suite, with YAML formatting standardized across all test configurations.

The implementation follows the existing test architecture using PageManager for UI interactions and includes proper test lifecycle management with setup/teardown procedures. The functionality being tested appears to be a performance safeguard that prevents users from executing resource-intensive queries that exceed configured time limits.

Confidence score: 3/5

  • This PR has moderate risk due to test implementation quality issues that could affect reliability
  • Score reflects concerns about hardcoded timeouts, duplicate code, debugging artifacts, and potential test flakiness from timing dependencies
  • Pay close attention to maxquery.spec.js for code quality improvements and managementPage.js for timeout handling

4 files reviewed, 5 comments

Edit Code Review Bot Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Flaky Waits

The method relies on fixed timeouts (e.g., waitForTimeout 3000) instead of waiting for specific network or UI conditions, which can cause flakiness. Prefer waiting on targeted responses or element states already hinted by the commented waitForResponse.

await this.searchInput.click();
await this.searchInput.fill(streamName);
await this.page.waitForTimeout(3000);

// Wait for the expected response
// await this.page.waitForResponse(
//   (response) =>
//     response
//       .url()
//       .includes(
//         "/api/default/streams?type=logs&offset=0&limit=20&keyword=e2e_automate"
//       ) && response.status() === 200
// );

// Wait for stream details to appear and click

await this.streamDetailButton.waitFor({ state: "visible", timeout: 5000 });
await this.streamDetailButton.click();
Locator Specificity

Using first() on the 'Stream Detail' button may click the wrong stream if multiple results are present. Consider scoping the locator to the searched stream row to ensure the correct detail modal is opened.

this.streamDetailButton = page
  .getByRole("button", { name: "Stream Detail" })
  .first();
this.maxQueryInput = page.locator(
  '[data-test="stream-details-max-query-range-input"]'
);
Save After Toggle

In ensureStreamingDisabled the code clicks the submit button after toggling but does not re-verify the persisted state post-save. Add a post-save check (e.g., reload and assert aria-checked) to ensure the change is committed.

  // If Streaming is enabled, click to disable it
  if (isChecked) {
    console.log("Disabling Streaming...");
    await this.page.click(toggleSelector);
    await this.page.waitForTimeout(500); // allow UI to update

    // Verify toggle is now disabled
    const newCheckedState = await this.page.$eval(
      toggleSelector,
      (toggle) => {
        return toggle.getAttribute("aria-checked") === "true";
      }
    );

    await this.page.locator('[data-test="dashboard-add-submit"]').click();

    await this.page.waitForTimeout(5000);

    if (!newCheckedState) {
      console.log("Streaming has been successfully disabled.");
    } else {
      console.log("Failed to disable Streaming.");
    }
  } else {
    console.log("Streaming is already disabled.");
  }
}

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Use locator getAttribute for stability

Accessing attributes with $eval can throw if the element re-renders; use a locator
and getAttribute to reduce detached element errors. This improves stability under UI
updates.

tests/ui-testing/pages/generalPages/managementPage.js [86-88]

-const isChecked = await this.page.$eval(toggleSelector, (toggle) => {
-  return toggle.getAttribute("aria-checked") === "true";
-});
+const toggle = this.page.locator(toggleSelector);
+await toggle.waitFor({ state: "visible" });
+const isChecked = (await toggle.getAttribute("aria-checked")) === "true";
Suggestion importance[1-10]: 7

__

Why: Switching from $eval to locator.getAttribute reduces detached element errors during re-renders and matches Playwright best practices. It's contextually correct and enhances stability without changing behavior.

Medium
Avoid fixed sleeps with conditional wait

Replace the fixed timeout with a condition-based wait to avoid flakiness and race
conditions. Wait for the specific streamName row/button to appear before proceeding.

tests/ui-testing/pages/dashboardPages/streams.js [23-25]

 await this.searchInput.click();
 await this.searchInput.fill(streamName);
-await this.page.waitForTimeout(3000);
+await this.streamDetailButton.filter({ hasText: "Stream Detail" }).waitFor({ state: "visible", timeout: 15000 });
Suggestion importance[1-10]: 6

__

Why: Replacing a hardcoded timeout with a condition-based wait reduces flakiness and aligns with best practices. However, using this.streamDetailButton.filter({ hasText: "Stream Detail" }) is redundant since the locator already targets that button, so impact is moderate.

Low
General
Guarantee input is cleared before fill

Ensure the input is truly cleared before typing to prevent concatenated values
causing wrong settings. Use a clear action or select-all-and-delete before filling.

tests/ui-testing/pages/dashboardPages/streams.js [45]

+await this.maxQueryInput.click();
+await this.maxQueryInput.press('Control+A');
+await this.maxQueryInput.press('Delete');
 await this.maxQueryInput.fill(newValue);
Suggestion importance[1-10]: 7

__

Why: Ensuring the input is cleared before filling prevents concatenated values and potential test instability. The approach is accurate and improves reliability with minimal risk.

Medium

@ktx-akshay ktx-akshay force-pushed the test--dashboard-max-query-range-limit branch 4 times, most recently from 38511d7 to b33be23 Compare September 4, 2025 12:58
… WebSocket toggle logic with improved logging
… with enhanced logging and streamlined methods
@ktx-akshay ktx-akshay force-pushed the test--dashboard-max-query-range-limit branch from d424afc to 2a243c9 Compare September 5, 2025 05:05
@ktx-akshay ktx-akshay merged commit 62d5f2d into main Sep 5, 2025
34 of 40 checks passed
@ktx-akshay ktx-akshay deleted the test--dashboard-max-query-range-limit branch September 5, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants