Skip to content

Conversation

@ktx-akshay
Copy link
Collaborator

@ktx-akshay ktx-akshay commented Jul 25, 2024

Summary by CodeRabbit

  • New Features

    • Expanded automated testing coverage by adding new UI test files for dashboard management and logging visualization functionalities.
    • Enhanced dashboard UI tests now cover creating, modifying, duplicating, and applying filters to dashboards.
    • Introduced tests for verifying user interactions with logging visualizations, including error handling and data persistence.
    • Added tests for Virtual Reference Language (VRL) features within the dashboard, validating function applications and error handling.
  • Bug Fixes

    • Improved error handling in UI tests to ensure that invalid inputs trigger appropriate error messages.
  • Tests

    • Comprehensive test cases implemented for various user interactions across new features, ensuring functionality works as intended.

@CLAassistant
Copy link

CLAassistant commented Jul 25, 2024

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Walkthrough

The changes enhance the testing suite for a dashboard application using Playwright by adding three new test files: dashboard.spec.js, visualize.spec.js, and vrl.spec.js. These additions improve coverage for UI functionalities related to dashboard management, logging visualization, and Virtual Reference Language (VRL) features. Additionally, the GitHub Actions configuration has been updated to include these test cases, facilitating broader automated testing and ensuring robust validation of the application’s features.

Changes

Files Change Summary
.github/workflows/playwright.yml Expanded the test filename list in the GitHub Actions configuration to include two new test files, improving automated testing coverage.
tests/ui-testing/playwright-tests/dashboard.spec.js, tests/ui-testing/playwright-tests/visualize.spec.js, tests/ui-testing/playwright-tests/vrl.spec.js Introduced new test files implementing comprehensive UI tests for dashboard functionalities, logging visualization, and VRL features, enhancing overall test coverage.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dashboard
    participant Visualization
    participant VRL

    User->>Dashboard: Login
    Dashboard->>User: Authenticate

    User->>Dashboard: Create Dashboard
    Dashboard->>User: Dashboard Created

    User->>Dashboard: Apply Filters
    Dashboard->>User: Update Data

    User->>Visualization: View Logs
    Visualization->>User: Display Logs

    User->>VRL: Input VRL Function
    VRL->>User: Display Results
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ktx-akshay ktx-akshay force-pushed the test/dasboard/visulization branch from d66ee3d to 31f58d5 Compare July 25, 2024 11:03
@ktx-akshay ktx-akshay force-pushed the test/dasboard/visulization branch from 4f3124d to ddb54e4 Compare August 1, 2024 11:21
@ktx-akshay ktx-akshay marked this pull request as ready for review August 1, 2024 17:52
@ktx-akshay ktx-akshay requested a review from neha00290 August 1, 2024 17:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

Outside diff range, codebase verification and nitpick comments (1)
tests/ui-testing/playwright-tests/dashboard.spec.js (1)

7-7: Use template literals for better readability.

Using template literals can improve readability when constructing strings.

- const randomDashboardName = 'Dashboard_' + Math.random().toString(36).substr(2, 9);
+ const randomDashboardName = `Dashboard_${Math.random().toString(36).substr(2, 9)}`;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d2bfb96 and fef9007.

Files selected for processing (4)
  • .github/workflows/playwright.yml (1 hunks)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/vrl.spec.js (1 hunks)
Additional context used
Path-based instructions (3)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/vrl.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 40-40: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/vrl.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (19)
.github/workflows/playwright.yml (1)

87-87: LGTM! New test files added to the matrix configuration.

The new test files dashboard.spec.js and visualize.spec.js are correctly added to the matrix configuration for the browser job.

tests/ui-testing/playwright-tests/visualize.spec.js (9)

8-22: LGTM! Login function handles navigation and authentication correctly.

The login function correctly navigates to the base URL, fills in the login credentials, and signs in.


24-34: LGTM! Stream selection function handles the process correctly.

The selectStreamAndStreamTypeForLogs function correctly handles the selection of a stream and stream type for logs.


42-53: LGTM! Query application function handles the process correctly.

The applyQueryButton function correctly handles clicking the run query button and verifying the response status.


115-126: LGTM! Test case verifies log creation process correctly.

The test case correctly verifies that logs are created when ingesting queries into the search field.


128-139: LGTM! Test case verifies default chart settings correctly.

The test case correctly verifies that the default chart type and default X,Y axis are set to automatic field after clicking the Visualize button.


141-160: LGTM! Test case verifies data adjustment process correctly.

The test case correctly verifies that editing the X-axis and Y-axis on the chart effectively adjusts the displayed data.


162-200: LGTM! Test case verifies data plotting process correctly.

The test case correctly verifies that changing the chart type correctly plots the data according to the new chart type.


230-246: LGTM! Test case verifies search query behavior correctly.

The test case correctly verifies that there is no reflection of changes in the search query if there is a change in the X and Y axis.


248-257: LGTM! Test case verifies visualization behavior for an empty query correctly.

The test case correctly verifies the visualization behavior for an empty query.

tests/ui-testing/playwright-tests/vrl.spec.js (9)

11-31: LGTM! Login function handles navigation and authentication correctly.

The login function correctly navigates to the base URL, fills in the login credentials, and signs in.


33-43: LGTM! Page loading function handles the process correctly.

The waitForDashboardPage function correctly waits for the dashboard page to load and verifies the response status.


52-63: LGTM! Query application function handles the process correctly.

The applyQueryButton function correctly handles clicking the run query button and verifying the response status.


145-178: LGTM! Test case verifies VRL function display process correctly.

The test case correctly verifies that the VRL function is displayed in the field list after it has been written.


180-217: LGTM! Test case verifies addition of multiple VRL functions correctly.

The test case correctly verifies that multiple VRL functions can be successfully added.


219-253: LGTM! Test case verifies chart saving process correctly.

The test case correctly verifies that the chart is successfully saved by adding the VRL function.


255-289: LGTM! Test case verifies VRL function query behavior correctly.

The test case correctly verifies that the VRL function query does not vanish after changing from custom SQL mode to auto mode.


292-343: LGTM! Test case verifies error message display process correctly.

The test case correctly verifies that an error message is displayed when changing the VRL function if the existing VRL function is not updated or changed.


347-379: LGTM! Test case verifies error message display process for invalid VRL function correctly.

The test case correctly verifies that an error message is displayed if an invalid VRL function is added.

Comment on lines 295 to 64
test('Verify, The Chart should update when changing the chart type', async ({ page }) => {


await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();

await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();

await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();

// await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_docker_id"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-w-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(200);

await page.locator('[data-test="selected-chart-area-item"]').click();

await expect(page.locator('[data-test="selected-chart-area-stacked-item"]')).toBeVisible();

await page.locator('[data-test="selected-chart-h-bar-item"] img').click();
await expect(page.locator('[data-test="selected-chart-scatter-item"] img')).toBeVisible();

await page.locator('[data-test="selected-chart-scatter-item"] img').click();
await expect(page.locator('[data-test="selected-chart-gauge-item"] img')).toBeVisible();

await page.locator('[data-test="selected-chart-gauge-item"] img').click();
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();

await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill('Dash_01');
await page.locator('[data-test="dashboard-panel-save"]').click();
await page.waitForTimeout(200);
await page.locator('[data-test="dashboard-edit-panel-Dash_01-dropdown"]').click();
await page.locator('[data-test="dashboard-delete-panel"]').click();
await page.locator('[data-test="confirm-button"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for chart type change.

Consider adding error handling for the process of updating the chart when changing the chart type.

test('Verify, The Chart should update when changing the chart type', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines 1 to 5
import { test, expect } from "@playwright/test";
import logData from "../../ui-testing/cypress/fixtures/log.json";
import { log } from "console";
import logsdata from "../../test-data/logs_data.json";
import { parseArgs } from "util";
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused imports.

The log and parseArgs imports are not used in the file.

- import { log } from "console";
- import { parseArgs } from "util";
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { test, expect } from "@playwright/test";
import logData from "../../ui-testing/cypress/fixtures/log.json";
import { log } from "console";
import logsdata from "../../test-data/logs_data.json";
import { parseArgs } from "util";
import { test, expect } from "@playwright/test";
import logData from "../../ui-testing/cypress/fixtures/log.json";
import logsdata from "../../test-data/logs_data.json";

Comment on lines 145 to 64
test('Verify create New Dashboard ', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });

});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard creation.

Consider adding error handling for the dashboard creation process to manage potential issues.

test('Verify create New Dashboard ', async ({ page }) => {   
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
    } catch (error) {
        console.error('Dashboard creation failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('Verify create New Dashboard ', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
});
test('Verify create New Dashboard ', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
} catch (error) {
console.error('Dashboard creation failed:', error);
throw error;
}
});

Comment on lines 157 to 171
test('Verify that Delete the dashboard', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-back-btn"]').click();

await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
await page.locator('[data-test="confirm-button"]').click();


});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard deletion.

Consider adding error handling for the dashboard deletion process to manage potential issues.

test('Verify that Delete the dashboard', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-back-btn"]').click();
        await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
        await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
        await page.locator('[data-test="confirm-button"]').click();
    } catch (error) {
        console.error('Dashboard deletion failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('Verify that Delete the dashboard', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
await page.locator('[data-test="confirm-button"]').click();
});
test('Verify that Delete the dashboard', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
await page.locator('[data-test="confirm-button"]').click();
} catch (error) {
console.error('Dashboard deletion failed:', error);
throw error;
}
});

Comment on lines 174 to 188
test('Verify the Duplicate the Dashboard', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });

await page.locator('[data-test="dashboard-back-btn"]').click();

await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();

});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard duplication.

Consider adding error handling for the dashboard duplication process to manage potential issues.

test('Verify the Duplicate the Dashboard', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
        await page.locator('[data-test="dashboard-back-btn"]').click();
        await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
        await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();
    } catch (error) {
        console.error('Dashboard duplication failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('Verify the Duplicate the Dashboard', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();
});
test('Verify the Duplicate the Dashboard', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();
} catch (error) {
console.error('Dashboard duplication failed:', error);
throw error;
}
});

