-
-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Grumpy Cat on shop page (cart with items from a closed OC) #5440
Conversation
…e naming convention and also to make it more specific to completed orders
…rvice naming convention
expect(controller.current_order.distributor).to eq(distributor) | ||
expect(controller.current_order.order_cycle).to eq(order_cycle2) | ||
expect(controller.current_order.line_items).to be_empty | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth adding specs for the cases here?
master...Matt-Yorkley:enterprise-controller-stock
- Line item variants are all in stock
- Line item variants are not all in stock
- A line item's variant has been soft-deleted
- A line item's variant has been removed from the OC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to do this as part of this PR but now that Pau moved it to Test Ready with the two approvals, we can probably get this into the release.
I will work on these specs anyway and create a new PR. I am a bit all over 10's of PRs, I may get to this only on Monday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine as is. The services seem mostly covered with unit tests and we might just need to increase the integration coverage at controller level a little bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
OrderCycle.not_closed.with_distributor(current_distributor) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll go to heaven for this 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or 👿
# frozen_string_literal: false | ||
|
||
# Resets a completed order by building a new order based on the one specified. | ||
# This implements the "continue shopping" feature once an order is completed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty useful 👌
Hi @luisramos0 I've checked this bug and the test cases you describe. In summary, the bug is gone 🎉 The test cases: 1- no other OCs: redirect to shops page, but a flash message does not appear 3- if there are two or more OCs, the red Oc selector will show up - OK (verified this with 3 open OCs as well) If two open OCs have the same products, and one of them is closes before checkout, the products on the cart are not automatically allocated to the OC remaining open. Instead, one is redirected to the /shop page, either with remaining OC open (test case 2) or with the selector showing up in red (case 3). Other tests:
This is ready to go. It think the warning would be nice to have, but I don't think we should block this, for this reason. I can open a separate issue to add this. |
ok, thanks Filipe. Yes, let's open an issue for that missing message. We need to tackle it now. |
Hi @luisramos0 , I checked this PR again, and found a small but relevant imprecision in my notes above (confusion between shops /shops /shop). In test case 1, the user gets redirected to the /shop page, as the pic shows (not confuse with /shops - sorry for that). To see which flash message to expect in these test cases, I had a look in the code. So, should it be this error: a) "The shop you are looking for doesn't exist or is inactive on OFN. Please check other shops." or this info? b) "The order cycle you've selected has just closed. Please try again!" According to the code it should be a), right? I could trigger both these flash messages in my system, but only when visiting or getting redirected to the /shops page. This can happen if the user is in the checkout menu with items in cart, and: a) the shop closes (by changing the package from shop/hub to producer profile) and the user attempts to edit is cart (navigating back with the browser): b) the OC closes on checkout page and the user clicks Boutiques: So, both of these flash messages appear in the /shops# page. In the covered test cases the user rather gets redirected to the /shop page (not /shops or shops), so could this be the reason why I am not observing any the flash messages? Should this be dealt in a separate issue (should I open one)? PS - I found other issues which I don't think are related to this PR (opening issues on these):
|
Hey Filipe, thanks for the detailed update! I understand the problem, the user has a cart and is shopping, the manager closes the OC in the backoffice (there are no other OCs), user loads the shopfront and the cart is empty and the closed shop message displays. The closed shop message is already evidently saying the cause of the empty cart. I think we are ok here. So we would change the test case and leave it as is: I think you did find a bug though: the missing translation of that flash message in b) 👍 |
re that gif... @Matt-Yorkley will be happy to use his new catchphrase about caching issues! If anyone sees that problem again I think we should open an issue for it. |
actually, I can replicate this problem in staging FR. |
I cant replicate this in prod. Maybe a problem with the release? |
I can replicate this in staging FR by clicking around actually 🙈
|
What? Why?
Closes #5340
This issue was caused by landing on a shop page with some variants in the cart from an Order Cycle that was no longer visible to the user (either closed or some new tag rules). The code is now smart enough to verify the order_cycle is not visible and will empty the order.
Thsi was a simple if statement on the enterprise_controller but sometimes we have to make the world a better place, I mean OFN, so I went on an afternoon of refactoring by extracting new OrderCartRest service (and add some unit tests) and renaming 2 other services according to service naming conventions so now we have related services together:
It's when we extract these services (and see how complex they are) that we see how obviously overloaded our controllers are!!! We need more of this in OFN.
What should we test?
Verify the issue is fixed. When OC is closed and there are items in the cart, the cart will be cleared up and the normal redirection rules will apply:
1- no other OCs: flash message and redirect to shops page
2- if there is only one more OC, that one will be selected and displayed
3- if there are two or more OCs, the red Oc selector will show up.
We should also try to break it by changing things in the Backoffice and load different shops pages #variation #exploratorytesting
Note: now I realize I havent tested with 3 OCs.
Release notes
Changelog Category: Fixed
Fixed grumpy cat page (422 http error) when Order Cycle was closed while user was shopping (the broken case was only when there other Order Cycles open for the same shop)