USGS-WiM / whispers

Wildlife Health Information Sharing Partnership event reporting system(WHISPers) v2
Other
2 stars 1 forks source link

business rules for population not working as expected on event details page #1250

Closed JChipault closed 2 years ago

JChipault commented 2 years ago

Describe the bug On create event, the business rule for population is working as expected. If I put in a population of 1 and number dead of 2, I get this warning message: image

So that's good!

However, on the event details page, I can edit an event such that the population number is less than the sick or dead and I am allowed to save that change. image

And then if I go to clear that population number out altogether (so that it becomes null), I get image

Or even if I try to make the population number higher than the sick or dead, I get image

To Reproduce Steps to reproduce the behavior:

  1. Go to any event that has no population number listed for a species
  2. Click on the population field
  3. Enter a number less than the sick or dead tally
  4. Save
  5. Note that you're allowed to save
  6. Go back to the population field
  7. Try to null it out
  8. Get error message
  9. Go back to the population field
  10. Try to make it greater than the sick or dead tally
  11. Get error message

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

BlakeDraper commented 2 years ago

@JChipault Do I understand correctly that we should allow Population to be empty / null, when there is a greater than 0 sick/dead count sum, but not allow an actual number for Population less than the sum of the dead and sick count?

Notes for WIM

Bugs:

  1. POST to /api/locationspecies/{id}/ allows population_count less than dead_count, dead_count_estimated, sick_count, sick_count_estimated

expected behavior: should be prevented per business rules

  1. POST to /api/locationspecies/{id}/ throws error if population_count is null when there is any sum greater than 0 among dead_count, dead_count_estimated, sick_count, sick_count_estimated

expected behavior: should be allowed per business rules (tentative - awaitng NWHC confirmation)

JChipault commented 2 years ago

correct

BlakeDraper commented 2 years ago

Being handled on the backend: https://github.com/USGS-WiM/whispersservices/issues/532