eBay / flutter_glove_box

Various eBay tools for Flutter development
BSD 3-Clause "New" or "Revised" License
321 stars 69 forks source link

Support screenshots over time #52

Open matthew-carroll opened 4 years ago

matthew-carroll commented 4 years ago

This package is tailored towards multiple screenshots at one moment, like the same widget shown in 5 different ways.

A similar but different use-case is a series of screenshots over time. For example, I might have a 5 screen user journey and I'd like to capture all 5 of those steps within a single golden test so that I can easily monitor the whole flow.

It would be nice if the goldent_toolkit included a concise API to take screenshots over time and then stitch those together into a single horizontal timeline of screens.

coreysprague commented 4 years ago

We actually have a solution for this, but not currently in the repo. One of our developers spiked it in before we open sourced, but we didn't keep it because we didn't use it very much. I'll take a look at what it would look like to resurrect it.

We used it specifically for validating key frames during complex animations. I'll give some thought to the API.

coreysprague commented 4 years ago

relates to https://github.com/eBay/flutter_glove_box/issues/11

https://github.com/flutter/flutter/pull/55527 also looks relevant

matthew-carroll commented 4 years ago

Animation screenshots would probably also be useful. I don't know if 2 APIs are more conducive to these 2 situations, or if they can easily operate with just 1 API, but I'd say both user journey screenshots as well as animation screenshots would be useful. Thanks.

coreysprague commented 4 years ago

I need to look at that flutter PR more closely, but conceptually, what I'm thinking about is allowing the user to exercise multiple golden assertions through a test, and have some API that allows you to batch them together

conceptually, something like:

stitchedGolden(() {
   // snap a golden
   // do some stuff
   // snap another
   // do some stuff
   // snap another
});

although the API won't probably look like that, but conceptually be unopinionated about the reason for wanting to combine multiple goldens into a single image

matthew-carroll commented 4 years ago

@coreysprague FYI - I just ran into this requirement on another project. Any chance that we'll see this capability soon?

coreysprague commented 4 years ago

@matthew-carroll I don't have an ETA for it. Have you checked this out? I believe it is available in Flutter stable now: https://github.com/flutter/flutter/pull/55527

matthew-carroll commented 4 years ago

Animation sheets look like they're tailored for animations, whereas I'm looking to take snapshots of multiple screens back to back. I'd also like to take snapshots on the web, which that PR says are not supported for animation sheets.

Do you have particular opinions about what this API should look like, or would it make sense for me to try designing something for this package?

coreysprague commented 4 years ago

@matthew-carroll: In that case.... check out the latest 0.7.0 build...

This PR added a way for multiple "full screens" to be shown in a single golden diff. https://github.com/eBay/flutter_glove_box/pull/68

I think you might be able to accomplish what you are looking for using this.

Each scenario can be acted upon independently. See this golden as an example:

Granted, in this example it's all the same screen, just different state. However, I see no reason that you couldn't do something conceptually like this:

..addScenario(FirstScreen(), (t) {});
..addScenario(FirstScreen(), (t) { userPressesButtonToNavigateToSecondScreen() });

pardon the pseudo code 😄

I haven't tried using this new API, but I think it might get you pretty close.

coreysprague commented 4 years ago

that being said, I think there is still potentially value in a lower level utility for stitching multiple goldens together.. but maybe the above will satisfy for now?