Skip to content

Commit 67c9dc9

Browse files
runningcodeclaude
andcommitted
fix(snapshot): Lowercase sidecar filenames to match Paparazzi images
Paparazzi's `Snapshot.toFileName()` applies `.lowercase(Locale.US)` to the snapshot name when generating image filenames. The sidecar JSON filenames must match, so re-add the lowercase call that was removed in e460156. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 11d8b61 commit 67c9dc9

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

plugin-build/src/main/kotlin/io/sentry/android/gradle/snapshot/GenerateSnapshotTestsTask.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import app.cash.paparazzi.detectEnvironment
109109
import com.android.ide.common.rendering.api.SessionParams
110110
import com.android.resources.*
111111
import java.io.File
112+
import java.util.Locale
112113
import kotlin.math.ceil
113114
import org.junit.Rule
114115
import org.junit.Test
@@ -365,7 +366,7 @@ class $CLASS_NAME(
365366
else "\"" + k + "\": " + v
366367
}
367368
val sidecarName = "Paparazzi_Preview_Test_" +
368-
screenshotId.replace("\\s".toRegex(), "_")
369+
screenshotId.lowercase(Locale.US).replace("\\s".toRegex(), "_")
369370
File(imagesDir, "${'$'}{sidecarName}.json").writeText(json)
370371
}
371372

plugin-build/src/test/kotlin/io/sentry/android/gradle/snapshot/GenerateSnapshotTestsTaskTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ class GenerateSnapshotTestsTaskTest {
116116
}
117117

118118
@Test
119-
fun `generated sidecar filename preserves original case`() {
119+
fun `generated sidecar filename is lowercased to match Paparazzi image filenames`() {
120120
val content = generateAndRead(packageTrees = listOf("com.example"))
121121

122-
assertTrue(content.contains("screenshotId.replace(\"\\\\s\".toRegex(), \"_\")"))
123-
assertFalse(content.contains("lowercase"))
122+
assertTrue(
123+
content.contains("screenshotId.lowercase(Locale.US).replace(\"\\\\s\".toRegex(), \"_\")")
124+
)
124125
}
125126

126127
private fun generateAndRead(

0 commit comments

Comments
 (0)