Skip to content
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

Paparazzi + Showkase Integration - java.io.FileNotFoundException (File name too long) #340

Open
ss0930 opened this issue Aug 9, 2023 · 5 comments

Comments

@ss0930
Copy link

ss0930 commented Aug 9, 2023

I am using showkase-screenshot-testing-paparazzi from #294 to auto-generate snapshots for Composable Previews. For certain previews that have long names, I am running into this issue from Paparazzi cashapp/paparazzi#734. Since the test name and png file name is being generated on Showkase, not sure if there is something I can do on my end.

I am able to get around it by renaming the Preview to something shorter, but would be great to have a fix for this in Showkase itself.

@evant
Copy link

evant commented Sep 15, 2023

Ran into this as well, leaving some notes on how this can be improved:

  1. It appears the generated file names for properties can be aggressively long, including the preview name, the component name, and the group name concatenated together. beta17 was even worse including the package name as well but that appears to be fixed.

    Do we actually need all of those? I'd think the preview function name would be sufficient since you can't have duplicate function names in the source files anyway, but maybe there's something I'm missing there.

  2. If you use preview params it also generates a lamba which is represented by a synthetic class. The name of this lambda is filename$propertyname$1.class which blows it up even more. shortening the filename/property would also help here but you can also go one step further and split it out into a separate function so the lamba isn't generated at all. Something like:

public val MyPreviewNameGroup: List<ShowkaseBrowserComponent> = 
    PreviewStyle()
        .values
        .iterator()
        .asSequence()
        .mapIndexed(::spacingPreviewSpacingExtrasSDKSpacingValues)
        .toList()
        
private fun myPreviewNameGroup(index: Int, previewParam: Param): ShowkaseBrowserComponent {
   return ShowkaseBrowserComponent(
        group = "Group"
        componentName = "Name",
        componentKDoc =  "",
        componentKey = ...,
        isDefaultStyle = false,
        component = @Composable { MyPreview(param = previewParam) }
    )
}

@vinaygaba
Copy link
Collaborator

vinaygaba commented Sep 21, 2023

@evant The reason all this info is added is because you can you repeated annotations and a single function can actually end up being multiple previews depending on how you are using the preview annotations. I do think that I need to figure out an alternate way to solve this though as hitting this issue could be common if you are using longer and more descriptive names.

For example, here's a file that Paparazzi generated in the sample project --

com.airbnb.android.showkase.screenshot.testing.paparazzi.sample_MyPaparazziShowkaseScreenshotTest_PaparazziShowkaseTest_test_previews[1.Chips**Basic Chip**Default Style,1.Pixel5,1.Ltr,1.DEFAULT]_chips**basic_chip**default_style

I wonder if I can somehow get rid of the earlier portion of the name that's added by Paparazzi by default i.e com.airbnb.android.showkase.screenshot.testing.paparazzi.sample_MyPaparazziShowkaseScreenshotTest_PaparazziShowkaseTest. Do you know if I can somehow configure that?

@evant
Copy link

evant commented Sep 21, 2023

The reason all this info is added is because you can you repeated annotations and a single function can actually end up being multiple previews depending on how you are using the preview annotations

Could you generate multiple properties in the same file or generate a single property that's a list of the components?

@evant
Copy link

evant commented Sep 21, 2023

Actually, just realized that this issue is about the generated paparazzi name. This name is purely generated from the test name so the fix would be separate, happy to open a new issue for generated showkase class names if that makes more sense.

@KatieBarnett
Copy link

I'm getting this as well with just Showkase (although actually we plan to use Paparazzi soon as well). Is there a possible workaround? We have a lot of previews and need descriptive names.

evant added a commit to evant/Showkase that referenced this issue Apr 10, 2024
This reduces the length of the filename because a disambiguated property
name can be quite long. Looking at the files gerenated in the sample
app, before this change the longest is 161 chars, after it's 102.

Partially addresses airbnb#340
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

No branches or pull requests

4 participants