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: picking settingsConfig from ApiEditorContext instead of props #37758

Open
wants to merge 8 commits into
base: release
Choose a base branch
from

Conversation

AmanAgarwal041
Copy link
Contributor

@AmanAgarwal041 AmanAgarwal041 commented Nov 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.All"

🔍 Cypress test results

Warning

Tests have not run on the HEAD 0b396fc yet


Wed, 27 Nov 2024 19:04:45 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced the CommonEditorForm component to accept settingsConfig directly from props for improved data management.
    • Introduced logging mechanisms in the CommonEditorForm, ActionSettings, ApiEditorContextProvider, and ApiEditorWrapper components to aid debugging during tests.
    • Added conditional logging in the fetchPluginFormConfigsSaga for better visibility during Cypress testing.
    • Updated test specifications in the Cypress limited tests to include new entries for "Abort Action" and "API MultiPart."
  • Refactor

    • Updated the way settingsConfig is accessed, removing it from context in favor of prop-based sourcing.

@AmanAgarwal041 AmanAgarwal041 added the ok-to-test Required label for CI label Nov 26, 2024
Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The changes in this pull request involve modifications to the CommonEditorForm component within the CommonEditorForm.tsx file. The primary adjustment is the extraction of the settingsConfig property from props instead of accessing it via context. This shift alters how settingsConfig is managed, ensuring it is sourced directly from the props, while also removing it from the context destructuring. Additionally, logging mechanisms are introduced in various components for debugging during testing. No other changes to logic or error handling are present.

Changes

File Path Change Summary
app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx - Added settingsConfig property to CommonFormPropsWithExtraParams.
- Removed settingsConfig from context destructuring.
- Introduced conditional logging for settingsConfig.
app/client/src/pages/Editor/ActionSettings.tsx - Added conditional logging for actionSettingsConfig when running with Cypress.
app/client/src/pages/Editor/APIEditor/ApiEditorContext.tsx - Introduced conditional logging for settingsConfig in the context provider when using Cypress.
app/client/src/pages/Editor/APIEditor/index.tsx - Added conditional logging for settingsConfig and pluginId in the wrapper component when using Cypress.
app/client/src/sagas/PluginSagas.ts - Enhanced logging in fetchPluginFormConfigsSaga for plugin form data when using Cypress.
app/client/cypress/limited-tests.txt - Updated test specifications: replaced Fork_Template_spec.js with AbortAction_Spec.ts and added API_MultiPart_Spec.ts.

Possibly related PRs

Suggested labels

Task, ok-to-test, Query & JS Pod, IDE Product, IDE Pod

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • albinAppsmith

🎉 In the realm of code, a change so bright,
settingsConfig now shines in the light.
From context it came, now props take the stage,
A shift in the flow, a new coding page.
With clarity gained, the structure is neat,
In the world of components, this change is a treat! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 12a2736 and 0b396fc.

📒 Files selected for processing (1)
  • app/client/src/pages/Editor/APIEditor/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/Editor/APIEditor/index.tsx

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.

@github-actions github-actions bot added the Bug Something isn't working label Nov 26, 2024
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

🧹 Outside diff range and nitpick comments (2)
app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (2)

Line range hint 113-113: Consider adding proper TypeScript types for settingsConfig

The any type reduces type safety. Consider defining an interface for the settings configuration object.

- settingsConfig: any;
+ interface SettingsConfig {
+   // Define the expected shape of your settings
+   // Example:
+   // showPagination?: boolean;
+   // enableCaching?: boolean;
+ }
+ settingsConfig: SettingsConfig;

Line range hint 365-365: Consider using consistent prop naming

The prop name changes from settingsConfig to actionSettingsConfig when passed to RequestTabs. Consider using consistent naming to improve maintainability.

- actionSettingsConfig={settingsConfig}
+ settingsConfig={settingsConfig}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f41cf12 and fa10866.

📒 Files selected for processing (1)
  • app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (1 hunks)
🔇 Additional comments (2)
app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (2)

184-184: LGTM: Correctly moved settingsConfig from context to props

