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

Testing a Dialog does not work #619

Closed
dalewking opened this issue Oct 19, 2022 · 4 comments
Closed

Testing a Dialog does not work #619

dalewking opened this issue Oct 19, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@dalewking
Copy link

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

@dalewking dalewking added the bug Something isn't working label Oct 19, 2022
@jrodbx
Copy link
Collaborator

jrodbx commented Oct 20, 2022

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.

@dalewking
Copy link
Author

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

@jrodbx
Copy link
Collaborator

jrodbx commented Dec 15, 2022

@jrodbx jrodbx closed this as completed Dec 15, 2022
@dalewking
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants