-
Notifications
You must be signed in to change notification settings - Fork 20
[DNM] Add paparazzi and compose snapshots preview #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| val previewInfo = preview.previewInfo | ||
| preview() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The previewInfo variable is extracted but unused. The preview() object is invoked directly, which likely ignores the intended preview configuration for the snapshot test.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
In the snapshot test, the previewInfo variable is extracted from the preview object but is never used. Instead, the preview() object is invoked directly. According to the library's documentation, the composable function should be invoked via the previewInfo object (e.g., previewInfo.previewComposable.invoke()). This discrepancy means that important configuration metadata from the @Preview annotation, such as device settings, locale, and theme, is likely being ignored. As a result, the generated snapshots may not reflect the intended configuration, leading to incorrect or failing tests.
💡 Suggested Fix
Replace the direct invocation preview() with the invocation from the previewInfo object, such as previewInfo.previewComposable.invoke(). This will ensure the composable is rendered with the correct configuration specified in its @Preview annotation.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
android/app/src/test/kotlin/com/emergetools/hackernews/ComposePreviewScanner.kt#L38-L40
Potential issue: In the snapshot test, the `previewInfo` variable is extracted from the
`preview` object but is never used. Instead, the `preview()` object is invoked directly.
According to the library's documentation, the composable function should be invoked via
the `previewInfo` object (e.g., `previewInfo.previewComposable.invoke()`). This
discrepancy means that important configuration metadata from the `@Preview` annotation,
such as device settings, locale, and theme, is likely being ignored. As a result, the
generated snapshots may not reflect the intended configuration, leading to incorrect or
failing tests.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7526923
🛰️ Build DistributionBuild available for installation
🛸 Powered by Emerge Tools |
⏱ Performance AnalysisHacker News
🛸 Powered by Emerge Tools |
📸 Snapshot Test8 added, 84 unchanged
🛸 Powered by Emerge Tools |
Restored BookmarksScreenComposeTest.kt and StoryRowComposeTest.kt from git history to maintain test coverage for Compose UI components.
…r test Ensures the output directory is cleaned before generating new preview scanner test files to prevent stale generated files from accumulating. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… configuration Update the Paparazzi preview scanner plugin to generate more sophisticated tests with comprehensive device configuration and preview parameter handling. Changes: - Update ComposablePreviewScanner library from 0.7.2 to 0.8.1 - Add includePrivatePreviews configuration option - Generate tests with DeviceConfigBuilder for proper device configuration (screen size, density, orientation, locale, night mode) - Add PaparazziPreviewRule.createFor() to create per-preview configured Paparazzi instances with dynamic API level support - Support custom rendering modes (NORMAL, FULL_EXPAND, SHRINK) - Add custom snapshot handlers (PreviewSnapshotVerifier, PreviewHtmlReportWriter) - Add SystemUiSize and PreviewBackground composables to handle showSystemUi, showBackground, and backgroundColor parameters - Use encodeUnsafeCharacters() in screenshot ID builder for proper character handling - Remove build artifacts from git tracking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
d43dccf to
7d4e4f4
Compare
Add baseline snapshot images generated by the enhanced Paparazzi preview scanner for visual regression testing. Changes: - Add new snapshot images with improved naming convention using encoded screenshot IDs - Remove old snapshot images that used numbered naming - Update gradle/libs.versions.toml: - Pin AGP version to 8.13.2 - Remove composable-preview-scanner library (now auto-injected by plugin) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove old numbered snapshot files from ui-components module. The new snapshots with improved naming were already committed in the previous change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Bundle the Paparazzi Gradle plugin as a dependency of the preview scanner plugin, so users no longer need to explicitly apply it. Changes: - Add Paparazzi Gradle plugin as implementation dependency in plugin build.gradle.kts - Add warning comment about potential version conflicts - Remove explicit Paparazzi plugin application from app and ui-components modules - Update plugin source with clarifying comment about plugin application - Users now only need to apply the preview-scanner plugin to get full functionality This simplifies setup by reducing it to a single plugin application instead of two. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The Paparazzi preview scanner now filters out previews from dependency modules, ensuring each module only generates snapshots for its own previews. This prevents duplicate/conflicting snapshots and improves build performance. Implementation uses Gradle's variant source directories to accurately determine which previews belong to the current module, supporting all Android project structures including product flavors and custom source sets. - Query actual source directories from Android variant configuration - Filter previews by checking source file existence in module directories - Handle Kotlin file-level functions (Kt suffix removal) - Remove bundled Paparazzi dependency from plugin (users apply manually) - Add proper Gradle task input annotations for correct caching 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
3989868 to
7bb599a
Compare
Remove redundant comments and improve code clarity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This adds paparazzi and the compose snapshots preview library to scan and find compose previews for paparazzi.
Paparazzi + compose snapshots preview folder is in
android/paparazzi-preview-scanner-plugin