Altinn / app-template-dotnet

Altinn Studio application template
1 stars 8 forks source link

Automatically generated end-to-end tests for apps #122

Open olemartinorg opened 1 year ago

olemartinorg commented 1 year ago

Background

As the library of deployed apps grows larger, this also increases the damage potential from any code changes (in frontend, app-lib) breaking existing functionality in deployed apps. As of right now, most apps use the latest v3 of the frontend app, and soon we'll want to migrate towards an app template were app-lib dependencies are managed automatically so that simple apps never need to be manually updated to keep getting updates.

We've had a few cases this spring/summer where seemingly innocuous changes (by me) in the frontend application have caused existing apps to crash unexpectedly. (If you're curious, one of these happened because a regex included syntax not supported in safari - a browser not routinely tested right now, and the other happened because a change to fix a warning caused a crash when the paragraph text was null.)

Proposed solution

As we're moving to make most simple apps into a collection of configuration files, we can also parse the configuration and generate automatic tests to be run in a browser. These tests could open the app, fill out the form, navigate though tracks, summaries, confirmations and receipts, and test the validity of data models produced in the end. Automatic tests could (or should) include a bit of randomness as it adds rows to repeating groups, uploads dummy attachments, possibly going back to correct mistakes on previous pages, try to submit before filling out all required fields (or adding too few rows in a repeating group), in order to get validation errors. In general though, we should be testing the happy-path where most users end up, as it's most important for us to catch show-stopping problems before we roll out new code to the public.

I would suggest implementing this by reading the page/layout/etc configuration files in the app, start the app in a closed/contained environment, and attempt to generate tests to run in a test framework like Playwright. With broad browser support, we should make sure to test in all major browsers every new release (for frontend, at least) along with mobile browsers.

Custom code in apps

Some apps have limitations on who can create instances, custom server-side validations on some fields, custom options, etc. We should make it easy for app developers to extend our tests in order to:

Other benefits

Pitfalls

Potential future improvements

Next steps

Implementing this is most likely quite an undertaking. We should try our hands at making a Proof of Concept, and proceed from there.

Related issues

These are both simpler solutions to the same problem (of crashing app-frontend-react bringing down the house), but will be much easier to implement (but won't give us all the same benefits, and both of these would be reactive instead of preventative):

ivarne commented 1 year ago

🤩🤩🤩🤩

haakemon commented 1 year ago

This sounds like a great suggestion!