Skip to content

Commit aed4be7

Browse files
runningcodeclaude
andcommitted
fix(snapshot): Preserve original case in sidecar filenames
The sidecar JSON and PNG filenames were being lowercased, causing a mismatch with the original screenshotId casing. Remove the `.lowercase(Locale.US)` call so filenames keep their original case. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 89a1699 commit aed4be7

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ 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
113112
import kotlin.math.ceil
114113
import org.junit.Rule
115114
import org.junit.Test
@@ -221,6 +220,7 @@ private object PaparazziPreviewRule {
221220
return Paparazzi(
222221
environment = detectEnvironment().copy(compileSdkVersion = previewApiLevel),
223222
deviceConfig = DeviceConfigBuilder.build(preview.previewInfo),
223+
theme = "android:Theme.Translucent.NoTitleBar",
224224
supportsRtl = true,
225225
showSystemUi = previewInfo.showSystemUi,
226226
renderingMode = when {
@@ -330,7 +330,7 @@ class $CLASS_NAME(
330330
}
331331
}
332332
}
333-
333+
334334
writeSidecarMetadata(screenshotId, preview)
335335
}
336336
@@ -365,7 +365,7 @@ class $CLASS_NAME(
365365
else "\"" + k + "\": " + v
366366
}
367367
val sidecarName = "Paparazzi_Preview_Test_" +
368-
screenshotId.lowercase(Locale.US).replace("\\s".toRegex(), "_")
368+
screenshotId.replace("\\s".toRegex(), "_")
369369
File(imagesDir, "${'$'}{sidecarName}.json").writeText(json)
370370
}
371371

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

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

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

122122
assertTrue(
123-
content.contains("screenshotId.lowercase(Locale.US).replace(\"\\\\s\".toRegex(), \"_\")")
123+
content.contains("screenshotId.replace(\"\\\\s\".toRegex(), \"_\")")
124124
)
125+
assertFalse(content.contains("lowercase"))
125126
}
126127

127128
private fun generateAndRead(

0 commit comments

Comments
 (0)