The change aligns with the PR objective of picking settingsConfig from props instead of context.


Line range hint 113-113: Verify all CommonEditorForm usages are updated

This change requires all components using CommonEditorForm to pass settingsConfig as a prop instead of relying on context.

Also applies to: 184-184

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit

Copy link

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

🧹 Outside diff range and nitpick comments (2)
app/client/src/pages/Editor/ActionSettings.tsx (2)

44-51: Consider structuring the Cypress log for better debugging

The logging implementation is correct but could be more structured for debugging purposes.

   /* @ts-expect-error: Types are not available */
   if (typeof window.Cypress?.log === "function") {
     /* @ts-expect-error: Types are not available */
     window.Cypress.log(
-      "props.actionSettingsConfig",
-      props.actionSettingsConfig,
+      {
+        name: 'ActionSettings',
+        message: 'Rendering with config',
+        consoleProps: () => ({
+          actionSettingsConfig: props.actionSettingsConfig
+        })
+      }
     );
   }

Line range hint 9-14: Technical Debt: Consider addressing the TODO comments and any types

There are multiple TODOs and any type usages that should be properly typed to improve type safety.

Consider creating proper interfaces for:

  1. actionSettingsConfig structure
  2. The section and control configuration objects

This will improve type safety and reduce the need for eslint-disable directives.

Also applies to: 65-66

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fa10866 and 76f4cf1.

