Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Query params missing in edit mode #34719

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Jul 4, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #34705
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9792639146
Commit: eb7a57a
Cypress dashboard.
Tags: @tag.All
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/PartialImportExport/PartialExport_spec.ts
  2. cypress/e2e/Regression/ServerSide/QueryPane/Mongo_Spec.js
List of identified flaky tests.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 Configration 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.

@github-actions github-actions bot added Bug Something isn't working IDE Navigation Issues/feature requests related to IDE navigation, and context switching Low An issue that is neither critical nor breaks a user flow New Developers Pod Issues that new developers face while exploring the IDE Production labels Jul 4, 2024
@hetunandu hetunandu added the ok-to-test Required label for CI label Jul 4, 2024
@ApekshaBhosale
Copy link
Contributor

@coderabbitai configuration

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

CodeRabbit configuration
language: en-US
tone_instructions: ''
early_access: false
enable_free_tier: true
reviews:
  profile: chill
  request_changes_workflow: false
  high_level_summary: true
  high_level_summary_placeholder: '@coderabbitai summary'
  auto_title_placeholder: '@coderabbitai'
  poem: true
  review_status: true
  collapse_walkthrough: false
  path_filters: []
  path_instructions:
    - path: app/client/cypress/**/**.*
      instructions: >-
        Follow best practices for Cypress code and e2e automation. 

        Avoid using cy.wait in code.

        Avoid using cy.pause in code.

        Use variables for locators, not strings.

        Use `data-*` attributes for selectors; avoid Xpaths and CSS attributes.

        Avoid selectors like `.btn.submit` or `button[type=submit]`.

        Perform logins via API with `LoginFromAPI`.

        Only interact with controlled sites/servers.

        Ensure tests can run with `it.only` and are independent.

        Use `before`, `beforeEach`, `after`, `afterEach` correctly; clean state
        before tests.

        Check new specs for flakiness by running them 10 times on CI.

        Use multiple assertions; don't treat Cypress as unit tests.

        Use constants for strings.

        Include datasource operations in `before` hooks.
  abort_on_close: true
  auto_review:
    enabled: true
    auto_incremental_review: true
    ignore_title_keywords: []
    labels: []
    drafts: false
    base_branches: []
  tools:
    shellcheck:
      enabled: true
    ruff:
      enabled: true
    markdownlint:
      enabled: true
    github-checks:
      enabled: true
      timeout_ms: 90000
    languagetool:
      enabled: true
      disabled_rules:
        - EN_UNPAIRED_BRACKETS
        - EN_UNPAIRED_QUOTES
      disabled_categories:
        - TYPOS
        - TYPOGRAPHY
        - CASING
      enabled_only: false
      level: default
      enabled_rules: []
      enabled_categories: []
    biome:
      enabled: true
    hadolint:
      enabled: true
    swiftlint:
      enabled: true
    phpstan:
      enabled: true
      level: default
    golangci-lint:
      enabled: true
    yamllint:
      enabled: true
    gitleaks:
      enabled: true
    checkov:
      enabled: true
    ast-grep:
      packages: []
      rule_dirs: []
      util_dirs: []
      essential_rules: true
chat:
  auto_reply: true
knowledge_base:
  learnings:
    scope: auto
  issues:
    scope: auto
  jira:
    project_keys: []
  linear:
    team_keys: []

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Tip

For best results, initiate chat on the files or code changes.

Unit Tests for URLBuilder Class

import URLBuilder, { URLBuilderParams, URL_TYPE, baseURLRegistry } from "app/client/src/ce/entities/URLRedirect/URLAssembly";
import { APP_MODE } from "entities/App";
import { ApplicationVersion } from "@appsmith/actions/applicationActions";
import getQueryParamsObject from "utils/getQueryParamsObject";

jest.mock("utils/getQueryParamsObject");

describe("URLBuilder", () => {
  let urlBuilder: URLBuilder;

  beforeEach(() => {
    urlBuilder = URLBuilder.getInstance();
    urlBuilder.resetURLParams();
  });

  it("should build URL with query parameters", () => {
    const builderParams: URLBuilderParams = {
      pageId: "pageId123",
      params: { foo: "bar" },
    };
    const mode = APP_MODE.EDIT;

    const expectedUrl = "/app/pageId123-?foo=bar";

    const result = urlBuilder.build(builderParams, mode);

    expect(result).toContain("?foo=bar");
  });

  it("should persist existing query parameters if specified", () => {
    (getQueryParamsObject as jest.Mock).mockReturnValue({ existing: "param" });

    const builderParams: URLBuilderParams = {
      pageId: "pageId123",
      persistExistingParams: true,
    };
    const mode = APP_MODE.EDIT;

    const result = urlBuilder.build(builderParams, mode);

    expect(result).toContain("?existing=param");
  });

  it("should not persist existing query parameters if not specified", () => {
    (getQueryParamsObject as jest.Mock).mockReturnValue({ existing: "param" });

    const builderParams: URLBuilderParams = {
      pageId: "pageId123",
      persistExistingParams: false,
    };
    const mode = APP_MODE.EDIT;

    const result = urlBuilder.build(builderParams, mode);

    expect(result).not.toContain("existing=param");
  });

  it("should include branch parameter if specified", () => {
    const builderParams: URLBuilderParams = {
      pageId: "pageId123",
      branch: "feature-branch",
    };
    const mode = APP_MODE.EDIT;

    const result = urlBuilder.build(builderParams, mode);

    expect(result).toContain("branch=feature-branch");
  });

  it("should handle hash and suffix in the URL", () => {
    const builderParams: URLBuilderParams = {
      pageId: "pageId123",
      hash: "section",
      suffix: "details",
    };
    const mode = APP_MODE.EDIT;

    const result = urlBuilder.build(builderParams, mode);

    expect(result).toContain("#section");
    expect(result).toContain("/details");
  });
});

@ApekshaBhosale, I've generated unit tests for the URLBuilder class focusing on the build method to ensure query parameters are correctly included in the URLs. These tests cover various scenarios such as persisting existing query parameters, including branch parameters, and handling hash and suffix in the URL.

Would you like me to proceed with any additional tests or modifications?

Analysis chain



Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# List the files modified in the PR to identify where the changes were made.
git diff --name-only origin/master

Length of output: 230


Script:

#!/bin/bash
# Identify the base branch of the PR.
BASE_BRANCH=$(git rev-parse --abbrev-ref HEAD~1)

# List the files modified in the PR by comparing against the base branch.
git diff --name-only $BASE_BRANCH

Length of output: 74


Script:

#!/bin/bash
# Find the common ancestor between the current branch and origin/master.
BASE_COMMIT=$(git merge-base HEAD origin/master)

# List the files modified in the PR by comparing against the common ancestor.
git diff --name-only $BASE_COMMIT

Length of output: 119


Script:

#!/bin/bash
# Find the last commit hash on the current branch.
LAST_COMMIT=$(git rev-parse HEAD)

# List the files modified in the last commit.
git diff-tree --no-commit-id --name-only -r $LAST_COMMIT

Length of output: 217


Script:

#!/bin/bash
# Display the contents of the modified file to understand the changes.
cat app/client/src/ce/entities/URLRedirect/URLAssembly.ts

Length of output: 8879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working IDE Navigation Issues/feature requests related to IDE navigation, and context switching Low An issue that is neither critical nor breaks a user flow New Developers Pod Issues that new developers face while exploring the IDE ok-to-test Required label for CI Production
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Query Parameters set using navigateTo get lost when clicking around
2 participants