mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.77k stars 267 forks source link

[Feature Request] Parameter interpolation should work for runFlow.file #1314

Open solidcell opened 1 year ago

solidcell commented 1 year ago

Is your feature request related to a problem? Please describe. In order to dry usage of nested flows, I'd like to define constants for their paths. However, parameters don't seem to work when used for runFlow.file.

For instance:

$ export MAESTRO_EMAIL_LOGIN_SUBFLOW=/path/to/subflows/email-login.yaml

...
- runFlow:
    file: /${MAESTRO_SUBFLOW_EMAIL_LOGIN}
...

Note: I'm using a leading / so that the path isn't interpreted as a relative path. Ostensibly, this wouldn't be necessary if interpolation worked, since it would see there's already a leading /.

Describe the solution you'd like I'd like for the above to interpolate correctly. However, it looks like interpolation doesn't occur. The text is taken literally.

I get a failure with the following error message: Flow file is invalid: /${MAESTRO_SUBFLOW_EMAIL_LOGIN}

The documentation doesn't go into specifics about where interpolation is permitted, but from the examples and my experimentation, it seems like it only works on top-level nodes.

Not only would I like this to work in order to keep my flow files DRY and less verbose, but they are much too coupled with the directory structure otherwise. For instance, if I have the following structure:

flows/auth/feature.yaml
flows/subflows/email-login.yaml

Then in feature.yaml I need to reference the subflow via ../../subflows/email-login.yaml The flow file shouldn't need to know internally where it lives. And I'd argue it shouldn't need to know where a subflow files lives either. If I change the directory structure of my flow files in the future, even just a little, it will case a lot of pain.

Describe alternatives you've considered

  1. I could just continue to fully type out the paths, which is quite verbose and not DRY.
  2. I could run some external preprocessor to interpolate it myself and not rely on Maestro's interpolation, however this doesn't seem worth it. The documentation should at least be specific about the intended usage and limitations.
ricardo7martins commented 2 months ago

This would be super helpful. Interesting how this is a thing for actions, but not for runFlow/runScript. As pointed above, having to type the same path on several files is quite cumbersome. I was trying to create an output.paths for a while before coming here and seeing it's not a thing already. Sad