rubyforgood / human-essentials

Human Essentials is an inventory management system for diaper, incontinence, and period-supply banks. It supports them in distributing to partners, tracking inventory, and reporting stats and analytics.
https://humanessentials.app
MIT License
471 stars 498 forks source link

Product Drives -- allow filtration by category #4033

Closed cielf closed 9 months ago

cielf commented 10 months ago

Summary

Allow filtration of product drives by item category

Why?

Provides more useful presentation of information to the banks

Details

Add item category to the possible filters for product drives When filtered on item category, 1/ Only those product drives that produced items in that category will be shown 2/ Any totals of items, values, etc will only count the item in the chosen category

What view, exactly are we talking about

Click on Product drives | All Product Drives in the left-hand menu

Original request info

Requested along with product drive export in support ticket by Judi M 20220808

Criteria for completion

PhantomSean commented 10 months ago

Hey @cielf I'd be happy to try my hand at this one

dorner commented 10 months ago

You got it!

PhantomSean commented 10 months ago

Hey @dorner working on this now and making my way through adding/adjusting tests for this functionality. I've noticed that there is 3 test cases from distribution_system_spec.rb that are failing independently of my changes. Have these been raised as their own issue? I've run the tests a number of times and its appears to be flaky test cases as they can occasionally pass on some runs.

Failures:

  1) Distributions When creating a distribution from a donation when editing that distribution User creates a distribution from a donation then edits it
     Failure/Error: click_on "Distributions", match: :first

     Ferrum::JavaScriptError:
       TypeError: Cannot read properties of undefined (reading 'response')
           at HTMLDocument.<anonymous> (http://127.0.0.1:36529/assets/controllers/turbo_controller-fccb6961e984a4e30ac5da2e1cf185bbfb9d9e8677a0bf2e284ec349e7b0db17.js:16:47)
           at S (http://127.0.0.1:36529/assets/turbo.min-a07af75140e849147b6b70f34d0918d27f2eff08dd6d957cd3c7211649928372.js:1:5013)
           at B.requestFinished (http://127.0.0.1:36529/assets/turbo.min-a07af75140e849147b6b70f34d0918d27f2eff08dd6d957cd3c7211649928372.js:1:13793)
           at H.perform (http://127.0.0.1:36529/assets/turbo.min-a07af75140e849147b6b70f34d0918d27f2eff08dd6d957cd3c7211649928372.js:1:7612)

     [Screenshot Image]: /home/sean/human-essentials/tmp/screenshots/failures_r_spec_example_groups_distributions_2_when_creating_a_distribution_from_a_donation_when_editing_that_distribution_user_creates_a_distribution_from_a_donation_then_edits_it_75.png

     # ./spec/system/distribution_system_spec.rb:381:in `block (4 levels) in <top (required)>'

  2) Distributions When creating a distribution from a donation when editing that distribution User creates duplicate line items
     Failure/Error: click_on "Edit", match: :first

     Capybara::ElementNotFound:
       Unable to find link or button "Edit"

     [Screenshot Image]: /home/sean/human-essentials/tmp/screenshots/failures_r_spec_example_groups_distributions_2_when_creating_a_distribution_from_a_donation_when_editing_that_distribution_user_creates_duplicate_line_items_872.png

     # ./spec/system/distribution_system_spec.rb:382:in `block (4 levels) in <top (required)>'

  3) Distributions When creating a distribution from a donation when editing that distribution User creates a distribution from a donation then tries to make the quantity too big
     Failure/Error: click_on "Edit", match: :first

     Capybara::ElementNotFound:
       Unable to find link or button "Edit"

     [Screenshot Image]: /home/sean/human-essentials/tmp/screenshots/failures_r_spec_example_groups_distributions_2_when_creating_a_distribution_from_a_donation_when_editing_that_distribution_user_creates_a_distribution_from_a_donation_then_tries_to_make_the_quantity_too_big_762.png

     # ./spec/system/distribution_system_spec.rb:382:in `block (4 levels) in <top (required)>'

Finished in 36 minutes 13 seconds (files took 15.89 seconds to load)
1989 examples, 3 failures, 2 pending

Failed examples:

rspec ./spec/system/distribution_system_spec.rb:386 # Distributions When creating a distribution from a donation when editing that distribution User creates a distribution from a donation then edits it
rspec ./spec/system/distribution_system_spec.rb:409 # Distributions When creating a distribution from a donation when editing that distribution User creates duplicate line items
rspec ./spec/system/distribution_system_spec.rb:395 # Distributions When creating a distribution from a donation when editing that distribution User creates a distribution from a donation then tries to make the quantity too big

Randomized with seed 58545

Coverage report generated for RSpec to /human-essentials/coverage. 5797 / 6214 LOC (93.29%) covered.

I'm happy to take a look at them as I'm working on my own test cases but not sure if you want to include them in the pull request for this issue or have them separated out to another issue.

dorner commented 10 months ago

cc: @awwaiid - can you take a look here?

@PhantomSean it's weird because we haven't seen failures with these tests on main. Do they happen "most of the time"?

PhantomSean commented 10 months ago

cc: @awwaiid - can you take a look here?

@PhantomSean it's weird because we haven't seen failures with these tests on main. Do they happen "most of the time"?

They were happening "most of the time" the other day when I first noticed the issue. I've just run bundle exec rspec 10 times and hit these failures on the 1st and 3rd run. All other runs passed so maybe it's not happening as often as I first thought.

I've been hitting the failures using https://github.com/PhantomSean/human-essentials/tree/main which I believe is currently up to date with main.

dorner commented 10 months ago

@PhantomSean let's just get the PR up and see what happens on CI.

PhantomSean commented 9 months ago

Hey @dorner / @awwaiid,

Have the pull request created and it is failing on the following system rspec test

rspec ./spec/system/distribution_system_spec.rb:108 # Distributions When creating a new distribution manually when the quantity is lower than the on hand recommended quantity should display an alert

Would one of you be able to take a quick look at my code changes? As far as I can see, the changes I've made shouldn't be affecting anything with the distributions or their pages.

dorner commented 9 months ago

Yeah this seems to be a flaky test. Not sure why it's happening, but it's unrelated to your changes.

awwaiid commented 9 months ago

Yes -- I have a fix at a6371f79ade7662e2b433c8b2add380c1289a43d over in another branch! Cuprite is faster than javascript, and one of the dropdowns is dynamically generated in that spec.