Skip to content

Add Paparazzi snapshot testing pipeline#36

Merged
andremion merged 3 commits into
developfrom
andrerego/and-1234-snapshot-pipeline
Jun 16, 2026
Merged

Add Paparazzi snapshot testing pipeline#36
andremion merged 3 commits into
developfrom
andrerego/and-1234-snapshot-pipeline

Conversation

@andremion

@andremion andremion commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Goal

The stream-chat-android-ai-compose module had no test source set and no snapshot coverage. This adds a Paparazzi snapshot pipeline so UI changes to the AI components are caught on every PR. It also lands before the component factory work (AND-1233), so that change can show a clean visual diff against this baseline. Linear: AND-1234.

Implementation

  • Apply the Paparazzi plugin, pinned to 2.0.0-alpha02. The stable line does not support this repo's Kotlin 2.2 / AGP 8.13 toolchain, and the newer alpha needs Gradle 9, so alpha02 is the only line that works here.
  • PaparazziTest is the shared base. It renders inside MaterialTheme and Surface (the module has no ChatTheme), enables LocalInspectionMode, and provides a no-op ActivityResultRegistryOwner so the composer's photo picker renders without a host activity.
  • Snapshot tests for the four public components: ChatComposer, StreamingText, AITypingIndicator, SpeechToTextButton (10 golden images under src/test/snapshots/images).
  • Each previewed state is a shared internal composable used by both the @Preview and the snapshot test, so previews and snapshots cannot drift apart. This matches the main SDK convention.
  • Snapshot verification runs on CI through the convention plugin's testCoverage task, which runs verifyPaparazziDebug for modules with the Paparazzi plugin (and the regular unit tests). The Paparazzi plugin is applied before the convention plugin so it is detected.
  • StreamingText: when animate is false, initialize the displayed text to the full text so the first frame shows it. The text was revealed through an effect that does not settle in a single frame. This also removes an empty-frame flash for static messages. The animated path is unchanged.

Testing

Automated:

  • ./gradlew testCoverage runs the unit tests and verifies all snapshots.
  • ./gradlew recordPaparazziDebug regenerates the goldens.

Manual steps in the sample app:

  1. Open the chat screen and confirm the composer, typing indicator, streaming text, and voice button look unchanged.
  2. Send a message and confirm a settled (non-generating) assistant message and user messages show their text immediately, with no empty flash.

Notes for the reviewer:

  • The goldens were recorded on macOS. The first CI run on Linux confirms cross-platform stability; if it reports diffs, the fix is to record on CI.
  • Paparazzi 2.0.0-alpha02 is a pre-release, used because it is the only line compatible with this toolchain.

Checklist

  • Issue linked (AND-1234)
  • Tests/docs updated
  • I have signed the Stream CLA

Apply the Paparazzi plugin (2.0.0-alpha02, the line that supports this repo's
Kotlin 2.2 / AGP 8.13 toolchain) and add snapshot tests for the AI compose
components.

PaparazziTest is the shared base: it renders inside MaterialTheme and Surface (the
module has no ChatTheme), enables LocalInspectionMode, and provides a no-op
ActivityResultRegistryOwner so the composer's photo-picker launcher renders without
a host activity. Tests cover AITypingIndicator, ChatComposer, and SpeechToTextButton,
producing 9 golden images.

Preview content for each state is extracted into shared internal composables that
both the @Preview functions and the snapshot tests call, so they cannot drift apart.

Snapshot verification runs on CI through the unit test job, which now runs
verifyPaparazziDebug (a superset that also runs the regular unit tests).
… frame

StreamingText revealed its text through a LaunchedEffect, so the first composition
showed empty text before the effect ran. When animate is false, initialize the
displayed text to the full text so it appears immediately, matching the documented
behavior and letting it render in a single Paparazzi frame.

Add the StreamingText snapshot test and its shared preview content function.
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@andremion andremion added the pr:ci CI / build tooling label Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-ai-compose 0.02 MB 0.02 MB 0.00 MB 🟢

@andremion andremion marked this pull request as ready for review June 15, 2026 15:48
@andremion andremion requested a review from a team as a code owner June 15, 2026 15:48

@gpunto gpunto 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.

Looks good, I just left a suggestion to align with the other repos

Comment thread .github/workflows/ci.yml Outdated
Comment thread stream-chat-android-ai-compose/build.gradle.kts Outdated
Align with the other Stream repos: the convention plugin registers a testCoverage task
that runs verifyPaparazziDebug for modules with the Paparazzi plugin. Opt the module into
coverage.includedModules and apply the Paparazzi plugin first so the convention detects it,
then run testCoverage on CI.
@andremion andremion enabled auto-merge (squash) June 16, 2026 10:39
@andremion andremion merged commit 95366e6 into develop Jun 16, 2026
9 checks passed
@andremion andremion deleted the andrerego/and-1234-snapshot-pipeline branch June 16, 2026 12:55
@stream-public-bot stream-public-bot added the released Included in a release label Jun 17, 2026
@stream-public-bot

Copy link
Copy Markdown

🚀 Available in v0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:ci CI / build tooling released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants