Skip to content

Add screenshot tests for Compose-based HTML -> annotated strings - #7441

Merged
TimoPtr merged 1 commit into
home-assistant:mainfrom
jpelgrom:screenshottest-htmltext
Sep 11, 2026
Merged

TimoPtr merged 1 commit into
home-assistant:mainfrom
jpelgrom:screenshottest-htmltext

Conversation

@jpelgrom

Copy link
Copy Markdown
Member

Summary

Adds screenshot tests for the function that was added in #7288 to convert HTML strings (templates) to an annotated string for display in Compose.

Adresses the second paragraph of my last review comment.

Note that Html.fromHtml never creates absolute size spans, so this branch isn't in screenshots. See the source code, the only usage of AbsoluteSizeSpan is when converting a string that already has one to HTML.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.
  • I have read the Open Home Foundation AI Policy.

Select exactly one option that describes AI usage in this contribution:

  • I have not used AI for this contribution.
  • AI assistance was used for this contribution.
  • AI fully generated the code for this contribution, but I've reviewed and understood it before submitting and will respond without AI during review.

Screenshots

See changed files

Link to pull request in documentation repositories

n/a

Any other notes

Copilot AI lite review requested due to automatic review settings September 10, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new screenshot test’s KDoc overstates coverage (missing the AbsoluteSizeSpan branch) and the preview setup deviates from established screenshot-test conventions in this module.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new screenshot-test suite in :app to visually validate the HTML → AnnotatedString conversion used by Compose screens when rendering Home Assistant templates.

Changes:

  • Introduces HtmlTextScreenshotTest with previews covering common markup cases (bold/italic/underline/size/color/line breaks).
  • Adds combined-markup scenarios to catch span-interactions in the rendered output.
File summaries
File Description
app/src/screenshotTest/kotlin/io/homeassistant/companion/android/util/compose/HtmlTextScreenshotTest.kt Adds screenshot previews to exercise parseHtml output across typical HTML span combinations.
Review details
  • Files reviewed: 1/10 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +9 to +14
/**
* Tests for all possible spans supported by [parseHtml] with:
* - no markup (verify nothing changes)
* - each markup separate
* - markup combined
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The original doc is correct, it is what is possible by using parseHtml. It just will never reach that branch as it isn't possible.

We should maybe drop AbsoluteSizeSpan completely but that is out of scope for this PR in my opinion.

@TimoPtr
TimoPtr merged commit fe9dae6 into home-assistant:main Sep 11, 2026
22 checks passed
@jpelgrom
jpelgrom deleted the screenshottest-htmltext branch September 11, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants