Skip to content

fix: Fix "restricted shipping" validation bug

stephen requested to merge fix-restricted-shipping-bug into main

One of the lesser-seen features of the donation form is its capability to detect when a country has been selected from the drop-down list which is ineligible for shipping (due in this case to active geopolitical conflict). A custom message politely informs the user that their selected country cannot cannot be shipped to, and the front-end validation infrastructure prevents the donation from being processed. However, when those two countries are not selected, nothing is shown at all to indicate that there is a shipping blocklist.

Perhaps due to its subtle nature, this feature slipped under a few radars when the testing and go-live plan was being carried out, and while other forms of validation were tested heavily, the "quiet invalidation" of this feature, due to its custom implementation - it doesn't invalidate the form field, but it does make the form itself invalid to submit - was much less tested, even though its bespoke nature means that other forms of form testing would not cover it. It also escaped notice when the backend validation was implemented; while we test the country field for existence in the Django donate form validation, we do not explicitly test against a list of blocklisted countries.

As a result, it appears that the "restricted shipping" validation feature was underimplemented at time of launch; it has not been properly validated in all cases as a disqualifying condition for form submission, and it has not been properly testing the form field value in some other cases. This MR addresses all of this:

  • The country field is now properly validated on both the front and the back end. It retains the design direction of having the country selection action itself not trigger a standard form validation state, instead displaying the custom purplish message.
  • When the country field is set to a country with restricted shipping and the user submits the form anyway, displayPaymentError() is used to display a separate validation error immediately above the payment area, informing the user of the specific problem.
  • Unit testing has been written against the backend restricted-shipping validation.

Merge request reports