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

Add NALD test data to permit licence helper #1049

Merged
merged 2 commits into from
May 23, 2024

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/WATER-3981

The water-abstraction-service has a mechanism for seeding data for testing that relies on loading in YAML fixture files, sort of. Some content comes from these, but other stuff is hard-coded into the 'loaders'.

Long story short, we're going to replace it with something simpler yet more flexible!

Our new solution is going to be based on the hard work we've already invested in making our test helpers. We use these to quickly create meaningful records in the DB which we can then write unit tests against. So, why not reuse them to do the same for our acceptance tests!?

One key difference with the unit tests is we are only driving the app through our code. Anything external we mock or stub. The acceptance tests do not have that luxury which means any record we create has to support not only this app but the legacy ones.

The good news is we can do nearly all that with the existing helper data and functionality. The one key bit missing is the licence_data_value for a permit.licence. In real life, when a licence is imported from NALD into WRLS a number of records get created. A lot of it is duplication, but not everything from NALD is put into tables.

This seems to stem from an early architectural decision that WRLS would be building a generic 'permit' repository. Some top level information is captured in permit.licence. But because it needed to be 'generic' everything (everything 😱) from NALD gets dumped into the JSONB field licence_data_value. The problem is, when the previous team built a feature that needed info only held in licence_data_value, rather than put it into a table, they just dipped into the JSON. And they did this again, and again, and again!

You cannot even load a licence in the UI without having this field properly populated. And that means it'll block our acceptance test data loading solution if we don't put something 'real' into it.

So, this change adds the ugliest bit of JSON you'll ever have clapped eyes on. 🤢🤮

We add it to the helper and by default load it into the field. It doesn't really matter that the data is, it just has to have a structure that won't make the legacy apps go 💥. The data is taken from the water-abstraction-service and its existing acceptance test data loading solution.

https://eaflood.atlassian.net/browse/WATER-3981

The [water-abstraction-service](https://gitub.com/DEFRA/water-abstraction-service) has a mechanism for seeding data for testing that relies on loading in YAML fixture files, sort of. Some content comes from these, but other stuff is hard-coded into the 'loaders'.

Long story short we're going to replace it with something simpler yet more flexible!

Our new solution is going to be based on the hard work we've already invested making our test helpers. We use these to quickly create meaningful records in the DB which we can then write unit tests against. So, why not reuse them to do the same for our acceptance tests!?

One key difference with the unit tests is we are only driving the app through our code. Anything external we mock or stub. The acceptance tests do not have that luxury which means any record we create has to support not only this app but the legacy ones.

The good news is we can do nearly all that with the existing helper data and functionality. The one key bit missing is the `licence_data_value` for a `permit.licence`. In real life, when a licence is imported from NALD into WRLS a number of records get created. A lot of it is duplication, but not _everything_ from NALD is put into tables.

This seems to stem from an early architectural decision that WRLS would be building a generic 'permit' repository. Some top level information is captured in `permit.licence`. But because it needed to be 'generic' everything (_everything_ 😱) from NALD gets dumped into the JSONB field `licence_data_value`. The problem is, when the previous team built a feature that needed info only held in `licence_data_value`, rather than put it into a table, they just dipped into the JSON. And they did this again, and again, and _again_!

You cannot even load a licence in the UI without having this field properly populated. And that means it'll block our acceptance test data loading solution if we don't put something 'real' into it.

So, this change adds the _ugliest_ bit of JSON you'll ever have clapped eyes on. 🤢🤮

We add it to the helper and by default load it into the field. It doesn't really matter that the data is, it just has to have a structure that won't make the legacy apps go 💥. The data is taken from the [water-abstraction-service](https://github.com/DEFRA/water-abstraction-service/blob/main/integration-tests/billing/services/permit-helpers.js) and its existing acceptance test data loading solution.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label May 23, 2024
@Cruikshanks Cruikshanks self-assigned this May 23, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review May 23, 2024 18:52
@Cruikshanks Cruikshanks merged commit 32cf624 into main May 23, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the add-nald-data-to-permit-helper branch May 23, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant