OpenWaterFoundation / owf-app-infomapper-ng

Open Water Foundation InfoMapper web application for menu-driven maps and visualizations, using Angular
GNU General Public License v3.0
1 stars 2 forks source link

Add Angular unit and integration tests #421

Closed Nightsphere closed 2 years ago

Nightsphere commented 2 years ago

Cypress has been used for a few months, and is a great end-to-end testing framework. There is still more that can be added in the future, but covers a great deal of the code as is. It does however, have difficulties testing the more unit/integration side of things, as that's not really what it's made for.

This was deemed necessary to put on the radar because of a multiple feature-breaking bug that occurred in this Common Library issue. The momenjs function was not recognized anymore and needed to be replaced with a more up-to-date datetime package. Cypress did not catch this because it checks if an HTML Element is displayed on the DOM. Even if a Dialog Component fails as it did in this case, the HTML still exists and the test passes.

I have started looking into implementing these smaller scoped tests using the built-in Jasmine & Karma packages. I'm starting here in the InfoMapper because it should theoretically be easier to test than the much more content heavy Common library.

Nightsphere commented 2 years ago

This probably should have been added to the AppDev repo, but nonetheless, tests have been added to the Common package and should catch issues with the new date-fns library being used for manipulating dates, along with other tests. Similar to Cypress, there are plenty more tests that can be added, but seeing as thousands of lines of code from Java were brought in (not to mention the hundreds more that I wrote), it would be quite the time sink to cover it all. I will add tests incrementally in the future.

There's no line that needs to be crossed in order to close this issue, as tests will always need to be made when new code is created, so I will close this issue now.