[FEAT] Auto select existing user when an account already exists (#4325)
* feat :star: auto select existing user when an account already exists
* lint
* Added test and simplyfied code
---------
Co-authored-by: Lars van de Kerkhof <lars@permanentmarkers.nl>
Adds new functional tests for ShippingAddressView, PaymentDetailsView
and ThankYouView.
It's the second part of #1645.
Notes
* Adds a custom template to be able to test some functionalities of
PaymentDetailsView
* Adds an helper to the CheckoutMixin
* Uses factory-boy factories
* Adds helpers to the CheckoutMixin helper
* Adds plenty of functional tests
* Adds HTML IDs to some forms to be able to easily reference them
from our tests
@maikhoepfel:
This commit is the squashed version of #1645, but it
does not contain the template changes. The unused
ShippingAddressView code was already cherry-picked across in 549decb.
I also fixed some PEP8 issues.
When ordering a basket of free products, or with vouchers giving 100%
discount, we should not collect payment details.
To achieve this, I've added a check to the CheckoutSessionMixin which
calculates the order total and decides whether payment is necessary.
The modified test failed because the OrderCalculator called by
check_payment_is_necessary accessed other properties on the shipping
method. We now just mock a valid shipping method, which still achieves
the aim of ensuring there's only one.
It is now replaced with a checkout pre-condition that applies to every
checkout view. If someone's basket becomes invalid while they are in
checkout, then they will be redirected back to the basket page.