Comment on lines 191 to 211
test('Verify create dashboard,with add the breakDown', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();

await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();

// Refine the locator for 'e2e_automate'
await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();

await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();

await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
await page.locator('[data-test="dashboard-apply"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard creation with breakdown.

Consider adding error handling for the dashboard creation process with breakdown to manage potential issues.

test('Verify create dashboard,with add the breakDown', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
        await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
        await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
        await page.locator('[data-test="dashboard-apply"]').click();
    } catch (error) {
        console.error('Dashboard creation with breakdown failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('Verify create dashboard,with add the breakDown', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
// Refine the locator for 'e2e_automate'
await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
await page.locator('[data-test="dashboard-apply"]').click();
});
test('Verify create dashboard,with add the breakDown', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
await page.locator('[data-test="dashboard-apply"]').click();
} catch (error) {
console.error('Dashboard creation with breakdown failed:', error);
throw error;
}
});

Comment on lines 11 to 33
async function login(page) {
await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
// await page.getByText('Login as internal user').click();
await page
.locator('[data-cy="login-user-id"]')
.fill(process.env["ZO_ROOT_USER_EMAIL"]);

// wait for login api response
const waitForLogin = page.waitForResponse(response =>
response.url().includes('/auth/login') && response.status() === 200
)

await page
.locator('[data-cy="login-password"]')
.fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();

await waitForLogin

await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' })
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for login.

Consider adding error handling for the login process to manage potential issues.

async function login(page) {
    try {
        await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
        await page.locator('[data-cy="login-user-id"]').fill(process.env["ZO_ROOT_USER_EMAIL"]);
        const waitForLogin = page.waitForResponse(response =>
            response.url().includes('/auth/login') && response.status() === 200
        );
        await page.locator('[data-cy="login-password"]').fill(process.env["ZO_ROOT_USER_PASSWORD"]);
        await page.locator('[data-cy="login-sign-in"]').click();
        await waitForLogin;
        await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' });
    } catch (error) {
        console.error('Login failed:', error);
        throw error;
    }
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function login(page) {
await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
// await page.getByText('Login as internal user').click();
await page
.locator('[data-cy="login-user-id"]')
.fill(process.env["ZO_ROOT_USER_EMAIL"]);
// wait for login api response
const waitForLogin = page.waitForResponse(response =>
response.url().includes('/auth/login') && response.status() === 200
)
await page
.locator('[data-cy="login-password"]')
.fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();
await waitForLogin
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' })
}
async function login(page) {
try {
await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
await page.locator('[data-cy="login-user-id"]').fill(process.env["ZO_ROOT_USER_EMAIL"]);
const waitForLogin = page.waitForResponse(response =>
response.url().includes('/auth/login') && response.status() === 200
);
await page.locator('[data-cy="login-password"]').fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();
await waitForLogin;
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' });
} catch (error) {
console.error('Login failed:', error);
throw error;
}
}

Comment on lines 214 to 251
test('should update the data when changing between absolute and relative time using the Kolkata time zone.', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();


await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();

await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();

await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
await page.locator('[data-test="datetime-timezone-select"]').click();

await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
await page.getByText('Asia/Calcutta', { exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(300);

await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-absolute-tab"]').click();
await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();

await page.getByRole('button', { name: '7', exact: true }).click();

await page.getByRole('button', { name: '8', exact: true }).click();

await page.locator('[data-test="dashboard-apply"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for time zone change.

Consider adding error handling for the process of changing between absolute and relative time using the Kolkata time zone.

test('should update the data when changing between absolute and relative time using the Kolkata time zone.', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
        await page.getByText('e2e_automate').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
        await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
        await page.locator('[data-test="datetime-timezone-select"]').click();
        await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
        await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
        await page.getByText('Asia/Calcutta', { exact: true }).click();
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.waitForTimeout(300);
        await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-absolute-tab"]').click();
        await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();
        await page.getByRole('button', { name: '7', exact: true }).click();
        await page.getByRole('button', { name: '8', exact: true }).click();
        await page.locator('[data-test="dashboard-apply"]').click();
    } catch (error) {
        console.error('Time zone change failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should update the data when changing between absolute and relative time using the Kolkata time zone.', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
await page.locator('[data-test="datetime-timezone-select"]').click();
await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
await page.getByText('Asia/Calcutta', { exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(300);
await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-absolute-tab"]').click();
await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();
await page.getByRole('button', { name: '7', exact: true }).click();
await page.getByRole('button', { name: '8', exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
});
test('should update the data when changing between absolute and relative time using the Kolkata time zone.', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
await page.locator('[data-test="datetime-timezone-select"]').click();
await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
await page.getByText('Asia/Calcutta', { exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(300);
await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-absolute-tab"]').click();
await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();
await page.getByRole('button', { name: '7', exact: true }).click();
await page.getByRole('button', { name: '8', exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
} catch (error) {
console.error('Time zone change failed:', error);
throw error;
}
});

Comment on lines 254 to 292
test('should update the chart when entering a custom SQL query.', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();


await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.locator('[data-test="dashboard-customSql"]').click();

// Focus on the first line of the editor
await page.locator('.view-line').first().click();
await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');

// Fill the custom SQL query
await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
await page.waitForTimeout(400);

await page.locator('[data-test="dashboard-apply"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();

await page.waitForTimeout(200);

await page.locator('[data-test="dashboard-apply"]')//.toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(400);
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-panel-save"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for custom SQL query.

Consider adding error handling for the process of updating the chart with a custom SQL query.

test('should update the chart when entering a custom SQL query.', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
        await page.locator('[data-test="dashboard-customSql"]').click();
        await page.locator('.view-line').first().click();
        await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
        await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
        await page.waitForTimeout(400);
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();
        await page.waitForTimeout(200);
        await page.locator('[data-test="dashboard-apply"]');
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
        await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.waitForTimeout(400);
        await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
        await page.locator('[data-test="dashboard-panel-name"]').click();
        await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-panel-save"]').click();
    } catch (error) {
        console.error('Custom SQL query update failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should update the chart when entering a custom SQL query.', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.locator('[data-test="dashboard-customSql"]').click();
// Focus on the first line of the editor
await page.locator('.view-line').first().click();
await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
// Fill the custom SQL query
await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
await page.waitForTimeout(400);
await page.locator('[data-test="dashboard-apply"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();
await page.waitForTimeout(200);
await page.locator('[data-test="dashboard-apply"]')//.toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(400);
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-panel-save"]').click();
});
test('should update the chart when entering a custom SQL query.', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.locator('[data-test="dashboard-customSql"]').click();
// Focus on the first line of the editor
await page.locator('.view-line').first().click();
await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
// Fill the custom SQL query
await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
await page.waitForTimeout(400);
await page.locator('[data-test="dashboard-apply"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();
await page.waitForTimeout(200);
await page.locator('[data-test="dashboard-apply"]');
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(400);
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-panel-save"]').click();
} catch (error) {
console.error('Custom SQL query update failed:', error);
throw error;
}
});

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 19

Outside diff range, codebase verification and nitpick comments (1)
tests/ui-testing/playwright-tests/dashboard.spec.js (1)

1-5: Remove unused imports.

The log and parseArgs imports are not used in the file.

- import { log } from "console";
- import { parseArgs } from "util";
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fef9007 and 4e9c888.

Files selected for processing (2)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
Additional context used
Path-based instructions (2)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 40-40: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (1)
tests/ui-testing/playwright-tests/dashboard.spec.js (1)

294-336: Ensure proper error handling for chart type change.

Consider adding error handling for the process of updating the chart when changing the chart type.

test('should display the correct and updated chart when changing the chart type', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
        await page.getByText('e2e_automate').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-relative-3-w-btn"]').click();
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.waitForTimeout(200);
        await page.locator('[data-test="selected-chart-area-item"]').click();
        await expect(page.locator('[data-test="selected-chart-area-stacked-item"]')).toBeVisible();
        await page.locator('[data-test="selected-chart-h-bar-item"] img').click();
        await expect(page.locator('[data-test="selected-chart-scatter-item"] img')).toBeVisible();
        await page.locator('[data-test="selected-chart-scatter-item"] img').click();
        await expect(page.locator('[data-test="selected-chart-gauge-item"] img')).toBeVisible();
        await page.locator('[data-test="selected-chart-gauge-item"] img').click();
        await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
        await page.locator('[data-test="dashboard-panel-name"]').click();
        await page.locator('[data-test="dashboard-panel-name"]').fill('Dash_01');
        await page.locator('[data-test="dashboard-panel-save"]').click();
        await page.waitForTimeout(200);
        await page.locator('[data-test="dashboard-edit-panel-Dash_01-dropdown"]').click();
        await page.locator('[data-test="dashboard-delete-panel"]').click();
        await page.locator('[data-test="confirm-button"]').click();

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines 116 to 134
test('should create logs when queries are ingested into the search field', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/logs-item"]').click();
await page.getByLabel('SQL Mode').locator('div').nth(2).click();
await page.waitForTimeout(1000);
await page.locator('[data-test="logs-search-index-list"]').getByText('arrow_drop_down').click();
await page.locator('[data-test="log-search-index-list-stream-toggle-e2e_automate"] div').nth(2).click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();


});
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should create logs when queries are ingested into the search field', async ({ page }) => {
  try {
    await page.locator('[data-test="menu-link-\\/logs-item"]').click();
    await page.getByLabel('SQL Mode').locator('div').nth(2).click();
    await page.waitForTimeout(1000);
    await page.locator('[data-test="logs-search-index-list"]').getByText('arrow_drop_down').click();
    await page.locator('[data-test="log-search-index-list-stream-toggle-e2e_automate"] div').nth(2).click();
    await page.locator('[data-test="date-time-btn"]').click();
    await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

Comment on lines 130 to 155
test('should set the default chart type and default X and Y axes to automatic after clicking the Visualize button', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/logs-item"]').click();
await page.locator('[data-test="logs-search-index-list"]').getByText('arrow_drop_down').click();
await page.locator('[data-test="logs-logs-toggle"]').click();
await page.waitForTimeout(1000);
await page.locator('[data-test="logs-visualize-toggle"]').click();
await expect(page.locator('.q-list > div:nth-child(3)')).toBeVisible();
await page.locator('[data-test="dashboard-x-item-_timestamp"]').click();
await expect(page.locator('[data-test="dashboard-x-item-_timestamp"]')).toBeVisible();
await expect(page.locator('[data-test="dashboard-y-item-_timestamp"]')).toBeVisible();

});
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should set the default chart type and default X and Y axes to automatic after clicking the Visualize button', async ({ page }) => {
  try {
    await page.locator('[data-test="menu-link-\\/logs-item"]').click();
    await page.locator('[data-test="logs-search-index-list"]').getByText('arrow_drop_down').click();
    await page.locator('[data-test="logs-logs-toggle"]').click();
    await page.waitForTimeout(1000);
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await expect(page.locator('.q-list > div:nth-child(3)')).toBeVisible();
    await page.locator('[data-test="dashboard-x-item-_timestamp"]').click();
    await expect(page.locator('[data-test="dashboard-x-item-_timestamp"]')).toBeVisible();
    await expect(page.locator('[data-test="dashboard-y-item-_timestamp"]')).toBeVisible();
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

Comment on lines 144 to 190
test('should adjust the displayed data effectively when editing the X-axis and Y-axis on the chart', async ({ page }) => {

await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-visualize-toggle"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.getByText('Chart configuration has been').click();
await expect(page.getByText('Chart configuration has been')).toBeVisible();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await expect(page.getByText('There are some errors, please')).toBeVisible();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="dashboard-y-item-_timestamp-remove"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 470,
y: 13
}
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should adjust the displayed data effectively when editing the X-axis and Y-axis on the chart', async ({ page }) => {
  try {
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
    await page.getByText('Chart configuration has been').click();
    await expect(page.getByText('Chart configuration has been')).toBeVisible();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await expect(page.getByText('There are some errors, please')).toBeVisible();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-x-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="dashboard-y-item-_timestamp-remove"]').click();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-y-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 470, y: 13 }
    });
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

Comment on lines 166 to 266
test('should correctly plot the data according to the new chart type when changing the chart type', async ({ page }) => {

await page.locator('[data-test="logs-visualize-toggle"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('.q-list > div:nth-child(5)').click();
await expect(page.locator('[data-test="chart-renderer"] canvas')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 457,
y: 135
}
});
await page.locator('.q-pa-none > .q-list > div').first().click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 590,
y: 127
}
});
await page.locator('.q-list > div:nth-child(2)').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 475,
y: 45
}
});
await page.locator('[data-test="selected-chart-h-bar-item"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 722,
y: 52
}
});
await page.locator('.q-list > div:nth-child(6)').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 362,
y: 30
}
});
await page.locator('div:nth-child(11)').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 650,
y: 85
}
});
await page.locator('div:nth-child(12)').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 216,
y: 53
}
});
await page.locator('div:nth-child(17)').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 423,
y: 127
}
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should correctly plot the data according to the new chart type when changing the chart type', async ({ page }) => {
  try {
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('.q-list > div:nth-child(5)').click();
    await expect(page.locator('[data-test="chart-renderer"] canvas')).toBeVisible();
    await page.locator('[data-test="date-time-btn"]').click();
    await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 457, y: 135 }
    });
    await page.locator('.q-pa-none > .q-list > div').first().click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 590, y: 127 }
    });
    await page.locator('.q-list > div:nth-child(2)').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 475, y: 45 }
    });
    await page.locator('[data-test="selected-chart-h-bar-item"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 722, y: 52 }
    });
    await page.locator('.q-list > div:nth-child(6)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 362, y: 30 }
    });
    await page.locator('div:nth-child(11)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 650, y: 85 }
    });
    await page.locator('div:nth-child(12)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 216, y: 53 }
    });
    await page.locator('div:nth-child(17)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 423, y: 127 }
    });
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

