-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: Refactor handling of empty chart data in ChartWidget #37009
Conversation
WalkthroughThe changes in this pull request enhance the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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/widgets/ChartWidget/widget/index.test.ts (1)
75-82
: LGTM. Consider adding an assertion for mixed data types.The new test case effectively covers scenarios where series data is null or undefined. Good job on improving the test coverage.
Consider adding an assertion for a mixed scenario where one series has valid data and another has null/undefined data. This would ensure the function behaves correctly in all possible combinations.
app/client/src/widgets/ChartWidget/widget/index.tsx (1)
54-57
: Approved: Robust check for empty chart data.The additional check for
props.chartData[seriesID].data
existence before accessing its length effectively addresses the TypeError issue. This change aligns well with the PR objectives.Consider using optional chaining for a more concise expression:
if (props.chartData[seriesID].data?.length > 0) { return false; }This achieves the same result with a slightly more compact syntax.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
- app/client/src/widgets/ChartWidget/widget/index.test.ts (1 hunks)
- app/client/src/widgets/ChartWidget/widget/index.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
app/client/src/widgets/ChartWidget/widget/index.tsx (1)
Line range hint
1-380
: Verify impact on chart rendering scenarios.The changes to
emptyChartData
function improve empty data handling without affecting other parts of the component. This aligns well with the PR objectives.To ensure comprehensive coverage, please verify the following scenarios:
- Chart rendering with valid data
- Chart rendering with empty data
- Chart rendering with partially empty data (some series empty, others not)
✅ Verification successful
Changes to
emptyChartData
verified successfully.All relevant tests are present, and usage of
ChartWidget
is properly covered.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for test files related to ChartWidget echo "Searching for ChartWidget test files..." fd -e test.tsx -e test.ts ChartWidget # Search for ChartWidget usage in the codebase echo "Searching for ChartWidget usage..." rg "ChartWidget" -t tsx -t tsLength of output: 409
Script:
#!/bin/bash # Search for test files related to ChartWidget echo "Searching for ChartWidget test files..." fd --extension test.tsx --extension test.ts --type f ChartWidget # Search for ChartWidget usage in the codebase with corrected file type patterns echo "Searching for ChartWidget usage..." rg "ChartWidget" -g "*.tsx" -g "*.ts"Length of output: 12984
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT, left 2 tiny comments...
@@ -72,6 +72,15 @@ describe("emptyChartData", () => { | |||
expect(emptyChartData(props)).toEqual(true); | |||
}); | |||
|
|||
it("returns true if each series is null or undefined", () => { | |||
const props = JSON.parse(JSON.stringify(basicEChartProps)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you are just following what the previous developer did in this test, but why are we doing stringify and parse the JS object? 🤔 Just curious about it...What's the point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically creating a (deep)clone of the object. We change some nested properties of this object in the test.
…ty chart data more efficiently
Description
These changes ensure that the ChartWidget can handle scenarios where the chart data is null or undefined, and that the tests accurately reflect this behavior.
Fixes #37008
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.Chart"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11473049534
Commit: 08602d3
Cypress dashboard.
Tags:
@tag.Chart
Spec:
Wed, 23 Oct 2024 04:52:48 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Bug Fixes
Tests
Documentation