From 3f9d64cfb5e5669db974d5d90575a4d2698a5152 Mon Sep 17 00:00:00 2001 From: arti0090 Date: Fri, 21 May 2021 12:34:40 +0200 Subject: [PATCH 1/4] [API] Add itemsTotal field to order resource --- ...ng_detailed_information_about_cart.feature | 21 +++++++++++++++++++ .../seeing_order_items_in_cart.feature | 15 ------------- .../Behat/Context/Api/Shop/CartContext.php | 11 ++++++++++ .../Resources/config/api_resources/Order.xml | 1 + .../Resources/config/serialization/Order.xml | 7 +++++++ 5 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 features/cart/shopping_cart/seeing_detailed_information_about_cart.feature delete mode 100644 features/cart/shopping_cart/seeing_order_items_in_cart.feature diff --git a/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature b/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature new file mode 100644 index 00000000000..3dbd13bc385 --- /dev/null +++ b/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature @@ -0,0 +1,21 @@ +@shopping_cart +Feature: Seeing detailed information of cart + In order to see detailed information of my cart + As a Visitor + I want to be able to see those information of my cart + + Background: + Given the store operates on a single channel in "United States" + And the store has a product "T-shirt banana" priced at "$12.54" + + @api + Scenario: Viewing items of my cart + When I add 5 of them to my cart + And I check items in my cart + Then my cart should have 5 items of product "T-shirt banana" + + @api + Scenario: Viewing items total of my cart + Given I pick up my cart + And I check details of my cart + Then my cart should have 0 items total diff --git a/features/cart/shopping_cart/seeing_order_items_in_cart.feature b/features/cart/shopping_cart/seeing_order_items_in_cart.feature deleted file mode 100644 index b1d78130e29..00000000000 --- a/features/cart/shopping_cart/seeing_order_items_in_cart.feature +++ /dev/null @@ -1,15 +0,0 @@ -@shopping_cart -Feature: Seeing order items in cart - In order to see details about my order items - As a Visitor - I want to be able to see my cart order items - - Background: - Given the store operates on a single channel in "United States" - And the store has a product "T-shirt banana" priced at "$12.54" - - @api - Scenario: Viewing content of my cart - When I add 5 of them to my cart - And I check items in my cart - Then my cart should have 5 items of product "T-shirt banana" diff --git a/src/Sylius/Behat/Context/Api/Shop/CartContext.php b/src/Sylius/Behat/Context/Api/Shop/CartContext.php index 36f50ced755..80a71b97986 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CartContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CartContext.php @@ -526,6 +526,17 @@ public function iCheckItemsOfMyCart(string $tokenValue): void $this->cartsClient->executeCustomRequest($request); } + /** + * @Then /^my cart should have (\d+) items total$/ + */ + public function myCartShouldHaveItemsTotal(int $total): void + { + Assert::same( + $this->responseChecker->getValue($this->cartsClient->getLastResponse(), 'shippingTotal'), + $total + ); + } + /** * @Then /^my cart should have (\d+) items of (product "([^"]+)")$/ */ diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml index 87f919140c7..1d08143b3e2 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml @@ -410,6 +410,7 @@ + diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml index 7a66f46e5f9..52295579237 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml @@ -102,6 +102,13 @@ admin:order:read + + admin:order:read + shop:cart:read + shop:order:read + shop:order:account:read + + admin:order:read shop:cart:read From 41cca0a8bc102f4582aca143637d75e9957dac1f Mon Sep 17 00:00:00 2001 From: arti0090 Date: Fri, 21 May 2021 14:48:41 +0200 Subject: [PATCH 2/4] Changes to scenarios --- .../seeing_detailed_information_about_cart.feature | 5 +++-- src/Sylius/Behat/Context/Api/Shop/CartContext.php | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature b/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature index 3dbd13bc385..8c92ad8585c 100644 --- a/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature +++ b/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature @@ -16,6 +16,7 @@ Feature: Seeing detailed information of cart @api Scenario: Viewing items total of my cart - Given I pick up my cart + When I add 5 of them to my cart And I check details of my cart - Then my cart should have 0 items total + Then my cart should have "$62.70" items total + diff --git a/src/Sylius/Behat/Context/Api/Shop/CartContext.php b/src/Sylius/Behat/Context/Api/Shop/CartContext.php index 80a71b97986..cb3ce9c7615 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CartContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CartContext.php @@ -527,13 +527,13 @@ public function iCheckItemsOfMyCart(string $tokenValue): void } /** - * @Then /^my cart should have (\d+) items total$/ + * @Then /^my cart should have ("[^"]+") items total$/ */ - public function myCartShouldHaveItemsTotal(int $total): void + public function myCartShouldHaveItemsTotal(int $itemsTotal): void { Assert::same( - $this->responseChecker->getValue($this->cartsClient->getLastResponse(), 'shippingTotal'), - $total + $this->responseChecker->getValue($this->cartsClient->getLastResponse(), 'itemsTotal'), + $itemsTotal ); } From 0e88a33b238a211fe765cd1d1079637ca1c5bd59 Mon Sep 17 00:00:00 2001 From: arti0090 Date: Mon, 24 May 2021 12:53:37 +0200 Subject: [PATCH 3/4] Changes to scenario and serialization --- .../seeing_detailed_information_about_cart.feature | 7 +++---- src/Sylius/Behat/Context/Api/Shop/CartContext.php | 1 + .../ApiBundle/Resources/config/api_resources/Order.xml | 6 ++++++ .../ApiBundle/Resources/config/serialization/Order.xml | 1 - 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature b/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature index 8c92ad8585c..d7110d4c50a 100644 --- a/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature +++ b/features/cart/shopping_cart/seeing_detailed_information_about_cart.feature @@ -1,8 +1,8 @@ @shopping_cart Feature: Seeing detailed information of cart - In order to see detailed information of my cart + In order to know more about status of my cart As a Visitor - I want to be able to see those information of my cart + I want to be able to see detailed information of my cart Background: Given the store operates on a single channel in "United States" @@ -12,11 +12,10 @@ Feature: Seeing detailed information of cart Scenario: Viewing items of my cart When I add 5 of them to my cart And I check items in my cart - Then my cart should have 5 items of product "T-shirt banana" + Then my cart should have quantity of 5 items of product "T-shirt banana" @api Scenario: Viewing items total of my cart When I add 5 of them to my cart And I check details of my cart Then my cart should have "$62.70" items total - diff --git a/src/Sylius/Behat/Context/Api/Shop/CartContext.php b/src/Sylius/Behat/Context/Api/Shop/CartContext.php index cb3ce9c7615..3d76cdd176f 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CartContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CartContext.php @@ -539,6 +539,7 @@ public function myCartShouldHaveItemsTotal(int $itemsTotal): void /** * @Then /^my cart should have (\d+) items of (product "([^"]+)")$/ + * @Then /^my cart should have quantity of (\d+) items of (product "([^"]+)")$/ */ public function myCartShouldHaveItems(int $quantity, ProductInterface $product): void { diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml index 1d08143b3e2..ec1f63ebc6f 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Order.xml @@ -62,6 +62,9 @@ GET /shop/orders/{tokenValue} + + shop:cart:read + @@ -70,6 +73,9 @@ Deletes cart + + shop:order:read + diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml index 52295579237..8f1e816b26b 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml @@ -103,7 +103,6 @@ - admin:order:read shop:cart:read shop:order:read shop:order:account:read From f41bf8487872527e72dccbfca0848948ada84ff6 Mon Sep 17 00:00:00 2001 From: arti0090 Date: Mon, 24 May 2021 15:43:22 +0200 Subject: [PATCH 4/4] Fixes related to missing serialization group --- src/Sylius/Behat/Context/Api/Shop/OrderContext.php | 2 +- .../Bundle/ApiBundle/Resources/config/serialization/Order.xml | 2 ++ .../ApiBundle/Resources/config/serialization/OrderItem.xml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Sylius/Behat/Context/Api/Shop/OrderContext.php b/src/Sylius/Behat/Context/Api/Shop/OrderContext.php index 7aebbb9177a..3b4af992f12 100644 --- a/src/Sylius/Behat/Context/Api/Shop/OrderContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/OrderContext.php @@ -287,7 +287,7 @@ public function iShouldHaveChosenPaymentMethodForMyOrder(PaymentMethodInterface ->getValue($this->client->show($this->sharedStorage->get('cart_token')), 'payments')[0] ; - Assert::same($this->iriConverter->getIriFromItem($paymentMethod), $payment['method']); + Assert::same($this->iriConverter->getIriFromItem($paymentMethod), $payment['method']['@id']); } /** diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml index 8f1e816b26b..33b19d5aa78 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Order.xml @@ -67,10 +67,12 @@ admin:order:read + shop:cart:read admin:order:read + shop:cart:read diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/OrderItem.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/OrderItem.xml index b2f197206ed..8f365cb6364 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/OrderItem.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/OrderItem.xml @@ -85,6 +85,7 @@ admin:order:read admin:order_item:read + shop:cart:read shop:order_item:read