Comment on lines 235 to 297
test('should not reflect changes in the search query on the logs page if a field is changed or added in the visualization', async ({ page }) => {

// remain to mention compare qaury

await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.getByLabel('Expand "kubernetes_container_image"').click();
await page.locator('[data-test="logs-search-subfield-add-kubernetes_container_image-058694856476\\.dkr\\.ecr\\.us-west-2\\.amazonaws\\.com\\/ziox\\:v0\\.0\\.3"] [data-test="log-search-subfield-list-equal-kubernetes_container_image-field-btn"]').click();
await page.locator('[data-test="logs-search-subfield-add-kubernetes_container_image-sha256\\:90e0a12eae07ad3d0bbfbb73b076ba3ce6e5ad38fb93babc22fba4d19206ca6b"] [data-test="log-search-subfield-list-not-equal-kubernetes_container_image-field-btn"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-visualize-toggle"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-logs-toggle"]').click();
await page.locator('[data-test="confirm-button"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should not reflect changes in the search query on the logs page if a field is changed or added in the visualization', async ({ page }) => {
  try {
    await page.locator('[data-test="date-time-btn"]').click();
    await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.getByLabel('Expand "kubernetes_container_image"').click();
    await page.locator('[data-test="logs-search-subfield-add-kubernetes_container_image-058694856476\\.dkr\\.ecr\\.us-west-2\\.amazonaws\\.com\\/ziox\\:v0\\.0\\.3"] [data-test="log-search-subfield-list-equal-kubernetes_container_image-field-btn"]').click();
    await page.locator('[data-test="logs-search-subfield-add-kubernetes_container_image-sha256\\:90e0a12eae07ad3d0bbfbb73b076ba3ce6e5ad38fb93babc22fba4d19206ca6b"] [data-test="log-search-subfield-list-not-equal-kubernetes_container_image-field-btn"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data

<!-- This is an auto-generated comment by CodeRabbit -->

@@ -0,0 +1,462 @@
import { test, expect } from "@playwright/test";
import logData from "../cypress/fixtures/log.json";
import { log } from "console";
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unnecessary import.

The import from "console" is not used and should be removed to clean up the code.

- import { log } from "console";
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { log } from "console";

@ktx-akshay ktx-akshay force-pushed the test/dasboard/visulization branch from 4e9c888 to d3d7e62 Compare August 2, 2024 10:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

Outside diff range, codebase verification and nitpick comments (1)
tests/ui-testing/playwright-tests/dashboard.spec.js (1)

52-63: Use configurable timeout values.

Hardcoding timeout values can lead to maintenance issues. Consider using a configurable timeout value.

async function applyQueryButton(page) {
    // click on the run query button
    // Type the value of a variable into an input field
    const search = page.waitForResponse(logData.applyQuery);
-    await page.waitForTimeout(3000);
+    const timeout = process.env.QUERY_TIMEOUT || 3000;
+    await page.waitForTimeout(timeout);
    await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
        force: true,
    });
    // get the data from the search variable
    await expect.poll(async () => (await search).status()).toBe(200);
    // await search.hits.FIXME_should("be.an", "array");
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4e9c888 and d3d7e62.

Files selected for processing (4)
  • .github/workflows/playwright.yml (1 hunks)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/vrl.spec.js (1 hunks)
Files not reviewed due to server errors (2)
  • tests/ui-testing/playwright-tests/visualize.spec.js
  • tests/ui-testing/playwright-tests/vrl.spec.js
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/playwright.yml
Additional context used
Path-based instructions (3)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/vrl.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 40-40: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/vrl.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Comment on lines 294 to 64
test('should display the correct and updated chart when changing the chart type', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();

await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();

await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();

// await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_docker_id"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-w-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(200);

await page.locator('[data-test="selected-chart-area-item"]').click();

await expect(page.locator('[data-test="selected-chart-area-stacked-item"]')).toBeVisible();

await page.locator('[data-test="selected-chart-h-bar-item"] img').click();
await expect(page.locator('[data-test="selected-chart-scatter-item"] img')).toBeVisible();

await page.locator('[data-test="selected-chart-scatter-item"] img').click();
await expect(page.locator('[data-test="selected-chart-gauge-item"] img')).toBeVisible();

await page.locator('[data-test="selected-chart-gauge-item"] img').click();
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();

await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill('Dash_01');
await page.locator('[data-test="dashboard-panel-save"]').click();
await page.waitForTimeout(200);
await page.locator('[data-test="dashboard-edit-panel-Dash_01-dropdown"]').click();
await page.locator('[data-test="dashboard-delete-panel"]').click();
await page.locator('[data-test="confirm-button"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for chart type change.

Consider adding error handling for the process of updating the chart when changing the chart type.

test('should display the correct and updated chart when changing the chart type', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
        await page.getByText('e2e_automate').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines 253 to 292
test('should update the chart with the results of a custom SQL query', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();


await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.locator('[data-test="dashboard-customSql"]').click();

// Focus on the first line of the editor
await page.locator('.view-line').first().click();
await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');

// Fill the custom SQL query
await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
await page.waitForTimeout(400);

await page.locator('[data-test="dashboard-apply"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();

await page.waitForTimeout(200);

await page.locator('[data-test="dashboard-apply"]')//.toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(400);
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-panel-save"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for custom SQL query.

Consider adding error handling for the process of updating the chart with a custom SQL query.

test('should update the chart when entering a custom SQL query.', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
        await page.locator('[data-test="dashboard-customSql"]').click();
        await page.locator('.view-line').first().click();
        await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
        await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
        await page.waitForTimeout(400);
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();
        await page.waitForTimeout(200);
        await page.locator('[data-test="dashboard-apply"]');
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
        await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.waitForTimeout(400);
        await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
        await page.locator('[data-test="dashboard-panel-name"]').click();
        await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-panel-save"]').click();
    } catch (error) {
        console.error('Custom SQL query update failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should update the chart with the results of a custom SQL query', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.locator('[data-test="dashboard-customSql"]').click();
// Focus on the first line of the editor
await page.locator('.view-line').first().click();
await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
// Fill the custom SQL query
await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
await page.waitForTimeout(400);
await page.locator('[data-test="dashboard-apply"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();
await page.waitForTimeout(200);
await page.locator('[data-test="dashboard-apply"]')//.toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(400);
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-panel-save"]').click();
});
test('should update the chart with the results of a custom SQL query', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
await page.locator('[data-test="dashboard-customSql"]').click();
// Focus on the first line of the editor
await page.locator('.view-line').first().click();
await page.locator('[data-test="dashboard-panel-query-editor"]').getByLabel('Editor content;Press Alt+F1').fill('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
// Fill the custom SQL query
await page.keyboard.type('SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1", kubernetes_container_name as "breakdown_1" FROM "e2e_automate" GROUP BY x_axis_1, breakdown_1');
await page.waitForTimeout(400);
await page.locator('[data-test="dashboard-apply"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-x_axis_1"] [data-test="dashboard-add-x-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-y_axis_1"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-breakdown_1"] [data-test="dashboard-add-b-data"]').click();
await page.waitForTimeout(200);
await page.locator('[data-test="dashboard-apply"]')//.toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-30-m-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(400);
await expect(page.locator('[data-test="dashboard-panel-name"]')).toBeVisible();
await page.locator('[data-test="dashboard-panel-name"]').click();
await page.locator('[data-test="dashboard-panel-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-panel-save"]').click();
} catch (error) {
console.error('Custom SQL query update failed:', error);
throw error;
}
});

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Outside diff range, codebase verification and nitpick comments (1)
tests/ui-testing/playwright-tests/dashboard.spec.js (1)

3-5: Remove unused imports.

The log and parseArgs imports are not used in the file.

- import { log } from "console";
- import { parseArgs } from "util";
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d3d7e62 and b74518f.

Files selected for processing (2)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
Additional context used
Path-based instructions (2)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 40-40: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (11)
tests/ui-testing/playwright-tests/visualize.spec.js (10)

8-22: Enhance error handling and readability in login function.

Add error handling, comments, and replace hardcoded timeouts with element-specific waits.

async function login(page) {
  try {
    await page.goto(process.env["ZO_BASE_URL"]);
    await page.waitForSelector('[data-cy="login-user-id"]');
    // Fill in user ID
    await page.locator('[data-cy="login-user-id"]').fill(process.env["ZO_ROOT_USER_EMAIL"]);
    // Fill in password
    await page.locator('[data-cy="login-password"]').fill(process.env["ZO_ROOT_USER_PASSWORD"]);
    await page.locator('[data-cy="login-sign-in"]').click();
    await page.waitForNavigation();
    await page.goto(process.env["ZO_BASE_URL"]);
  } catch (error) {
    console.error("Login failed:", error);
  }
}

24-34: Enhance error handling and readability in selectStreamAndStreamTypeForLogs function.

Add error handling and comments for better readability.

const selectStreamAndStreamTypeForLogs = async (page, stream) => {
  try {
    await page.waitForTimeout(4000);
    await page.locator('[data-test="log-search-index-list-select-stream"]').click({ force: true });
    // Select the stream from the dropdown
    await page.locator("div.q-item").getByText(`${stream}`).first().click({ force: true });
  } catch (error) {
    console.error(`Failed to select stream ${stream}:`, error);
  }
};

42-53: Enhance error handling and readability in applyQueryButton function.

Add error handling and comments for better readability.

async function applyQueryButton(page) {
  try {
    // Wait for the query response
    const search = page.waitForResponse(logData.applyQuery);
    await page.waitForTimeout(3000);
    // Click on the run query button
    await page.locator("[data-test='logs-search-bar-refresh-btn']").click({ force: true });
    // Ensure the response status is 200
    await expect.poll(async () => (await search).status()).toBe(200);
  } catch (error) {
    console.error("Failed to apply query:", error);
  }
}

61-114: Enhance error handling and readability in test.beforeEach setup.

Add error handling and comments for better readability.

test.beforeEach(async ({ page }) => {
  console.log("running before each");
  try {
    await login(page);
    await page.waitForTimeout(5000);
    const orgId = process.env["ORGNAME"];
    const streamName = "e2e_automate";
    const basicAuthCredentials = Buffer.from(
      `${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
    ).toString("base64");

    const headers = {
      Authorization: `Basic ${basicAuthCredentials}`,
      "Content-Type": "application/json",
    };

    const response = await page.evaluate(
      async ({ url, headers, orgId, streamName, logsdata }) => {
        const fetchResponse = await fetch(
          `${url}/api/${orgId}/${streamName}/_json`,
          {
            method: "POST",
            headers: headers,
            body: JSON.stringify(logsdata),
          }
        );
        return await fetchResponse.json();
      },
      {
        url: process.env.INGESTION_URL,
        headers: headers,
        orgId: orgId,
        streamName: streamName,
        logsdata: logsdata,
      }
    );

    console.log(response);
    await page.goto(`${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`);
    await page.waitForResponse("**/api/default/_search**");
    await selectStreamAndStreamTypeForLogs(page, logData.Stream);
    await applyQueryButton(page);
  } catch (error) {
    console.error("Setup failed:", error);
  }
});

116-128: Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should create logs when queries are ingested into the search field', async ({ page }) => {
  try {
    await page.locator('[data-test="menu-link-\\/logs-item"]').click();
    await page.getByLabel('SQL Mode').locator('div').nth(2).click();
    await page.waitForTimeout(1000);
    await page.locator('[data-test="logs-search-index-list"]').getByText('arrow_drop_down').click();
    await page.locator('[data-test="log-search-index-list-stream-toggle-e2e_automate"] div').nth(2).click();
    await page.locator('[data-test="date-time-btn"]').click();
    await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

130-142: Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should set the default chart type and default X and Y axes to automatic after clicking the Visualize button', async ({ page }) => {
  try {
    await page.locator('[data-test="menu-link-\\/logs-item"]').click();
    await page.locator('[data-test="logs-search-index-list"]').getByText('arrow_drop_down').click();
    await page.locator('[data-test="logs-logs-toggle"]').click();
    await page.waitForTimeout(1000);
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await expect(page.locator('.q-list > div:nth-child(3)')).toBeVisible();
    await page.locator('[data-test="dashboard-x-item-_timestamp"]').click();
    await expect(page.locator('[data-test="dashboard-x-item-_timestamp"]')).toBeVisible();
    await expect(page.locator('[data-test="dashboard-y-item-_timestamp"]')).toBeVisible();
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

144-164: Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should adjust the displayed data effectively when editing the X-axis and Y-axis on the chart', async ({ page }) => {
  try {
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await page.locator('[data-test="dashboard-x-item-_timestamp-remove"]').click();
    await page.getByText('Chart configuration has been').click();
    await expect(page.getByText('Chart configuration has been')).toBeVisible();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await expect(page.getByText('There are some errors, please')).toBeVisible();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-x-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="dashboard-y-item-_timestamp-remove"]').click();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-y-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 470, y: 13 }
    });
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

166-233: Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should correctly plot the data according to the new chart type when changing the chart type', async ({ page }) => {
  try {
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('.q-list > div:nth-child(5)').click();
    await expect(page.locator('[data-test="chart-renderer"] canvas')).toBeVisible();
    await page.locator('[data-test="date-time-btn"]').click();
    await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 457, y: 135 }
    });
    await page.locator('.q-pa-none > .q-list > div').first().click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 590, y: 127 }
    });
    await page.locator('.q-list > div:nth-child(2)').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 475, y: 45 }
    });
    await page.locator('[data-test="selected-chart-h-bar-item"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 722, y: 52 }
    });
    await page.locator('.q-list > div:nth-child(6)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 362, y: 30 }
    });
    await page.locator('div:nth-child(11)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 650, y: 85 }
    });
    await page.locator('div:nth-child(12)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 216, y: 53 }
    });
    await page.locator('div:nth-child(17)').click();
    await page.locator('[data-test="chart-renderer"] canvas').click({
      position: { x: 423, y: 127 }
    });
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

235-251: Enhance error handling and readability in test case.

Add error handling and comments for better readability.

test('should not reflect changes in the search query on the logs page if a field is changed or added in the visualization', async ({ page }) => {
  try {
    await page.locator('[data-test="date-time-btn"]').click();
    await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.getByLabel('Expand "kubernetes_container_image"').click();
    await page.locator('[data-test="logs-search-subfield-add-kubernetes_container_image-058694856476\\.dkr\\.ecr\\.us-west-2\\.amazonaws\\.com\\/ziox\\:v0\\.0\\.3"] [data-test="log-search-subfield-list-equal-kubernetes_container_image-field-btn"]').click();
    await page.locator('[data-test="logs-search-subfield-add-kubernetes_container_image-sha256\\:90e0a12eae07ad3d0bbfbb73b076ba3ce6e5ad38fb93babc22fba4d19206ca6b"] [data-test="log-search-subfield-list-not-equal-kubernetes_container_image-field-btn"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="logs-visualize-toggle"]').click();
    await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]').click();
    await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
    await page.locator('[data-test="logs-logs-toggle"]').click();
    await page.locator('[data-test="confirm-button"]').click();
  } catch (error) {
    console.error("Test case failed:", error);
  }
});

253-262: Enhance error handling and readability in test case.

Add error handling and comments for better

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

253-292: Ensure proper error handling for custom SQL query.

Consider adding error handling for the process of updating the chart with a custom SQL query.

test('should update the chart with the results of a custom SQL query.', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines 47 to 50
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using control characters in regular expressions.

Control characters are unusual and potentially incorrect inputs. Update the regex to avoid using control characters.

function removeUTFCharacters(text) {
    // Remove UTF characters using regular expression
-    return text.replace(/[^\x00-\x7F]/g, " ");
+    return text.replace(/[^\u0000-\u007F]/g, " ");
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\u0000-\u007F]/g, " ");
Tools
Biome

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Comment on lines 173 to 188
test('should create a duplicate of the dashboard', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });

await page.locator('[data-test="dashboard-back-btn"]').click();

await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();

});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard duplication.

Consider adding error handling for the dashboard duplication process to manage potential issues.

test('should create a duplicate of the dashboard', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
        await page.locator('[data-test="dashboard-back-btn"]').click();
        await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
        await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();
    } catch (error) {
        console.error('Dashboard duplication failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should create a duplicate of the dashboard', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();
});
test('should create a duplicate of the dashboard', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]')).toBeVisible();
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-duplicate"]').click();
} catch (error) {
console.error('Dashboard duplication failed:', error);
throw error;
}
});

Comment on lines 157 to 171
test('should delete the dashboard', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-back-btn"]').click();

await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
await page.locator('[data-test="confirm-button"]').click();

});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard deletion.

Consider adding error handling for the dashboard deletion process to manage potential issues.

test('should delete the dashboard', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-back-btn"]').click();
        await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
        await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
        await page.locator('[data-test="confirm-button"]').click();
    } catch (error) {
        console.error('Dashboard deletion failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should delete the dashboard', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
await page.locator('[data-test="confirm-button"]').click();
});
test('should delete the dashboard', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-back-btn"]').click();
await expect(page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]')).toBeVisible({ timeout: 30000 });
await page.getByRole('row', { name: `01 ${randomDashboardName}` }).locator('[data-test="dashboard-delete"]').click();
await page.locator('[data-test="confirm-button"]').click();
} catch (error) {
console.error('Dashboard deletion failed:', error);
throw error;
}
});

Comment on lines 33 to 48
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(response =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
)

await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**")

await page.waitForSelector(`text="Please wait while loading dashboards..."`, { state: 'hidden' })
await dashboardListApi
await page.waitForTimeout(500)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for waiting dashboard page.

Consider adding error handling for the dashboard page loading process to manage potential issues.

async function waitForDashboardPage(page) {
    try {
        const dashboardListApi = page.waitForResponse(response =>
            /\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
        );
        await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
        await page.waitForSelector(`text="Please wait while loading dashboards..."`, { state: 'hidden' });
        await dashboardListApi;
        await page.waitForTimeout(500);
    } catch (error) {
        console.error('Dashboard page loading failed:', error);
        throw error;
    }
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(response =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
)
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**")
await page.waitForSelector(`text="Please wait while loading dashboards..."`, { state: 'hidden' })
await dashboardListApi
await page.waitForTimeout(500)
}
async function waitForDashboardPage(page) {
try {
const dashboardListApi = page.waitForResponse(response =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
await page.waitForSelector(`text="Please wait while loading dashboards..."`, { state: 'hidden' });
await dashboardListApi;
await page.waitForTimeout(500);
} catch (error) {
console.error('Dashboard page loading failed:', error);
throw error;
}
}

Comment on lines 52 to 63
async function applyQueryButton(page) {
// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
// get the data from the search variable
await expect.poll(async () => (await search).status()).toBe(200);
// await search.hits.FIXME_should("be.an", "array");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for applying query button.

Consider adding error handling for the process of applying the query to manage potential issues.

async function applyQueryButton(page) {
    try {
        // click on the run query button
        // Type the value of a variable into an input field
        const search = page.waitForResponse(logData.applyQuery);
        await page.waitForTimeout(3000);
        await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
            force: true,
        });
        // get the data from the search variable
        await expect.poll(async () => (await search).status()).toBe(200);
    } catch (error) {
        console.error('Applying query failed:', error);
        throw error;
    }
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function applyQueryButton(page) {
// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
// get the data from the search variable
await expect.poll(async () => (await search).status()).toBe(200);
// await search.hits.FIXME_should("be.an", "array");
}
async function applyQueryButton(page) {
try {
// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
// get the data from the search variable
await expect.poll(async () => (await search).status()).toBe(200);
} catch (error) {
console.error('Applying query failed:', error);
throw error;
}
}

Comment on lines 145 to 64
test('should create a new dashboar', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });

});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard creation.

Consider adding error handling for the dashboard creation process to manage potential issues.

test('should create a new dashboard', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
    } catch (error) {
        console.error('Dashboard creation failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should create a new dashboar', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
});
test('should create a new dashboard', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 30000 });
} catch (error) {
console.error('Dashboard creation failed:', error);
throw error;
}
});

Comment on lines 11 to 33
async function login(page) {
await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
// await page.getByText('Login as internal user').click();
await page
.locator('[data-cy="login-user-id"]')
.fill(process.env["ZO_ROOT_USER_EMAIL"]);

// wait for login api response
const waitForLogin = page.waitForResponse(response =>
response.url().includes('/auth/login') && response.status() === 200
)

await page
.locator('[data-cy="login-password"]')
.fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();

await waitForLogin

await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' })
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for login.

Consider adding error handling for the login process to manage potential issues.

async function login(page) {
    try {
        await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
        await page.locator('[data-cy="login-user-id"]').fill(process.env["ZO_ROOT_USER_EMAIL"]);
        const waitForLogin = page.waitForResponse(response =>
            response.url().includes('/auth/login') && response.status() === 200
        );
        await page.locator('[data-cy="login-password"]').fill(process.env["ZO_ROOT_USER_PASSWORD"]);
        await page.locator('[data-cy="login-sign-in"]').click();
        await waitForLogin;
        await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' });
    } catch (error) {
        console.error('Login failed:', error);
        throw error;
    }
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function login(page) {
await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
// await page.getByText('Login as internal user').click();
await page
.locator('[data-cy="login-user-id"]')
.fill(process.env["ZO_ROOT_USER_EMAIL"]);
// wait for login api response
const waitForLogin = page.waitForResponse(response =>
response.url().includes('/auth/login') && response.status() === 200
)
await page
.locator('[data-cy="login-password"]')
.fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();
await waitForLogin
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' })
}
async function login(page) {
try {
await page.goto(process.env["ZO_BASE_URL"], { waitUntil: 'networkidle' });
await page.locator('[data-cy="login-user-id"]').fill(process.env["ZO_ROOT_USER_EMAIL"]);
const waitForLogin = page.waitForResponse(response =>
response.url().includes('/auth/login') && response.status() === 200
);
await page.locator('[data-cy="login-password"]').fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();
await waitForLogin;
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/", { waitUntil: 'networkidle' });
} catch (error) {
console.error('Login failed:', error);
throw error;
}
}

Comment on lines 190 to 211
test('should create a dashboard and add the breakdown', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();

await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();

// Refine the locator for 'e2e_automate'
await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();

await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();

await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
await page.locator('[data-test="dashboard-apply"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for dashboard creation with breakdown.

Consider adding error handling for the dashboard creation process with breakdown to manage potential issues.

test('should create a dashboard and add the breakdown', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
        await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
        await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
        await page.locator('[data-test="dashboard-apply"]').click();
    } catch (error) {
        console.error('Dashboard creation with breakdown failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should create a dashboard and add the breakdown', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
// Refine the locator for 'e2e_automate'
await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
await page.locator('[data-test="dashboard-apply"]').click();
});
test('should create a dashboard and add the breakdown', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText('Dashboard added successfully.')).toBeVisible({ timeout: 3000 });
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.locator('span').filter({ hasText: /^e2e_automate$/ }).click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await expect(page.locator('[data-test="dashboard-apply"]')).toBeVisible();
await page.locator('[data-test="dashboard-apply"]').click();
} catch (error) {
console.error('Dashboard creation with breakdown failed:', error);
throw error;
}
});

Comment on lines 213 to 250
test('should update the data when changing the time between both absolute and relative time using the Kolkata time zone.', async ({ page }) => {

await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();


await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();

await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();

await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
await page.locator('[data-test="datetime-timezone-select"]').click();

await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
await page.getByText('Asia/Calcutta', { exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(300);

await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-absolute-tab"]').click();
await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();

await page.getByRole('button', { name: '7', exact: true }).click();

await page.getByRole('button', { name: '8', exact: true }).click();

await page.locator('[data-test="dashboard-apply"]').click();
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for time zone change.

Consider adding error handling for the process of changing between absolute and relative time using the Kolkata time zone.

test('should update the data when changing the time between both absolute and relative time using the Kolkata time zone.', async ({ page }) => {
    try {
        await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
        await waitForDashboardPage(page);
        await page.locator('[data-test="dashboard-add"]').click();
        await page.locator('[data-test="add-dashboard-name"]').click();
        await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
        await page.locator('[data-test="dashboard-add-submit"]').click();
        await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
        await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
        await page.getByText('e2e_automate').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
        await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
        await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
        await page.locator('[data-test="datetime-timezone-select"]').click();
        await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
        await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
        await page.getByText('Asia/Calcutta', { exact: true }).click();
        await page.locator('[data-test="dashboard-apply"]').click();
        await page.waitForTimeout(300);
        await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
        await page.locator('[data-test="date-time-btn"]').click();
        await page.locator('[data-test="date-time-absolute-tab"]').click();
        await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();
        await page.getByRole('button', { name: '7', exact: true }).click();
        await page.getByRole('button', { name: '8', exact: true }).click();
        await page.locator('[data-test="dashboard-apply"]').click();
    } catch (error) {
        console.error('Time zone change failed:', error);
        throw error;
    }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('should update the data when changing the time between both absolute and relative time using the Kolkata time zone.', async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page)
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
await page.locator('[data-test="datetime-timezone-select"]').click();
await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
await page.getByText('Asia/Calcutta', { exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(300);
await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-absolute-tab"]').click();
await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();
await page.getByRole('button', { name: '7', exact: true }).click();
await page.getByRole('button', { name: '8', exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
test('should update the data when changing the time between both absolute and relative time using the Kolkata time zone.', async ({ page }) => {
try {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page.locator('[data-test="add-dashboard-name"]').fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]').click();
await page.locator('label').filter({ hasText: 'Streamarrow_drop_down' }).locator('i').click();
await page.getByText('e2e_automate').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_hash"] [data-test="dashboard-add-y-data"]').click();
await page.locator('[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]').click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-3-h-btn"]').click();
await page.locator('label').filter({ hasText: 'Timezonearrow_drop_down' }).locator('i').click();
await page.locator('[data-test="datetime-timezone-select"]').click();
await page.locator('[data-test="datetime-timezone-select"]').press('Enter');
await page.locator('[data-test="datetime-timezone-select"]').fill('calcutta');
await page.getByText('Asia/Calcutta', { exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
await page.waitForTimeout(300);
await expect(page.locator('[data-test="date-time-btn"]')).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-absolute-tab"]').click();
await page.locator('button').filter({ hasText: 'chevron_left' }).first().click();
await page.getByRole('button', { name: '7', exact: true }).click();
await page.getByRole('button', { name: '8', exact: true }).click();
await page.locator('[data-test="dashboard-apply"]').click();
} catch (error) {
console.error('Time zone change failed:', error);
throw error;
}
});

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Outside diff range, codebase verification and nitpick comments (2)
tests/ui-testing/playwright-tests/dashboard.spec.js (2)

14-14: Remove commented-out code.

The commented-out code should be removed to maintain code cleanliness.

-  //  await page.getByText('Login as internal user').click();

19-19: Remove commented-out code.

The commented-out code should be removed to maintain code cleanliness.

-  // wait for login api response
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b74518f and db642ae.

Files selected for processing (2)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
Additional context used
Path-based instructions (2)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 40-40: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 57-57: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (4)
tests/ui-testing/playwright-tests/dashboard.spec.js (4)

37-50: LGTM!

The waitForDashboardPage function is well-implemented.


148-160: LGTM!

The test case should create a new dashboard is well-structured.


162-183: LGTM!

The test case should delete the dashboard is well-structured.


185-209: LGTM!

The test case should create a duplicate of the dashboard is well-structured.

@ktx-akshay ktx-akshay force-pushed the test/dasboard/visulization branch from db642ae to d2120df Compare August 5, 2024 05:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between db642ae and d2120df.

Files selected for processing (4)
  • .github/workflows/playwright.yml (1 hunks)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/vrl.spec.js (1 hunks)
Files not reviewed due to server errors (2)
  • tests/ui-testing/playwright-tests/visualize.spec.js
  • tests/ui-testing/playwright-tests/vrl.spec.js
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/playwright.yml
Additional context used
Path-based instructions (3)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/vrl.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 40-40: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/vrl.spec.js

[error] 50-50: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 57-57: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (14)
tests/ui-testing/playwright-tests/dashboard.spec.js (14)

3-5: Remove unused imports.

The log and parseArgs imports are not used in the file.

- import { log } from "console";
- import { parseArgs } from "util";

14-14: Remove commented-out code.

The commented-out line is not needed and should be removed to keep the code clean.

-  //  await page.getByText('Login as internal user').click();

37-50: LGTM!

The function waitForDashboardPage performs the expected actions and looks good.


148-160: LGTM!

The test case should create a new dashboard performs the expected actions and looks good.


162-183: LGTM!

The test case should delete the dashboard performs the expected actions and looks good.


185-209: LGTM!

The test case should create a duplicate of the dashboard performs the expected actions and looks good.


211-252: LGTM!

The test case should create a dashboard and add the breakdown performs the expected actions and looks good.


254-318: LGTM!

The test case should update the data when changing the time between both absolute and relative time using the Kolkata time zone performs the expected actions and looks good.


320-388: LGTM!

The test case should update the chart with the results of a custom SQL query performs the expected actions and looks good.


390-459: LGTM!

The test case should display the correct and updated chart when changing the chart type performs the expected actions and looks good.


461-550: LGTM!

The test case should navigate to another dashboard using the DrillDown feature performs the expected actions and looks good.


730-813: LGTM!

The test case should dynamically update the filtered data when applying the dynamic filter on the dashboard performs the expected actions and looks good.


1846-1906: LGTM!

The test case should correctly handle and display string and numeric values when no value replacement occurs performs the expected actions and looks good.


54-57: Fix the regular expression to avoid control characters.

The regular expression contains control characters, which can be problematic.

-    return text.replace(/[^\x00-\x7F]/g, " ");
+    return text.replace(/[^\u0000-\u007F]/g, " ");
Tools
Biome

[error] 57-57: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)





Copy link
Contributor

Choose a reason for hiding this comment

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

remove these additional lines

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 18

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d2120df and af91bad.

Files selected for processing (3)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/vrl.spec.js (1 hunks)
Additional context used
Path-based instructions (3)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/vrl.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 39-39: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/vrl.spec.js

[error] 56-56: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 55-55: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (4)
tests/ui-testing/playwright-tests/dashboard.spec.js (2)

57-68: LGTM!

The function correctly waits for a response and checks its status.


10-33: LGTM!

The function correctly handles the login process, including filling in credentials and waiting for the login response.

tests/ui-testing/playwright-tests/visualize.spec.js (1)

157-190: Replace hardcoded timeouts with element-specific waits.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(1000);
+  await page.waitForSelector('[data-test="logs-visualize-toggle"]');

Likely invalid or redundant comment.

tests/ui-testing/playwright-tests/vrl.spec.js (1)

11-34: Replace hardcoded timeouts with element-specific waits.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(1000);
+  await page.waitForSelector('[data-cy="login-user-id"]');

Likely invalid or redundant comment.

function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the regular expression to avoid control characters.

The regular expression contains control characters, which can be problematic.

-    return text.replace(/[^\x00-\x7F]/g, " ");
+    return text.replace(/[^\u0000-\u007F]/g, " ");
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return text.replace(/[^\x00-\x7F]/g, " ");
return text.replace(/[^\u0000-\u007F]/g, " ");
Tools
Biome

[error] 55-55: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Comment on lines +299 to +314
test("should handle an empty query in visualization without displaying an error.", async ({
page,
}) => {
await page.locator(".view-line").first().click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-visualize-toggle"]').click();
await expect(page.locator(".view-line").first()).toBeVisible();
await expect(
page.locator('[data-test="dashboard-x-item-_timestamp"]')
).toBeVisible();
await expect(
page.locator('[data-test="dashboard-y-item-_timestamp"]')
).toBeVisible();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeouts with element-specific waits.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(1000);
+  await page.waitForSelector('[data-test="logs-visualize-toggle"]');

Committable suggestion was skipped due to low confidence.

Comment on lines +192 to +266
test("should correctly plot the data according to the new chart type when changing the chart type", async ({
page,
}) => {
await page.locator('[data-test="logs-visualize-toggle"]').click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]'
)
.click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator(".q-list > div:nth-child(5)").click();
await expect(
page.locator('[data-test="chart-renderer"] canvas')
).toBeVisible();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 457,
y: 135,
},
});
await page.locator(".q-pa-none > .q-list > div").first().click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 590,
y: 127,
},
});
await page.locator(".q-list > div:nth-child(2)").click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 475,
y: 45,
},
});
await page.locator('[data-test="selected-chart-h-bar-item"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 722,
y: 52,
},
});
await page.locator(".q-list > div:nth-child(6)").click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 362,
y: 30,
},
});
await page.locator("div:nth-child(11)").click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 650,
y: 85,
},
});
await page.locator("div:nth-child(12)").click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 216,
y: 53,
},
});
await page.locator("div:nth-child(17)").click();
await page.locator('[data-test="chart-renderer"] canvas').click({
position: {
x: 423,
y: 127,
},
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeouts with element-specific waits.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(1000);
+  await page.waitForSelector('[data-test="logs-visualize-toggle"]');

Committable suggestion was skipped due to low confidence.

Comment on lines +362 to +420
test("should not update the query on the logs page when switching between logs and visualization, even if changes are made in any field in the visualization", async ({
page,
}) => {
// Chart should not reflect changes made to X or Y axis.

await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.getByLabel('Expand "kubernetes_container_hash"').click();
await page
.locator(
'[data-test="logs-search-subfield-add-kubernetes_container_hash-058694856476\\.dkr\\.ecr\\.us-west-2\\.amazonaws\\.com\\/ziox\\@sha256\\:3dbbb0dc1eab2d5a3b3e4a75fd87d194e8095c92d7b2b62e7cdbd07020f54589"] [data-test="log-search-subfield-list-equal-kubernetes_container_hash-field-btn"]'
)
.click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-visualize-toggle"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();

let exceptionBefore = null;
let exceptionAfter = null;

// try and catch block for compare tow field.

try {
await expect(
page.locator(
'[data-test="dashboard-filter-item-kubernetes_container_hash"]'
)
).toBeVisible();
} catch (e) {
exceptionBefore = e;
}

await page
.locator(
'[data-test="dashboard-filter-item-kubernetes_container_hash-remove"]'
)
.click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-logs-toggle"]').click();
await page.locator('[data-test="confirm-button"]').click();
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
await page.locator('[data-test="logs-visualize-toggle"]').click();

try {
await expect(
page.locator(
'[data-test="dashboard-filter-item-kubernetes_container_hash"]'
)
).toBeVisible();
} catch (e) {
exceptionAfter = e;
}

expect(exceptionBefore).toBe(exceptionAfter);

// Perform an additional refresh to ensure consistency
await page.locator('[data-test="logs-search-bar-refresh-btn"]').click();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeouts with element-specific waits.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(1000);
+  await page.waitForSelector('[data-test="logs-visualize-toggle"]');

Committable suggestion was skipped due to low confidence.

Comment on lines +23 to +33
const selectStreamAndStreamTypeForLogs = async (page, stream) => {
await page.waitForTimeout(4000);
await page
.locator('[data-test="log-search-index-list-select-stream"]')
.click({ force: true });
await page
.locator("div.q-item")
.getByText(`${stream}`)
.first()
.click({ force: true });
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(4000);
+  await page.waitForSelector('[data-test="log-search-index-list-select-stream"]');
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const selectStreamAndStreamTypeForLogs = async (page, stream) => {
await page.waitForTimeout(4000);
await page
.locator('[data-test="log-search-index-list-select-stream"]')
.click({ force: true });
await page
.locator("div.q-item")
.getByText(`${stream}`)
.first()
.click({ force: true });
};
const selectStreamAndStreamTypeForLogs = async (page, stream) => {
await page.waitForSelector('[data-test="log-search-index-list-select-stream"]');
await page
.locator('[data-test="log-search-index-list-select-stream"]')
.click({ force: true });
await page
.locator("div.q-item")
.getByText(`${stream}`)
.first()
.click({ force: true });
};

Comment on lines +53 to +57
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix regular expression to remove unexpected control character.

The regular expression contains an unexpected control character and should be corrected.

-  return text.replace(/[^\x00-\x7F]/g, " ");
+  return text.replace(/[^\x20-\x7E]/g, " ");
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
}
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x20-\x7E]/g, " ");
}
Tools
Biome

[error] 56-56: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Comment on lines +58 to +69
async function applyQueryButton(page) {
// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
// get the data from the search variable
await expect.poll(async () => (await search).status()).toBe(200);
// await search.hits.FIXME_should("be.an", "array");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(3000);
+  await page.waitForSelector("[data-test='logs-search-bar-refresh-btn']");
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function applyQueryButton(page) {
// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
// get the data from the search variable
await expect.poll(async () => (await search).status()).toBe(200);
// await search.hits.FIXME_should("be.an", "array");
}
async function applyQueryButton(page) {
// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForSelector("[data-test='logs-search-bar-refresh-btn']");
await page.locator("[data-test='logs-search-bar-refresh-btn']").click({
force: true,
});
// get the data from the search variable
await expect.poll(async () => (await search).status()).toBe(200);
// await search.hits.FIXME_should("be.an", "array");
}

Comment on lines +36 to +49
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);

await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");

await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(500);
+  await page.waitForSelector('text="Please wait while loading dashboards..."', { state: "hidden" });
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
}
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForSelector('text="Please wait while loading dashboards..."', { state: "hidden" });
}

Comment on lines +77 to +144
test.beforeEach(async ({ page }) => {
await login(page);

// just to make sure org is set
const orgNavigation = page.goto(
`${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
);

// ("ingests logs via API", () => {
const orgId = process.env["ORGNAME"];
const streamName = "e2e_automate";
const basicAuthCredentials = Buffer.from(
`${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
).toString("base64");

const headers = {
Authorization: `Basic ${basicAuthCredentials}`,
"Content-Type": "application/json",
};

// const logsdata = {}; // Fill this with your actual data

const fetchResponse = await fetch(
`${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`,
{
method: "POST",
headers: headers,
body: JSON.stringify(logsdata),
}
);
const response = await fetchResponse.json();

await orgNavigation;

// Making a POST request using fetch API
// const response = await page.evaluate(
// async ({ url, headers, orgId, streamName, logsdata }) => {
// const fetchResponse = await fetch(
// `${url}/api/${orgId}/${streamName}/_json`,
// {
// method: "POST",
// headers: headers,
// body: JSON.stringify(logsdata),
// }
// );
// return await fetchResponse.json();
// },
// {
// url: process.env.INGESTION_URL,
// headers: headers,
// orgId: orgId,
// streamName: streamName,
// logsdata: logsdata,
// }
// );

console.log(response);
// });
// const allorgs = page.waitForResponse("**/api/default/organizations**");
// const functions = page.waitForResponse("**/api/default/functions**");
// await page.goto(
// `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
// );
// const allsearch = page.waitForResponse("**/api/default/_search**");
// await selectStreamAndStreamTypeForLogs(page, logData.Stream);
// await applyQueryButton(page);
// const streams = page.waitForResponse("**/api/default/streams**");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling in beforeEach setup.

Add error handling for better reliability.

test.beforeEach(async ({ page }) => {
  try {
    await login(page);
    const orgNavigation = page.goto(
      `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
    );

    const orgId = process.env["ORGNAME"];
    const streamName = "e2e_automate";
    const basicAuthCredentials = Buffer.from(
      `${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
    ).toString("base64");

    const headers = {
      Authorization: `Basic ${basicAuthCredentials}`,
      "Content-Type": "application/json",
    };

    const fetchResponse = await fetch(
      `${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`,
      {
        method: "POST",
        headers: headers,
        body: JSON.stringify(logsdata),
      }
    );
    const response = await fetchResponse.json();
    await orgNavigation;
    console.log(response);
  } catch (error) {
    console.error("Setup failed:", error);
  }
});
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test.beforeEach(async ({ page }) => {
await login(page);
// just to make sure org is set
const orgNavigation = page.goto(
`${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
);
// ("ingests logs via API", () => {
const orgId = process.env["ORGNAME"];
const streamName = "e2e_automate";
const basicAuthCredentials = Buffer.from(
`${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
).toString("base64");
const headers = {
Authorization: `Basic ${basicAuthCredentials}`,
"Content-Type": "application/json",
};
// const logsdata = {}; // Fill this with your actual data
const fetchResponse = await fetch(
`${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`,
{
method: "POST",
headers: headers,
body: JSON.stringify(logsdata),
}
);
const response = await fetchResponse.json();
await orgNavigation;
// Making a POST request using fetch API
// const response = await page.evaluate(
// async ({ url, headers, orgId, streamName, logsdata }) => {
// const fetchResponse = await fetch(
// `${url}/api/${orgId}/${streamName}/_json`,
// {
// method: "POST",
// headers: headers,
// body: JSON.stringify(logsdata),
// }
// );
// return await fetchResponse.json();
// },
// {
// url: process.env.INGESTION_URL,
// headers: headers,
// orgId: orgId,
// streamName: streamName,
// logsdata: logsdata,
// }
// );
console.log(response);
// });
// const allorgs = page.waitForResponse("**/api/default/organizations**");
// const functions = page.waitForResponse("**/api/default/functions**");
// await page.goto(
// `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
// );
// const allsearch = page.waitForResponse("**/api/default/_search**");
// await selectStreamAndStreamTypeForLogs(page, logData.Stream);
// await applyQueryButton(page);
// const streams = page.waitForResponse("**/api/default/streams**");
});
test.beforeEach(async ({ page }) => {
try {
await login(page);
// just to make sure org is set
const orgNavigation = page.goto(
`${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
);
// ("ingests logs via API", () => {
const orgId = process.env["ORGNAME"];
const streamName = "e2e_automate";
const basicAuthCredentials = Buffer.from(
`${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
).toString("base64");
const headers = {
Authorization: `Basic ${basicAuthCredentials}`,
"Content-Type": "application/json",
};
// const logsdata = {}; // Fill this with your actual data
const fetchResponse = await fetch(
`${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`,
{
method: "POST",
headers: headers,
body: JSON.stringify(logsdata),
}
);
const response = await fetchResponse.json();
await orgNavigation;
// Making a POST request using fetch API
// const response = await page.evaluate(
// async ({ url, headers, orgId, streamName, logsdata }) => {
// const fetchResponse = await fetch(
// `${url}/api/${orgId}/${streamName}/_json`,
// {
// method: "POST",
// headers: headers,
// body: JSON.stringify(logsdata),
// }
// );
// return await fetchResponse.json();
// },
// {
// url: process.env.INGESTION_URL,
// headers: headers,
// orgId: orgId,
// streamName: streamName,
// logsdata: logsdata,
// }
// );
console.log(response);
// });
// const allorgs = page.waitForResponse("**/api/default/organizations**");
// const functions = page.waitForResponse("**/api/default/functions**");
// await page.goto(
// `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
// );
// const allsearch = page.waitForResponse("**/api/default/_search**");
// await selectStreamAndStreamTypeForLogs(page, logData.Stream);
// await applyQueryButton(page);
// const streams = page.waitForResponse("**/api/default/streams**");
} catch (error) {
console.error("Setup failed:", error);
}
});

Comment on lines +146 to +201
test("should display the VRL function in the field list after it has been written.", async ({
page,
}) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();

await page
.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]')
.click();
await page
.locator("label")
.filter({ hasText: "Streamarrow_drop_down" })
.locator("i")
.click();
await page.getByText("e2e_automate").click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubectl_kubernetes_io_default_container"] [data-test="dashboard-add-y-data"]'
)
.click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]'
)
.click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
// await page.getByText('arrow_rightQueryAutoPromQLCustom SQL').click();
await page
.locator('[data-test="logs-search-bar-show-query-toggle-btn"] img')
.click();

// await page.locator('#fnEditor > .monaco-editor > .overflow-guard > div:nth-child(2) > .lines-content > .view-lines').click();
await page
.locator('[data-test="dashboard-vrl-function-editor"]')
.getByLabel("Editor content;Press Alt+F1")
.fill(".vrl=123");
await page.waitForTimeout(3000);

await page.locator('[data-test="dashboard-apply"]').click();
const locator = page.locator(
'[data-test="field-list-item-logs-e2e_automate-vrl"]'
);

// Get the locator and ensure it is visible
await page
.locator('[data-test="field-list-item-logs-e2e_automate-vrl"]')
.waitFor({ state: "visible" });
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(3000);
+  await page.waitForSelector('[data-test="dashboard-apply"]');
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("should display the VRL function in the field list after it has been written.", async ({
page,
}) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page
.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]')
.click();
await page
.locator("label")
.filter({ hasText: "Streamarrow_drop_down" })
.locator("i")
.click();
await page.getByText("e2e_automate").click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubectl_kubernetes_io_default_container"] [data-test="dashboard-add-y-data"]'
)
.click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]'
)
.click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
// await page.getByText('arrow_rightQueryAutoPromQLCustom SQL').click();
await page
.locator('[data-test="logs-search-bar-show-query-toggle-btn"] img')
.click();
// await page.locator('#fnEditor > .monaco-editor > .overflow-guard > div:nth-child(2) > .lines-content > .view-lines').click();
await page
.locator('[data-test="dashboard-vrl-function-editor"]')
.getByLabel("Editor content;Press Alt+F1")
.fill(".vrl=123");
await page.waitForTimeout(3000);
await page.locator('[data-test="dashboard-apply"]').click();
const locator = page.locator(
'[data-test="field-list-item-logs-e2e_automate-vrl"]'
);
// Get the locator and ensure it is visible
await page
.locator('[data-test="field-list-item-logs-e2e_automate-vrl"]')
.waitFor({ state: "visible" });
});
test("should display the VRL function in the field list after it has been written.", async ({
page,
}) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await page
.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]')
.click();
await page
.locator("label")
.filter({ hasText: "Streamarrow_drop_down" })
.locator("i")
.click();
await page.getByText("e2e_automate").click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubectl_kubernetes_io_default_container"] [data-test="dashboard-add-y-data"]'
)
.click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_annotations_kubernetes_io_psp"] [data-test="dashboard-add-b-data"]'
)
.click();
await page.locator('[data-test="date-time-btn"]').click();
await page.locator('[data-test="date-time-relative-6-w-btn"]').click();
await page.locator('[data-test="dashboard-apply"]').click();
// await page.getByText('arrow_rightQueryAutoPromQLCustom SQL').click();
await page
.locator('[data-test="logs-search-bar-show-query-toggle-btn"] img')
.click();
// await page.locator('#fnEditor > .monaco-editor > .overflow-guard > div:nth-child(2) > .lines-content > .view-lines').click();
await page
.locator('[data-test="dashboard-vrl-function-editor"]')
.getByLabel("Editor content;Press Alt+F1")
.fill(".vrl=123");
await page.waitForSelector('[data-test="dashboard-apply"]');
await page.locator('[data-test="dashboard-apply"]').click();
const locator = page.locator(
'[data-test="field-list-item-logs-e2e_automate-vrl"]'
);
// Get the locator and ensure it is visible
await page
.locator('[data-test="field-list-item-logs-e2e_automate-vrl"]')
.waitFor({ state: "visible" });
});

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 49

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between af91bad and 109d4d3.

Files selected for processing (4)
  • .github/workflows/playwright.yml (1 hunks)
  • tests/ui-testing/playwright-tests/dashboard.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/visualize.spec.js (1 hunks)
  • tests/ui-testing/playwright-tests/vrl.spec.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/playwright.yml
Additional context used
Path-based instructions (3)
tests/ui-testing/playwright-tests/visualize.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/vrl.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

tests/ui-testing/playwright-tests/dashboard.spec.js (1)

Pattern **/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Biome
tests/ui-testing/playwright-tests/visualize.spec.js

[error] 39-39: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/vrl.spec.js

[error] 56-56: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

tests/ui-testing/playwright-tests/dashboard.spec.js

[error] 55-55: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Additional comments not posted (2)
tests/ui-testing/playwright-tests/dashboard.spec.js (1)

1-3: Optimize imports.

Consider consolidating the imports from the same module.

- import logData from "../../ui-testing/cypress/fixtures/log.json";
- import logsdata from "../../test-data/logs_data.json";
+ import logData from "../../ui-testing/cypress/fixtures/log.json";
+ import logsdata from "../../test-data/logs_data.json";

Likely invalid or redundant comment.

tests/ui-testing/playwright-tests/visualize.spec.js (1)

245-245: Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(2000);
+  await page.waitForSelector('[data-test="logs-search-bar-refresh-btn"]');

Likely invalid or redundant comment.

Comment on lines +76 to +144
test.beforeEach(async ({ page }) => {
console.log("running before each");
await login(page);

// just to make sure org is set
const orgNavigation = page.goto(
`${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
);

// ("ingests logs via API", () => {
const orgId = process.env["ORGNAME"];
const streamName = "e2e_automate";
const basicAuthCredentials = Buffer.from(
`${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
).toString("base64");

const headers = {
Authorization: `Basic ${basicAuthCredentials}`,
"Content-Type": "application/json",
};

// const logsdata = {}; // Fill this with your actual data

const fetchResponse = await fetch(
`${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`,
{
method: "POST",
headers: headers,
body: JSON.stringify(logsdata),
}
);
const response = await fetchResponse.json();

await orgNavigation;

// Making a POST request using fetch API
// const response = await page.evaluate(
// async ({ url, headers, orgId, streamName, logsdata }) => {
// const fetchResponse = await fetch(
// `${url}/api/${orgId}/${streamName}/_json`,
// {
// method: "POST",
// headers: headers,
// body: JSON.stringify(logsdata),
// }
// );
// return await fetchResponse.json();
// },
// {
// url: process.env.INGESTION_URL,
// headers: headers,
// orgId: orgId,
// streamName: streamName,
// logsdata: logsdata,
// }
// );

console.log(response);
// });
// const allorgs = page.waitForResponse("**/api/default/organizations**");
// const functions = page.waitForResponse("**/api/default/functions**");
// await page.goto(
// `${logData.logsUrl}?org_identifier=${process.env["ORGNAME"]}`
// );
// const allsearch = page.waitForResponse("**/api/default/_search**");
// await selectStreamAndStreamTypeForLogs(page, logData.Stream);
// await applyQueryButton(page);
// const streams = page.waitForResponse("**/api/default/streams**");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented-out code.

The commented-out code in the test.beforeEach block should be removed to improve readability.

- // let logData;
- // tebefore(async function () {
- //   // logData("log");
- //   // const data = page;
- //   // logData = data;
- //   // console.log("--logData--", logData);
- // });

Committable suggestion was skipped due to low confidence.

Comment on lines +1724 to +1765
test("should redirect to the list of dashboard pages when discarding changes", async ({
page,
}) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();

await page
.locator('[data-test="dashboard-if-no-panel-add-panel-btn"]')
.click();
await page
.locator("label")
.filter({ hasText: "Streamarrow_drop_down" })
.locator("i")
.click();
await page.getByText("e2e_automate").click();

await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_container_image"] [data-test="dashboard-add-b-data"]'
)
.click();
await page
.locator(
'[data-test="field-list-item-logs-e2e_automate-kubernetes_docker_id"] [data-test="dashboard-add-y-data"]'
)
.click();
await page.locator('[data-test="dashboard-apply"]').click();

page.once("dialog", (dialog) => {
console.log(`Dialog message: ${dialog.message()}`);
dialog.dismiss().catch(() => {});
});
await page.locator('[data-test="dashboard-panel-discard"]').click();

// await expect(page.getByText('Start by adding your first')).toBeVisible();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Add assertion to verify redirection after discarding changes.

Consider adding an assertion to verify that the user was redirected to the list of dashboard pages after discarding changes.

+ await expect(page.getByText("Redirected to dashboard list successfully.")).toBeVisible({ timeout: 30000 });

Committable suggestion was skipped due to low confidence.

Comment on lines +50 to +56
test.describe("dashboard UI testcases", () => {
// let logData;
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the regular expression to avoid control characters.

The regular expression contains control characters, which can be problematic.

- return text.replace(/[^\x00-\x7F]/g, " ");
+ return text.replace(/[^\u0000-\u007F]/g, " ");
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test.describe("dashboard UI testcases", () => {
// let logData;
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
}
test.describe("dashboard UI testcases", () => {
// let logData;
function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\u0000-\u007F]/g, " ");
}
Tools
Biome

[error] 55-55: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

Comment on lines +146 to +158
test("should create a new dashboar", async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText("Dashboard added successfully.")).toBeVisible({
timeout: 30000,
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix typo in test name.

The test name contains a typo ("dashboar" instead of "dashboard").

- test("should create a new dashboar", async ({ page }) => {
+ test("should create a new dashboard", async ({ page }) => {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("should create a new dashboar", async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText("Dashboard added successfully.")).toBeVisible({
timeout: 30000,
});
});
test("should create a new dashboard", async ({ page }) => {
await page.locator('[data-test="menu-link-\\/dashboards-item"]').click();
await waitForDashboardPage(page);
await page.locator('[data-test="dashboard-add"]').click();
await page.locator('[data-test="add-dashboard-name"]').click();
await page
.locator('[data-test="add-dashboard-name"]')
.fill(randomDashboardName);
await page.locator('[data-test="dashboard-add-submit"]').click();
await expect(page.getByText("Dashboard added successfully.")).toBeVisible({
timeout: 30000,
});
});

Comment on lines +35 to +48
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);

await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");

await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance waitForDashboardPage function with error handling.

The waitForDashboardPage function lacks error handling. Consider adding try-catch blocks to handle potential errors during the waiting process.

+ async function waitForDashboardPage(page) {
+   try {
      const dashboardListApi = page.waitForResponse((response) => /\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200);
      await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
      await page.waitForSelector(`text="Please wait while loading dashboards..."`, { state: "hidden" });
      await dashboardListApi;
      await page.waitForTimeout(500);
+   } catch (error) {
+     console.error("Waiting for dashboard page failed:", error);
+   }
+ }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function waitForDashboardPage(page) {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
}
async function waitForDashboardPage(page) {
try {
const dashboardListApi = page.waitForResponse(
(response) =>
/\/api\/.+\/dashboards/.test(response.url()) && response.status() === 200
);
await page.waitForURL(process.env["ZO_BASE_URL"] + "/web/dashboards**");
await page.waitForSelector(`text="Please wait while loading dashboards..."`, {
state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
} catch (error) {
console.error("Waiting for dashboard page failed:", error);
}
}

.fill(
".percentage , err=.histogram *.kubernetes_annotations_kubectl_kubernetes_io_default_container/ 100"
);
await page.waitForTimeout(3000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(3000);
+  await page.waitForSelector('[data-test="dashboard-apply"]');
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await page.waitForTimeout(3000);
await page.waitForSelector('[data-test="dashboard-apply"]');

function removeUTFCharacters(text) {
// console.log(text, "tex");
// Remove UTF characters using regular expression
return text.replace(/[^\x00-\x7F]/g, " ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix regular expression to remove unexpected control character.

The regular expression contains an unexpected control character and should be corrected.

-  return text.replace(/[^\x00-\x7F]/g, " ");
+  return text.replace(/[^\x20-\x7E]/g, " ");
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return text.replace(/[^\x00-\x7F]/g, " ");
return text.replace(/[^\x20-\x7E]/g, " ");
Tools
Biome

[error] 56-56: Unexpected control character(s) in regular expression: \x00

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

state: "hidden",
});
await dashboardListApi;
await page.waitForTimeout(500);
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(500);
+  await page.waitForSelector('text="Please wait while loading dashboards..."', { state: "hidden" });
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await page.waitForTimeout(500);
await page.waitForSelector('text="Please wait while loading dashboards..."', { state: "hidden" });

// click on the run query button
// Type the value of a variable into an input field
const search = page.waitForResponse(logData.applyQuery);
await page.waitForTimeout(3000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(3000);
+  await page.waitForSelector("[data-test='logs-search-bar-refresh-btn']");
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await page.waitForTimeout(3000);
await page.waitForSelector("[data-test='logs-search-bar-refresh-btn']");


//await page.locator('[data-test="dashboard-vrl-function-editor"]').getByLabel('Editor content;Press Alt+F1').fill('.percenteage1 ,err = .kubernetes_annotations_kubectl_kubernetes_io_default_container * .kubernetes_container_hash / 100\ .percenteage2 ,err = .kubernetes_annotations_kubectl_kubernetes_io_default_container / .kubernetes_container_hash * 100 \n');

await page.waitForTimeout(2000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace hardcoded timeout with element-specific wait.

Hardcoded timeouts can lead to flaky tests. Use element-specific waits for better reliability.

-  await page.waitForTimeout(2000);
+  await page.waitForSelector('[data-test="dashboard-apply"]');
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await page.waitForTimeout(2000);
await page.waitForSelector('[data-test="dashboard-apply"]');

@ktx-akshay ktx-akshay merged commit 355591c into main Aug 5, 2024
@ktx-akshay ktx-akshay deleted the test/dasboard/visulization branch August 5, 2024 08:56
abvarun226 pushed a commit to abvarun226/openobserve that referenced this pull request Aug 8, 2024
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Expanded automated testing coverage by adding new UI test files for
dashboard management and logging visualization functionalities.
- Enhanced dashboard UI tests now cover creating, modifying,
duplicating, and applying filters to dashboards.
- Introduced tests for verifying user interactions with logging
visualizations, including error handling and data persistence.
- Added tests for Virtual Reference Language (VRL) features within the
dashboard, validating function applications and error handling.

- **Bug Fixes**
- Improved error handling in UI tests to ensure that invalid inputs
trigger appropriate error messages.

- **Tests**
- Comprehensive test cases implemented for various user interactions
across new features, ensuring functionality works as intended.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

4 participants