test(amber): add unit tests for visualization OpDescs (HeatMap, BarChart, LineChart, PieChart)#4812
Conversation
…art, LineChart, PieChart) Closes apache#4810 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4812 +/- ##
============================================
+ Coverage 43.85% 43.94% +0.09%
- Complexity 2106 2125 +19
============================================
Files 957 957
Lines 34072 34072
Branches 3753 3753
============================================
+ Hits 14942 14974 +32
+ Misses 18341 18309 -32
Partials 789 789
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds ScalaTest unit coverage for additional visualization operator descriptors in common/workflow-operator, focusing on operatorInfo, getOutputSchemas, and structural properties of generatePythonCode, plus current “missing required field” behavior.
Changes:
- Added new specs for
HeatMapOpDescandLineChartOpDesc. - Expanded existing
BarChartOpDescSpecandPieChartOpDescSpecto validate operator metadata, output schema, python generation structure, and failure modes. - Documented current asymmetric / buggy guard behavior (e.g.,
LineChartOpDescNPE on defaultlines).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/pieChart/PieChartOpDescSpec.scala | Extends PieChart spec with operatorInfo/output schema/python code structural checks and guard behavior assertions. |
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/lineChart/LineChartOpDescSpec.scala | Adds new LineChart spec covering operatorInfo/output schema/python code structure and current null-lines NPE behavior. |
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/heatMap/HeatMapOpDescSpec.scala | Adds new HeatMap spec for operatorInfo/output schema/python code structure and required-field assertions. |
| common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDescSpec.scala | Extends BarChart spec with operatorInfo/output schema/python code structural checks and assertion-message coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace the loose \`decodeOccurrences >= 2\` checks in LineChart, PieChart,
and BarChart specs with sentinel-based assertions that verify each
EncodableString field is wrapped through wrapWithPythonDecoderExpr
individually. Each spec now sets distinct sentinels per field
(e.g. xLabel=\"X_LBL_SENT\" vs yLabel=\"Y_LBL_SENT\"), asserts the encoded
output contains \`self.decode_python_template('<base64>')\` for each, and
checks the raw sentinels are absent so a regression that emits one of
the fields as a literal cannot satisfy the count alone.
What changes were proposed in this PR?
Adds scalatest coverage for four more visualization operator descriptors. New specs for
HeatMapOpDescandLineChartOpDesc; existing thinBarChartandPieChartspecs are extended with the same shape used in the previous bundle (#4809).Each spec covers
operatorInfo(name + group + outputPort count),getOutputSchemas(single-porthtml-contentSTRING),generatePythonCode(operator class + plotly imports +decode_python_templateruntime decode-site count for eachEncodableString), and the missing-required-field behavior — which differs by OpDesc:HeatMapasserts onx,y,value(all three).BarChartasserts onvalueandfieldswith explicit messages ("Value column cannot be empty" / "Fields cannot be empty").PieChartasserts only onvalue—namehas no guard, so an empty-name configuration still renders.LineCharthas no asserts but itslinesfield defaults tonull; callinggeneratePythonCodeon a default-constructed instance raisesNullPointerException(see Bug filed below).Any related issues, documentation, discussions?
Closes #4810.
Bug filed separately:
LineChartOpDesc.generatePythonCodethrowsNullPointerExceptionwhenlinesis left at itsnulldefault, instead of raisingAssertionErrorlike the other visualizers or rendering an empty chart.How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-7)