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

Render compose component with clock based logic #605

Open
charlesng opened this issue Dec 12, 2024 · 9 comments
Open

Render compose component with clock based logic #605

charlesng opened this issue Dec 12, 2024 · 9 comments

Comments

@charlesng
Copy link

First of all , i like the feature "Experimental Compose Preview Support" 😄 , which provides us confidence on all our 8xx preview components, which is good. However, some of preview we have to igore them in roborazzi test because there is clock-based logic inside the component.

We have a stateful compose component which included count down logic like below

LaunchedEffect(key1 = model.expiryTime) {
   while( remainingSeconds > 0) {
      delay(1000)
      remainingSeconds -=1
   }
}

When we run roborazzi, the recorded screenshot generate different result everytime.

I would like to seek any advice for it 🙏

@takahirom
Copy link
Owner

We can add @PausedPreview to handle this, which we need to add manually now. I added the contributions welcome label to this issue. We might have to add the roborazzi-annotation module to use the annotation in the production source set and utilize the annotation in roborazzi-compose-preview-scanner-support to set autoAdvance = false and advanceTimeBy(xxx).
https://speakerdeck.com/sumio/shi-zu-mikarali-jie-suru-composepurebiyuwoyang-nabariesiyondesukurinsiyotutotesutosiyou?slide=101

@sergio-sastre
Copy link
Contributor

sergio-sastre commented Dec 12, 2024

I can help with this since I have the full picture on my head of what has to be done and it should be pretty simple.

Since this is the second time it is requested, like in #550, we can prioritise this.

Adding this would also be a good preparation for
#447.

@takahirom
Copy link
Owner

Since this is the second time it is requested, like in #550, we can prioritise this.

I went to an Android meet-up about testing in Japan, and I received the same feedback there 😅
If you could help, it would be much appreciated!

@sergio-sastre
Copy link
Contributor

Sure! Let me handle this. I‘m busy this week but I think I can get something working before new year 😊

@charlesng
Copy link
Author

Thanks a lot for the quick reply, i am looking forward to the new version supporting this 🎉

@sergio-sastre
Copy link
Contributor

Sure! Let me handle this. I‘m busy this week but I think I can get something working before new year 😊

This will take a bit longer. I’m planning to finalise next ComposablePreviewScanner release next week and then I’ll handle this right afterwards.

Thanks for your patience 🙏

@sergio-sastre
Copy link
Contributor

FYI: I'll start working on this next week 🚀

@takahirom
Copy link
Owner

@sergio-sastre Thank you for the update! I appreciate you taking on this task. We're looking forward to it! 🎉

@sergio-sastre
Copy link
Contributor

sergio-sastre commented Jan 18, 2025

Hi @takahirom
I've been working on this and I'm blocked because the new module I created :roborazzi-annotations does not compile:
#633

When I execute
./gradlew :roborazzi-annotations:compileDebugKotlin

it fails with an error I am unable to decipher...
Could you help me with that?

Moreover, I've also observed that to achieve that we need a ComposeTestRule and we use an ActivityScenario, which is necessary for setting size and background preview parameters...

Without making big changes, the fastest way to achieve it is by adding the ComposeTestRule in the PreviewTester... I do not like the solution too much to be honest... maybe you have an idea on what it would be the best way to solve that?

takahirom added a commit to sergio-sastre/roborazzi that referenced this issue Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants