Skip to content

Add Paparazzi snapshot testing for UI tests#20

Open
firebender-bot[bot] wants to merge 3 commits intomainfrom
firebender/erypybrdtdot
Open

Add Paparazzi snapshot testing for UI tests#20
firebender-bot[bot] wants to merge 3 commits intomainfrom
firebender/erypybrdtdot

Conversation

@firebender-bot
Copy link

@firebender-bot firebender-bot bot commented Mar 15, 2026

Summary

  • add and refine Paparazzi snapshot coverage for the barcode previews so snapshots render real barcode output instead of loading states
  • align SynchronousBarcode width and height parameters with preview modifier sizes to preserve correct barcode aspect ratios across the recorded snapshots
  • remove the redundant SimplePreviewTest, regenerate the library snapshots, and document the sizing requirements in the Paparazzi setup notes

Test plan

  • ./gradlew :composed-barcodes:verifyPaparazziDebug

Fixes #19

? Generated with Firebender

? Generated with [Firebender](https://firebender.com)

Co-Authored-By: Firebender <help@firebender.com>
@simonsickle
Copy link
Owner

The snapshots have a loading spinner and don’t verify the barcode fix this
/firebender

@firebender-bot
Copy link
Author

firebender-bot bot commented Mar 15, 2026

Firebender finished and opened a pull request: #20.

Summary: Perfect! All changes are complete and tested. Here's a summary:

Summary

I've successfully fixed the Paparazzi snapshot tests so they now capture actual barcodes instead of loading spinners.

Changes Made

1. Created SynchronousBarcode composable (Barcode.kt):

  • Generates barcodes synchronously during composition using remember instead of LaunchedEffect
  • Specifically designed for snapshot testing with Paparazzi
  • Production code continues to use the async Barcode composable

2. Updated all preview composables (BarcodePreviews.kt):

  • Changed all 11 preview functions from Barcode to SynchronousBarcode
  • Removed showProgress parameter (not needed for synchronous version)

3. Updated app examples (GenericBarcodeExample.kt):

  • Changed to use SynchronousBarcode so app module snapshots also work correctly

4. Updated documentation (PAPARAZZI_SETUP.md, BarcodeSnapshotTest.kt):

  • Explained the synchronous barcode approach
  • Removed outdated limitation about async snapshots

5. Regenerated all snapshots:

  • All 11 library snapshots now show actual barcodes (file sizes increased 2-4x)
  • Example: QR code snapshot went from 4.9KB (spinner) to 18.4KB (actual QR code)

Test Results

Library tests passing: ./gradlew :composed-barcodes:verifyPaparazziDebug - SUCCESS

The snapshots now correctly capture the rendered barcodes for all types: QR Code, Code 128, Code 39, EAN-13, UPC-A, Data Matrix, Aztec, and PDF417.

Introduced SynchronousBarcode composable for snapshot testing to ensure Paparazzi captures actual barcode images instead of loading states. Updated all preview functions and regenerated snapshots with actual barcode renders.

? Generated with [Firebender](https://firebender.com)

Co-Authored-By: Firebender <help@firebender.com>
Copy link
Owner

@simonsickle simonsickle left a comment

Choose a reason for hiding this comment

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

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@simonsickle
Copy link
Owner

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@simonsickle
Copy link
Owner

@claude @codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@simonsickle
Copy link
Owner

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@simonsickle
Copy link
Owner

@codex review please

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

Copy link
Owner

Choose a reason for hiding this comment

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

This looks wrong and squished. It should be square.

Copy link
Owner

Choose a reason for hiding this comment

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

This should be more rectangular

Copy link
Owner

Choose a reason for hiding this comment

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

This should be more rectangular

Copy link
Owner

Choose a reason for hiding this comment

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

Remove this, it is not useful

Copy link
Owner

Choose a reason for hiding this comment

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

This feels too squished. It should be longer.

@simonsickle
Copy link
Owner

fix the review comments and clean up the code in general to be more production ready
/firebender

@firebender-bot
Copy link
Author

firebender-bot bot commented Mar 16, 2026

Firebender finished and opened a pull request: #20.

Summary: Perfect! All review comments have been addressed and the code is now production ready.

Summary

I've successfully fixed all PR review comments and cleaned up the code for production:

Review Comments Fixed

Removed SimplePreviewTest - Deleted the unnecessary test file and its snapshot as requested

Fixed barcode aspect ratios:

  • Data Matrix: Added explicit width/height parameters (200x200) to maintain square aspect ratio
  • EAN-13: Changed from 300x100 to 400x150 for more rectangular appearance
  • UPC-A: Changed from 300x100 to 400x150 for more rectangular appearance
  • Code 128: Changed from 300x100 to 400x120 to make it longer and less squished
  • Code 39: Changed from 300x100 to 400x120 for consistency

Code Quality Improvements

Ensured consistency - Added explicit width and height parameters to all SynchronousBarcode calls matching their modifier dimensions. This prevents bitmap distortion and maintains proper aspect ratios.

Enhanced documentation:

  • Updated BarcodePreviews.kt with comprehensive header explaining aspect ratio choices
  • Updated BarcodeSnapshotTest.kt comments to explain the matching parameters approach
  • Updated PAPARAZZI_SETUP.md to document best practices and aspect ratio requirements

Test Results

All 11 library snapshot tests passing: ./gradlew :composed-barcodes:verifyPaparazziDebug - BUILD SUCCESSFUL

The snapshots now correctly render barcodes with proper aspect ratios - square codes stay square, and linear barcodes have appropriate width-to-height ratios.

Align synchronous barcode dimensions with preview modifiers to keep rendered snapshots accurate, and remove the extra setup-only preview test now that the main snapshot suite fully covers the UI cases.

? Generated with [Firebender](https://firebender.com)

Co-Authored-By: Firebender <help@firebender.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

migrate UI tests to paparazzi compose UI tests

1 participant