You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I was looking into why the paparazzi snapshot keep generating a new golden images for existing components whenever I add a new component, I found out that it may be because of the name generation although I'm not really quite sure exactly if it's related yet. When a composable has a custom multipreview annotation from another module ,every time you add a composable to that module, the name will be generated with different integer in it.
To demonstrate, follow these steps:
Create a module, we call this rootModule, since this is where ShowKaseRoot will live. Setup ShowKase here
In this Module, create a composable, ComposableB
@Composable
funComposableB() { /*...*/ }
Create an Android library module, for future reference, we call this lib and setup ShowKase there
Create a custom multipreview annotation in the lib module
I don't observe this problem when using Preview or when the custom multipreview annotation is from same module. This only happens when referencing the one from another module. And this integer shift only affects previews that are lower in term of alphabetical order than the new one. In above example, B used to be 1. Then adding A shift B to 1. Adding ComposableC would not affect ComposableB
This impact us greatly because we have a common multipreview annotations in our core module referenced by different feature module. Every time we add a new composable, all of our snapshots are regenerated and we can't rely anything from snapshot test because of this bug. It also would not make sense to have the same preview groups across all features for us that would be a lot harder to maintain.
The text was updated successfully, but these errors were encountered:
vincent-paing
changed the title
showkaseName for composable is unstable when referencing Preview group from another module
showkaseName for composable is unstable when referencing multi preview annotation from another module
Apr 3, 2024
vincent-paing
changed the title
showkaseName for composable is unstable when referencing multi preview annotation from another module
showkaseName for composable is unstable when referencing custom multipreview annotation from another module
Apr 3, 2024
I believe this number is the elementIndex when generating ShowkaseMetadata.Component as: showkaseName = "${xElement.name} - ${customPreviewMetadata.previewName} - $elementIndex",
Since in this example the customPreviewMetadata.previewName is null we get the - - #
You can just filter this out using regex if it is used as part of a snapshot filename (e.g. when using Paparazzi).
For example: showkaseBrowserComponent.componentName.replace("""- - \d$""".toRegex(), "")
When I was looking into why the paparazzi snapshot keep generating a new golden images for existing components whenever I add a new component, I found out that it may be because of the name generation although I'm not really quite sure exactly if it's related yet. When a composable has a custom multipreview annotation from another module ,every time you add a composable to that module, the name will be generated with different integer in it.
To demonstrate, follow these steps:
rootModule
, since this is where ShowKaseRoot will live. Setup ShowKase hereComposableB
lib
and setup ShowKase therelib
moduleComposableB
back inrootModule
with this annotationrootModule
and preview with same preview groupComposableBPreview
has now changed from previously 0 to now 1I don't observe this problem when using
Preview
or when the custom multipreview annotation is from same module. This only happens when referencing the one from another module. And this integer shift only affects previews that are lower in term of alphabetical order than the new one. In above example, B used to be 1. Then adding A shift B to 1. AddingComposableC
would not affectComposableB
This impact us greatly because we have a common multipreview annotations in our core module referenced by different feature module. Every time we add a new composable, all of our snapshots are regenerated and we can't rely anything from snapshot test because of this bug. It also would not make sense to have the same preview groups across all features for us that would be a lot harder to maintain.
I have a made a repo here to test out easily
The text was updated successfully, but these errors were encountered: