salesforce / utam-js-recipes

Examples of testing with UTAM JavaScript
MIT License
48 stars 23 forks source link

[Feat Request] Introduce session check when running spec #28

Closed pozil closed 2 years ago

pozil commented 2 years ago

Is your feature request related to a problem? Please describe

When running tests, there's a good change that we either forget to log in or that a session that we obtained earlier has expired. If this is the case, we are blocked on the login page and the tool performs a series of retries that will lead to an unclear error after timing out.

Describe the solution you'd like

I'm suggesting a solution that I've implemented in the E-Bikes sample app.

Let's save a timestamp when we generate the env file with the login URL: https://github.com/trailheadapps/ebikes-lwc/blob/main/scripts/generate-login-url.js#L36

In our spec, we then read the timestamp and figure out if if the session has expired: https://github.com/trailheadapps/ebikes-lwc/blob/main/force-app/test/utam/page-explorer.spec.js#L27

If this is the case, we abort the test with a clear error message. https://github.com/trailheadapps/ebikes-lwc/blob/main/force-app/test/utam/page-explorer.spec.js#L31

olivier-martin-sf commented 2 years ago

Hi @pozil, that's indeed an improvement and a great suggestion, do you feel like implementing a PR for this? Thank you for such a helpful contribution