Skip to content

test(workflow-operator): add ImageUtilitySpec for encodeImageToHTML#5679

Open
KYinXu wants to merge 2 commits into
apache:mainfrom
KYinXu:test/image-utility-spec
Open

test(workflow-operator): add ImageUtilitySpec for encodeImageToHTML#5679
KYinXu wants to merge 2 commits into
apache:mainfrom
KYinXu:test/image-utility-spec

Conversation

@KYinXu

@KYinXu KYinXu commented Jun 13, 2026

Copy link
Copy Markdown

What changes were proposed in this PR?

Pin the Python snippet emitted by ImageUtility.encodeImageToHTML() — the helper that visualization operators splice into generated UDF code to base64-encode binary image data into an tag. Any drift in the f-string template or the error fallback would silently break image-rendering operators (e.g. Word Cloud). No production-code changes. Negative cases are covered implicitly: removing any pinned substring fails the corresponding assertion.

Spec Source Class Tests
ImageUtilitySpec ImageUtility 8

Spec file name follows the <srcClassName>Spec.scala one-to-one convention.

Behavior pinned

Surface Contract
encodeImageToHTML returns a non-empty String
Snippet imports base64 substring import base64 appears
Snippet calls base64.b64encode(binary_image_data) substring appears verbatim
Snippet decodes to UTF-8 substring .decode("utf-8") appears
Snippet emits an <img> tag with data:image;base64,... substring data:image;base64,{encoded_image_str} appears (verifies the f-string template)
Snippet handles binary-decode failure via try/except substrings except Exception and Binary input is not valid both appear
Snippet contains a top-level html = assignment substring html = f appears so downstream code can reference html
Determinism two calls return the exact same string

The harness pins via contains on canonical substrings — resilient to incidental whitespace changes from stripMargin while still catching real template drift.

Any related issues, documentation, discussions?

Closes #5665

How was this PR tested?

Unit tests were added here, tested through local verification:

  • sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.visualization.ImageUtilitySpec" - All 8 tests passed
  • sbt scalafmtCheckAll -- clean
  • sbt scalafixAll --check No lint errors

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

Generated-by: Composer 2.5 Fast

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for your first contribution to Texera, @KYinXu!

If you're looking for a good place to start, browse issues labeled starter-task; they're scoped to be approachable for newcomers.

You can drive common housekeeping yourself by commenting one of these commands on its own line:

  • Issues. Comment /take to assign an open issue to yourself, or /untake to release it. You can find unclaimed work with the search filter is:issue is:open no:assignee.
  • Sub-issues. To link issues into a parent/child hierarchy, comment /sub-issue #5166 #5222 on the parent to attach those children (or /unsub-issue #5166 #5222 to detach them). From a child issue, comment /parent-issue #5166 to set its parent, or /unparent-issue to clear it (the current parent is detected automatically). References may be written as #5166 or as a bare 5166; cross-repository references are not supported.
  • Pull requests (author only). Comment /request-review @user to request a review from someone, or /unrequest-review @user to withdraw that request.

Each command must match exactly: /take this will not work, only /take does. For the full contribution flow, see CONTRIBUTING.md.

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 test coverage for ImageUtility

1 participant