Closed MRichards99 closed 2 years ago
@MRichards99 I had to use @DefaultValue
as otherwise not specifying the remove param caused errors and thus it wasn't a backwards compatible change. I have deployed a snapshot of this branch on scigateway-preprod and it seems to work fine
@louise-davies just seen the changes you've made, I didn't pick that up while I was testing it, glad you've sorted it
As per https://github.com/ral-facilities/datagateway/issues/1210#issuecomment-1092983096, this PR adds a form parameter called
remove
on the POST request to/cartItems
. This parameter acts as a convenient way to remove items from the cart using POST, rather than DELETE. As such, whenremove
is set to true, it callsdeleteCartItems()
instead of executing the logic fromaddCartItems()
.The logic I've added means that
remove
is false by default; it's not explicitly set to false but the call todeleteCartItems()
only occurs when it is true so ifremove
isn't specified in the request, items will be added to the cart (i.e. the existing behaviour).I edited the tests as needed and checked they pass. I created a new VM (using the Vagrantfile on this repo) to ensure I had the correct testing environment.
There are no specific tests for
addCartItems()
so I haven't added any new ones testing this new behaviour. I did manually test on my own machine adding and removing items from the cart, although that was only a couple at a time (rather than the potentially hundreds that one might experience on a production machine).