Skip to content

test(amber): add unit tests for visualization OpDescs (HeatMap, BarChart, LineChart, PieChart)#4812

Merged
aglinxinyuan merged 3 commits into
apache:mainfrom
Yicong-Huang:test-visualization-opdescs-2
May 3, 2026
Merged

test(amber): add unit tests for visualization OpDescs (HeatMap, BarChart, LineChart, PieChart)#4812
aglinxinyuan merged 3 commits into
apache:mainfrom
Yicong-Huang:test-visualization-opdescs-2

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds scalatest coverage for four more visualization operator descriptors. New specs for HeatMapOpDesc and LineChartOpDesc; existing thin BarChart and PieChart specs are extended with the same shape used in the previous bundle (#4809).

Each spec covers operatorInfo (name + group + outputPort count), getOutputSchemas (single-port html-content STRING), generatePythonCode (operator class + plotly imports + decode_python_template runtime decode-site count for each EncodableString), and the missing-required-field behavior — which differs by OpDesc:

  • HeatMap asserts on x, y, value (all three).
  • BarChart asserts on value and fields with explicit messages ("Value column cannot be empty" / "Fields cannot be empty").
  • PieChart asserts only on valuename has no guard, so an empty-name configuration still renders.
  • LineChart has no asserts but its lines field defaults to null; calling generatePythonCode on a default-constructed instance raises NullPointerException (see Bug filed below).

Any related issues, documentation, discussions?

Closes #4810.

Bug filed separately: LineChartOpDesc.generatePythonCode throws NullPointerException when lines is left at its null default, instead of raising AssertionError like the other visualizers or rendering an empty chart.

How was this PR tested?

sbt scalafmtCheckAll
sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.visualization.heatMap.HeatMapOpDescSpec org.apache.texera.amber.operator.visualization.barChart.BarChartOpDescSpec org.apache.texera.amber.operator.visualization.lineChart.LineChartOpDescSpec org.apache.texera.amber.operator.visualization.pieChart.PieChartOpDescSpec"

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (claude-opus-4-7)

…art, LineChart, PieChart)

Closes apache#4810

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.94%. Comparing base (9b2005d) to head (80038f1).
⚠️ Report is 1 commits behind head on main.

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              
Flag Coverage Δ
access-control-service 28.12% <ø> (ø)
amber 42.58% <ø> (+0.20%) ⬆️
computing-unit-managing-service 0.00% <ø> (ø)
config-service 0.00% <ø> (ø)
file-service 33.24% <ø> (ø)
workflow-compiling-service 47.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 HeatMapOpDesc and LineChartOpDesc.
  • Expanded existing BarChartOpDescSpec and PieChartOpDescSpec to validate operator metadata, output schema, python generation structure, and failure modes.
  • Documented current asymmetric / buggy guard behavior (e.g., LineChartOpDesc NPE on default lines).

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.
@aglinxinyuan aglinxinyuan enabled auto-merge (squash) May 3, 2026 08:07
@aglinxinyuan aglinxinyuan merged commit f0e17c2 into apache:main May 3, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for visualization OpDescs (HeatMap, BarChart, LineChart, PieChart)

4 participants