cashapp/paparazzi

Testing a Dialog does not work

dalewking opened this issue · 4 comments

I would like to do a test of a simple composable that is a Dialog

Steps to Reproduce
Create a composable that is a dialog. For example:

@Composable
fun ProgressOverlay(text: String) {
    Dialog(
        onDismissRequest = { },
        DialogProperties(
            dismissOnBackPress = false,
            dismissOnClickOutside = false,
        ),
    ) {
        Box(
            contentAlignment = Alignment.Center,
            modifier = Modifier
                .background(Color.White, shape = RoundedCornerShape(8.dp))
                .testTag("progressOverlay"),

        ) {
            Column(
                Modifier.padding(20.dp),
                horizontalAlignment = Alignment.CenterHorizontally,
            ) {
                Text(
                    text,
                    fontSize = 18.sp,
                    modifier = Modifier
                        .testTag("progressOverlayMessage"),
                )
                Spacer(Modifier.height(20.dp))
                CircularProgressIndicator()
            }
        }
    }
}

Write a paprazzi test to display it:

class ProgressOverlaySnapshot {
    @get:Rule
    val paparazzi = Paparazzi(
        deviceConfig = PIXEL_5,
        theme = "android:Theme.Material.Light.NoActionBar"
    )

    @Test
    fun exampleMessage() {
        paparazzi.snapshot {
            ProgressOverlay("This is a test")
        }
    }
}

Expected behavior
I expect the dialog to be renderedgets rendered in the snapshot, but it is not shown
18725068ad0b201c404f959c7f2e0199f9f05b28

I note that Preview in android studio does render the dialog without issue

I recall this being an issue in Android Studio but perhaps it's now fixed. Can you confirm which Android Studio you're on? Currently Paparazzi is on Chipmunk so I'm guessing this was fixed in Dolphin or Electric Eel.

I'm still on Chipmunk:

Android Studio Chipmunk | 2021.2.1 Patch 2
Build #AI-212.5712.43.2112.8815526, built on July 10, 2022

Getting back to trying to get Paparazzi added to our project and this seems to still be an issue. In this case I am on Flamingo and I can confirm Dialogs also do not show in the Compose preview either.