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

chore: flexible return for test payload extraction func #38443

Merged
merged 4 commits into from
Jan 2, 2025

Conversation

ayushpahwa
Copy link
Contributor

@ayushpahwa ayushpahwa commented Jan 1, 2025

Description

The getTestPayloadFromCollectionData extracts the testPayload from passed collectionData and returns an empty string if no information is present. This PR updates the function definition to allow different default value based on the function call.

Fixes #37742

Automation

/test sanity

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12572189037
Commit: 26ea6e2
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Wed, 01 Jan 2025 16:34:44 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced function handling for undefined collection data
    • Improved key iteration in action execution utilities
  • Documentation

    • Added JSDoc comment to clarify function behavior

Copy link
Contributor

coderabbitai bot commented Jan 1, 2025

Walkthrough

The pull request modifies the actionExecutionUtils.ts file, focusing on utility functions related to action execution. The changes include replacing Object.keys with a custom objectKeys utility function and updating the getTestPayloadFromCollectionData function to handle undefined scenarios more flexibly. A new optional defaultValue parameter is introduced, and a JSDoc comment is added to provide more clarity about the function's behavior.

Changes

File Change Summary
app/client/src/ce/utils/actionExecutionUtils.ts - Replaced Object.keys with objectKeys utility
- Updated getTestPayloadFromCollectionData to accept optional defaultValue
- Added JSDoc comment to function

Suggested Labels

Task, skip-changelog, ok-to-test

Suggested Reviewers

  • ApekshaBhosale
  • nidhi-nair

Poem

Code flows like water, smooth and bright
Utility functions dancing with might
Keys transformed, defaults now clear
Flexibility whispers, "No need to fear!" 🚀
Refactoring magic, pure delight! ✨


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@ayushpahwa ayushpahwa requested a review from dvj1988 January 1, 2025 15:52
@github-actions github-actions bot added Task A simple Todo Workflows Pod Issues that the workflows team owns Workflows Product Issues related to the workflows product labels Jan 1, 2025
@ayushpahwa ayushpahwa requested a review from ashit-rath January 1, 2025 15:52
@ayushpahwa ayushpahwa added the ok-to-test Required label for CI label Jan 1, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 1, 2025
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 463c119 and 26ea6e2.

📒 Files selected for processing (1)
  • app/client/src/ce/utils/actionExecutionUtils.ts (4 hunks)
🔇 Additional comments (7)
app/client/src/ce/utils/actionExecutionUtils.ts (7)

12-12: Good use of the custom utility function.

Using objectKeys from @appsmith/utils here is consistent and helps keep the codebase DRY.


24-24: Implementation looks good.

The refactor using objectKeys preserves logic and avoids enumerating unexpected props.


73-73: Consistent approach with the custom utility function.

Continuing to use objectKeys for params is a clear, uniform approach.


102-108: Nice documentation addition.

Thank you for clarifying the function's purpose and parameters in the JSDoc. This will help future maintainers.


111-111: Flexible default value.

Using a parameter default of an empty string is aligned with the function’s goal of handling undefined states gracefully.


113-113: Graceful fallback.

Correctly returning the defaultValue ensures that callers receive a defined result when collectionData is missing.


119-119: Edge case handled.

Returning defaultValue when activeJSActionId or testPayload is missing is consistent with the function’s contract.

export const getTestPayloadFromCollectionData = (
collectionData: JSCollectionData | undefined,
defaultValue = "",
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't quite understand the reasoning behind adding this. Basically we are passing a default value to a function which it will return when the collectionData is not there or something else is missing. Can't this function return null and the caller of this function can just do getTestPayloadFromCollectionData() || defaultValue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main use is in the EE side of this change. Empty string is treated as a falsy value and for my use case I want the default value to be used only if the item is undefined. While I could do that check during consumption of this functions, but since the check is already happening here I preferred to update the function definition.

@ayushpahwa ayushpahwa requested a review from ashit-rath January 2, 2025 06:30
@ayushpahwa ayushpahwa merged commit 0b3e188 into release Jan 2, 2025
49 checks passed
@ayushpahwa ayushpahwa deleted the chore/workflow-test-payload-update branch January 2, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo Workflows Pod Issues that the workflows team owns Workflows Product Issues related to the workflows product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Change default payload of test run
2 participants