Skip to content

fix: Unit test fix#36471

Merged
sondermanish merged 2 commits intoreleasefrom
fix/import-unit-test
Sep 23, 2024
Merged

fix: Unit test fix#36471
sondermanish merged 2 commits intoreleasefrom
fix/import-unit-test

Conversation

@sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Sep 23, 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 #Issue Number
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.ImportExport"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10988998437
Commit: f59a368
Cypress dashboard.
Tags: @tag.ImportExport
Spec:


Mon, 23 Sep 2024 07:01:17 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes
    • Updated error message for clarity when importing an invalid JSON file, ensuring consistent phrasing and capitalization.
    • Introduced a standardized error message constant for improved maintainability.

@sondermanish sondermanish requested a review from a team as a code owner September 23, 2024 05:46
@sondermanish sondermanish self-assigned this Sep 23, 2024
@github-actions github-actions bot added the Bug Something isn't working label Sep 23, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes encompass a refinement of error messages across multiple files related to JSON imports. Specifically, the phrasing in the ImportServiceTests.java file has been updated for clarity, correcting "Seems like" to "It seems" and ensuring "JSON" is capitalized. Additionally, a new class, ImportExportConstants, has been introduced to standardize error messages, which are now consistently referenced in the error handling logic of the ImportServiceCEImpl class.

Changes

File Path Change Summary
app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java Updated the error message in importArtifactFromInvalidJsonFileWithoutArtifactTest for clarity.
app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ImportExportConstants.java Introduced ImportExportConstants class with a constant for error messages related to JSON imports.
app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java Modified error handling in importArtifactInWorkspace to use the new constant for consistency.

Possibly related PRs

Suggested labels

Task, ok-to-test

Suggested reviewers

  • sharat87
  • mohanarpit

Poem

In the realm of code where messages dwell,
A tweak was made, and all is well.
"It seems" now speaks with clarity bright,
JSON stands proud, a glorious sight!
Constants unite, making errors less grim,
A small change indeed, but a victory for him! 🌈


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>, please review it.
    -- 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@sondermanish
Copy link
Contributor Author

This doesn't require ci testing as there is only the test file that is being changed.

@github-actions
Copy link

Failed server tests

  • com.external.plugins.RestApiPluginTest#testDenyInstanceMetadataAwsViaCname
  • com.external.plugins.RestApiPluginTest#testDenyInstanceMetadataAwsWithRedirect

abhvsn
abhvsn previously approved these changes Sep 23, 2024
@sondermanish
Copy link
Contributor Author

sondermanish commented Sep 23, 2024

Unit test for which this test was written passes locally
image

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: 1

Outside diff range and nitpick comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ImportExportConstants.java (1)

3-3: Well done on the class declaration, but let's add some documentation!

The class name ImportExportConstants is descriptive and follows Java naming conventions. Good job! However, to help your classmates understand the purpose of this class better, let's add a Javadoc comment. Here's an example:

/**
 * This class contains constants related to import and export operations in the application.
 */
public class ImportExportConstants {
    // ... existing code ...
}

Remember, clear documentation helps everyone in the class understand your code better!

app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (1)

425-428: Very good, class! Let's discuss this improvement.

I'm pleased to see you've made your code more maintainable by using a constant for the error message. This is a step in the right direction! However, I have a small suggestion to make it even better.

Consider extracting the entire error message construction into a separate method in the ImportExportConstants class. This would further improve readability and maintainability. Here's an example:

-return Mono.error(new AppsmithException(
-        AppsmithError.VALIDATION_FAILURE,
-        "Field '" + artifactContextString
-                + ImportExportConstants.ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE));
+return Mono.error(new AppsmithException(
+        AppsmithError.VALIDATION_FAILURE,
+        ImportExportConstants.getArtifactJsonImportValidationErrorMessage(artifactContextString)));

Then in ImportExportConstants:

public static String getArtifactJsonImportValidationErrorMessage(String artifactContextString) {
    return "Field '" + artifactContextString + ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE;
}

This approach would centralize the error message construction and make it easier to modify in the future. Keep up the good work!

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e5472f0 and f59a368.

Files selected for processing (3)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ImportExportConstants.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java
Additional comments not posted (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ImportExportConstants.java (1)

1-1: Very good, class! The package declaration is correct.

The package name com.appsmith.server.constants follows proper Java naming conventions and is appropriately placed in the server constants package. Keep up the good work!

app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (1)

Line range hint 1-724: Class, let's do a quick pop quiz!

Now that we've made this change, it's important to verify that it doesn't affect other parts of our code. Can anyone tell me how we might do that?

Let's run a quick check to make sure we haven't missed any other occurrences of this error message construction:

This will help us ensure consistency across our codebase. Remember, consistency is key in writing clean, maintainable code!

@sondermanish sondermanish requested a review from abhvsn September 23, 2024 06:47
@sondermanish sondermanish enabled auto-merge (squash) September 23, 2024 06:48
@sondermanish sondermanish merged commit 44f1486 into release Sep 23, 2024
@sondermanish sondermanish deleted the fix/import-unit-test branch September 23, 2024 07:10
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 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 #`Issue Number`  
_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.ImportExport"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/10988998437>
> Commit: f59a368
> Workflow: `PR Automation test suite`
> Tags: `@tag.ImportExport`
> Spec: ``
> <hr>Mon, 23 Sep 2024 06:43:22 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Updated error message for clarity when importing an invalid JSON file,
ensuring consistent phrasing and capitalization.
- Introduced a standardized error message constant for improved
maintainability.
<!-- 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

Labels

Bug Something isn't working ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants