Hey Brock,
Could you please review the patch in #22. I have added some notes below.
-
+++ b/modules/dc_ajax_add_cart_popup/src/EventSubscriber/AjaxAddToCartPopupSubscriber.php @@ -0,0 +1,98 @@ + if (!$this->purchasedEntity) {
This
if
is covered inAjaxAddCartPopupTest::testAjaxPopup()
that you wrote. We are good here. -
+++ b/modules/dc_ajax_add_cart_popup/tests/src/FunctionalJavascript/AddCartPopupAjaxResponseTest.php @@ -0,0 +1,45 @@ + public function testPopupOnAjaxResponse() {
I have added this test which is going to check that the popup appears only if a product is added to cart via ajax, i.e. this
if
condition:if (!$response instanceof AjaxResponse) {
It also had the check whether the product is added to cart. So that means, it checks that product is successfuly aded to cart, while the popup does not appears.
-
+++ b/modules/dc_ajax_add_cart_popup/tests/src/FunctionalJavascript/AjaxAddCartPopupTest.php @@ -0,0 +1,59 @@ + // Confirm that the initial add to cart submit works. + $this->cart = Order::load($this->cart->id()); + $order_items = $this->cart->getItems(); + $this->assertOrderItemInOrder($this->variation, $order_items[0]);
In #17.4 I asked you to remove this. But later I realized that it should be here. Because it checks
AjaxAddToCartPopupSubscriber
'sif (!$this->purchasedEntity)
. i.e. popup appears ONLY when an item is added to cart. -
+++ b/modules/dc_ajax_add_cart_popup/tests/src/FunctionalJavascript/AjaxAddCartPopupTest.php @@ -0,0 +1,59 @@ + $this->assertSession()->pageTextContains("The item has been added to your cart.", 'Popup not found.');
In #17.5 I asked for a backend check, i.e. whether
OpenModalDialogCommand
is indeed present. That check is going to be tricky here. Mink does not keeps track of the type of response.I also compared this with Commerce core. They are doing something similar to check event subscribers.
Lets keep it this way. Simple. Later we can add a backend check test if there is a problem.