📒 Files selected for processing (3)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx (2 hunks)
  • app/client/src/pages/Editor/ActionSettings.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/limited-tests.txt (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (2)
app/client/cypress/limited-tests.txt (1)

2-3: LGTM! Verifying test file paths.

The test specifications follow proper naming conventions and are correctly organized under their respective test categories.

Let's verify the existence of these test files:

✅ Verification successful

Test files exist at the specified paths

Both test files are present in their respective directories:

  • app/client/cypress/e2e/Regression/ClientSide/BugTests/AbortAction_Spec.ts
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the specified test files exist in the correct locations

# Check if the test files exist
fd "AbortAction_Spec.ts|API_MultiPart_Spec.ts" --type f

Length of output: 207

app/client/src/pages/Editor/ActionSettings.tsx (1)

Line range hint 9-14: Verify implementation against PR objectives

The PR description mentions moving settingsConfig from props to context, but this file still receives configuration via props. Please clarify if this is intentional or if additional changes are needed.

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12046542345.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit

Copy link

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit-count run_count=5 runId=12046542345

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12047228995.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12047325773.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

***** Repeat Run Summary ***** Total Tests with repeat: 45 Total Passed: 44 Total Failed: 1 Total Skipped: 0 *****************************

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit-count run_count=5 runId=12047325773

Copy link

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 (3)
app/client/src/pages/Editor/APIEditor/ApiEditorContext.tsx (3)

Line range hint 7-12: Address the TODO comment in the interface.

The TODO comment indicates that the any type needs to be fixed. Consider defining a proper type for settingsConfig to improve type safety.

Would you like me to help define a proper type for the settingsConfig property?


62-68: Consider improving the TypeScript integration with Cypress.

Instead of suppressing TypeScript errors, consider:

  1. Installing proper Cypress types (@types/cypress)
  2. Using proper type guards for the Cypress check

Here's a more type-safe approach:

- /* @ts-expect-error: Types are not available */
- if (typeof window.Cypress?.log === "function") {
-   /* @ts-expect-error: Types are not available */
-   window.Cypress.log({
+ if (window.Cypress && typeof window.Cypress.log === 'function') {
+   window.Cypress.log({

Also, consider extracting the debug message to a constant for better readability:

const debugMessage = `ApiEditorContextProvider, ${JSON.stringify(settingsConfig || {})} ${JSON.stringify(value.settingsConfig || {})}`;
window.Cypress.log({ message: debugMessage });

66-66: Improve the debug message format.

The current debug message format makes it difficult to distinguish between the two config objects. Consider using a more structured format.

- message: `ApiEditorContextProvider, ${JSON.stringify(settingsConfig || {})} ${JSON.stringify(value.settingsConfig || {})}`,
+ message: `ApiEditorContextProvider | Props config: ${JSON.stringify(settingsConfig || {})} | Context config: ${JSON.stringify(value.settingsConfig || {})}`,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 91523c7 and 12a2736.

📒 Files selected for processing (3)
  • app/client/src/pages/Editor/APIEditor/ApiEditorContext.tsx (1 hunks)
  • app/client/src/pages/Editor/APIEditor/index.tsx (1 hunks)
  • app/client/src/sagas/PluginSagas.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/APIEditor/index.tsx
🔇 Additional comments (1)
app/client/src/sagas/PluginSagas.ts (1)

186-196: Verify consistent logging across related components.

Since this PR involves moving settingsConfig from props to ApiEditorContext, ensure logging is consistently implemented across all affected components.

✅ Verification successful

Cypress logging is consistently implemented across API editor components

The logging implementation for settings is already consistent across the related components:

  • PluginSagas.ts: Logs plugin form settings
  • ActionSettings.tsx: Logs action settings config
  • APIEditor/index.tsx: Logs settings config with plugin ID
  • APIEditor/CommonEditorForm.tsx: Logs both context and props settings
  • APIEditor/ApiEditorContext.tsx: Logs provider settings
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar Cypress logging implementations in related files
rg -l "window\.Cypress.*log.*setting" --type ts

Length of output: 49


Script:

#!/bin/bash
# Let's broaden the search to find any Cypress logging in the codebase
rg "window\.Cypress.*log" --type ts -A 2

# Also search for any settings-related logging patterns
rg "log.*setting" --type ts -A 2

Length of output: 7013

Comment on lines +186 to +196
if (
/* @ts-expect-error: Types are not available */
typeof window.Cypress?.log === "function" &&
plugin?.type === PluginType.API
) {
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `fetchPluginFormConfigsSaga, ${JSON.stringify(pluginFormData[index].setting || {})} ${JSON.stringify(defaultActionSettings[plugin.type] || {})}`,
});
}

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider improving type safety and logging implementation.

The current implementation has several areas for improvement:

  1. Using @ts-expect-error is not ideal for handling Cypress types
  2. The logging implementation could be more structured

Consider these improvements:

+ // Add to a types file
+ interface CypressWindow extends Window {
+   Cypress?: {
+     log: (args: { message: string }) => void;
+   };
+ }

- /* @ts-expect-error: Types are not available */
- typeof window.Cypress?.log === "function"
+ typeof (window as CypressWindow).Cypress?.log === "function"

- /* @ts-expect-error: Types are not available */
- window.Cypress.log({
+ (window as CypressWindow).Cypress?.log({
-   message: `fetchPluginFormConfigsSaga, ${JSON.stringify(pluginFormData[index].setting || {})} ${JSON.stringify(defaultActionSettings[plugin.type] || {})}`,
+   message: `Plugin Settings:
+     Current: ${JSON.stringify(pluginFormData[index].setting || {})}
+     Default: ${JSON.stringify(defaultActionSettings[plugin.type] || {})}`
  });

Committable suggestion skipped: line range outside the PR's diff.

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit-count run_count=5 runId=12046542345

@AmanAgarwal041 AmanAgarwal041 removed the ok-to-test Required label for CI label Nov 27, 2024
Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12048371654.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 45 Total Passed: 45 Total Failed: 0 Total Skipped: 0 *****************************

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit-count run_count=5 runId=12046542345

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12049158548.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 45 Total Passed: 45 Total Failed: 0 Total Skipped: 0 *****************************

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12050373379.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit-count run_count=10 runId=12050373379

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12051047387.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

***** Repeat Run Summary ***** Total Tests with repeat: 90 Total Passed: 84 Total Failed: 6 Total Skipped: 0 *****************************

@AmanAgarwal041
Copy link
Contributor Author

/ci-test-limit-count run_count=10 runId=12050373379

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12056743023.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

***** Repeat Run Summary ***** Total Tests with repeat: 90 Total Passed: 86 Total Failed: 4 Total Skipped: 0 *****************************

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant