[Cart] Cover remaining scenarios

This commit is contained in:
Grzegorz Sadowski 2024-09-13 14:19:09 +02:00
parent 86a0e91300
commit 834bdc1eae
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
2 changed files with 5 additions and 6 deletions

View file

@ -10,17 +10,17 @@ Feature: Viewing a total quantity of the cart
And the store has a product "Sylius T-Shirt"
And the store has a product "Symfony T-Shirt"
@no-api @todo-ui
@no-api @ui @javascript
Scenario: Viewing a total quantity for 1 product with quantity equals 1
When I add product "PHP T-Shirt" to the cart
Then I should see cart total quantity is 1
@no-api @todo-ui
@no-api @ui @javascript
Scenario: Viewing a total quantity for 1 product with quantity equals 2
When I add 2 products "PHP T-Shirt" to the cart
Then I should see cart total quantity is 2
@no-api @todo-ui
@no-api @ui @javascript
Scenario: Viewing a total quantity for 3 products with various quantities
When I add 2 products "PHP T-Shirt" to the cart
And I add 3 products "Sylius T-Shirt" to the cart

View file

@ -19,10 +19,9 @@ final class CartWidgetElement extends Element implements CartWidgetElementInterf
{
public function getCartTotalQuantity(): int
{
$cartTotal = $this->getElement('cart_button')->getText();
preg_match('/.+,\s(\d+)\s(items|item)/', $cartTotal, $parts);
$quantity = $this->getElement('cart_button')->getText();
return (int) ($parts[1] ?? 0);
return (int) ($quantity ?? 0);
}
protected function getDefinedElements(): array