|
887 | 887 |
|
888 | 888 | expect(page).to have_content("This distribution has been marked as being completed!")
|
889 | 889 | end
|
| 890 | + |
| 891 | + it "Double clicking distribution complete does not result in the distribution attemping to be completed twice" do |
| 892 | + visit new_distribution_path |
| 893 | + item = View::Inventory.new(organization.id).items_for_location(storage_location.id).first.db_item |
| 894 | + TestInventory.create_inventory(organization, |
| 895 | + { |
| 896 | + storage_location.id => { item.id => 20 } |
| 897 | + }) |
| 898 | + |
| 899 | + select "Test Partner", from: "Partner" |
| 900 | + select "Test Storage Location", from: "From storage location" |
| 901 | + choose "Delivery" |
| 902 | + select item.name, from: "distribution_line_items_attributes_0_item_id" |
| 903 | + fill_in "distribution_line_items_attributes_0_quantity", with: 15 |
| 904 | + |
| 905 | + click_button "Save" |
| 906 | + |
| 907 | + within "#distributionConfirmationModal" do |
| 908 | + click_button "Yes, it's correct" |
| 909 | + end |
| 910 | + |
| 911 | + # Make sure the button is there before trying to double click it |
| 912 | + expect(page.find('a.btn.btn-success.btn-md[href*="/picked_up"]')).to have_content("Distribution Complete") |
| 913 | + |
| 914 | + # Double click on the Distribution complete button |
| 915 | + ferrum_double_click('a.btn.btn-success.btn-md[href*="/picked_up"]') |
| 916 | + |
| 917 | + # Capybara will be quick to determine that a screen doesn't have content. |
| 918 | + # Make some positive assertions that only appears on the new screen to make |
| 919 | + # sure it's loaded before asserting something isn't there. |
| 920 | + expect(page).not_to have_content("Distribution Complete") |
| 921 | + expect(page).to have_content("Complete") |
| 922 | + |
| 923 | + # If it tries to mark the distribution as completed twice, the second time |
| 924 | + # will fail (the distribution is already complete) and show this error |
| 925 | + expect(page).not_to have_content("Sorry, we encountered an error when trying to mark this distribution as being completed") |
| 926 | + end |
890 | 927 | end
|
0 commit comments