-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
549 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,52 @@ | ||
@bundled_product | ||
Feature: Creating a product in store which is a bundle of other products | ||
I want to be able to add bundled product to cart | ||
As an Administrator | ||
I want to be able to add bundled product to cart | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am logged in as an administrator | ||
And the store has a product "Jack Daniels Gentleman" priced at "$10.00" | ||
And the store has a product "Johny Walker Black" priced at "$10.00" | ||
And the store has a product "Jim Beam Double Oak" priced at "$10.00" | ||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am logged in as an administrator | ||
And the store has a product "Jack Daniels Gentleman" priced at "$10.00" | ||
And the store has a product "Johny Walker Black" priced at "$10.00" | ||
And the store has a product "Jim Beam Double Oak" priced at "$10.00" | ||
|
||
@ui @javascript | ||
Scenario: Creating a bundled product | ||
When I want to create a new bundled product | ||
And I specify its code as "WHISKEY_PACK" | ||
And I name it "Whiskey double pack" in "English (United States)" | ||
And I set its slug to "whiskey-double-pack" in "English (United States)" | ||
And I set its price to "$10.00" for "United States" channel | ||
And I set its original price to "$20.00" for "United States" channel | ||
And I add product "Johny Walker Black" and "Jack Daniels Gentleman" to the bundle | ||
And I add it | ||
Then I should be notified that it has been successfully created | ||
@ui @javascript | ||
Scenario: Creating a bundled product | ||
When I want to create a new bundled product | ||
And I specify its code as "WHISKEY_PACK" | ||
And I name it "Whiskey double pack" in "English (United States)" | ||
And I set its slug to "whiskey-double-pack" in "English (United States)" | ||
And I set its price to "$10.00" for "United States" channel | ||
And I set its original price to "$20.00" for "United States" channel | ||
And I add product "Johny Walker Black" and "Jack Daniels Gentleman" to the bundle | ||
And I add it | ||
Then I should be notified that it has been successfully created | ||
|
||
@ui @javascript | ||
Scenario: Creating a bundled product with more products | ||
When I want to create a new bundled product | ||
And I specify its code as "WHISKEY_BIG_PACK" | ||
And I name it "Whiskey triple pack" in "English (United States)" | ||
And I set its slug to "whiskey-triple-pack" in "English (United States)" | ||
And I set its price to "$10.00" for "United States" channel | ||
And I set its original price to "$20.00" for "United States" channel | ||
And I add product "Johny Walker Black" and "Jack Daniels Gentleman" and "Jim Beam Double Oak" to the bundle | ||
And I add it | ||
Then I should be notified that it has been successfully created | ||
@ui @javascript | ||
Scenario: Creating a bundled product with more products | ||
When I want to create a new bundled product | ||
And I specify its code as "WHISKEY_BIG_PACK" | ||
And I name it "Whiskey triple pack" in "English (United States)" | ||
And I set its slug to "whiskey-triple-pack" in "English (United States)" | ||
And I set its price to "$10.00" for "United States" channel | ||
And I set its original price to "$20.00" for "United States" channel | ||
And I add product "Johny Walker Black" and "Jack Daniels Gentleman" and "Jim Beam Double Oak" to the bundle | ||
And I add it | ||
Then I should be notified that it has been successfully created | ||
And there should be a "WHISKEY_BIG_PACK" bundle containing "Johny Walker Black" with quantity 1 | ||
And there should be a "WHISKEY_BIG_PACK" bundle containing "Jack Daniels Gentleman" with quantity 1 | ||
And there should be a "WHISKEY_BIG_PACK" bundle containing "Jim Beam Double Oak" with quantity 1 | ||
|
||
@ui @javascript | ||
Scenario: Creating a bundled product with higher quantity | ||
When I want to create a new bundled product | ||
And I specify its code as "WHISKEY_BIG_PACK" | ||
And I name it "Whiskey triple pack" in "English (United States)" | ||
And I set its slug to "whiskey-triple-pack" in "English (United States)" | ||
And I set its price to "$10.00" for "United States" channel | ||
And I set its original price to "$20.00" for "United States" channel | ||
And I add product "Jim Beam Double Oak" with quantity 5 and "Jack Daniels Gentleman" with quantity 2 to the bundle | ||
And I add it | ||
Then I should be notified that it has been successfully created | ||
And there should be a "WHISKEY_BIG_PACK" bundle containing "Jim Beam Double Oak" with quantity 5 | ||
And there should be a "WHISKEY_BIG_PACK" bundle containing "Jack Daniels Gentleman" with quantity 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,66 @@ | ||
@bundled_product | ||
Feature: Having a product in store which is a bundle of other products | ||
I want to be able to add bundled product to cart | ||
As a Customer | ||
I want to be able to order bundled products | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am a logged in customer | ||
And the store ships everywhere for Free | ||
And the store allows paying Offline | ||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has "VAT" tax rate of 50% for "Coke" within the "US" zone | ||
And I am a logged in customer | ||
And the store ships everywhere for Free | ||
And the store allows paying Offline | ||
And the store has a product "Jim Beam" priced at "$10.00" | ||
And the store has a product "Jim Beam Double Oak" priced at "$10.00" | ||
And the store has a product "Coca-Cola" priced at "$5.00" | ||
And the store has bundled product "Jim Beam double pack" priced at "$18.00" which contains "Jim Beam" and "Jim Beam Double Oak" | ||
And the store has bundled product "Jim Beam&Coke" priced at "$12.00" which contains "Jim Beam" and "Coca-Cola" | ||
And it belongs to "Coke" tax category | ||
And all store products appear under a main taxonomy | ||
|
||
@ui | ||
Scenario: Adding a product bundle to the cart | ||
Given the store has a product "Jack Daniels Gentleman" priced at "$10.00" | ||
And the store has a product "Johny Walker Black" priced at "$10.00" | ||
And the store has bundled product "Whiskey double pack" priced at "$18.00" which contains "Jack Daniels Gentleman" and "Johny Walker Black" | ||
And all store products appear under a main taxonomy | ||
Then I added product "Whiskey double pack" to the cart | ||
And I should be on my cart summary page | ||
And there should be one item in my cart | ||
@ui | ||
Scenario: Adding product bundles to cart | ||
When I added product "Jim Beam double pack" to the cart | ||
And I change product "Jim Beam double pack" quantity to 5 in my cart | ||
Then I should see "Jim Beam double pack" with quantity 5 in my cart | ||
And my cart total should be "$90.00" | ||
|
||
@ui | ||
Scenario: Adding a few product bundles to the cart | ||
Given the store has a product "Jim Beam" priced at "$10.00" | ||
And the store has a product "Jim Beam Double Oak" priced at "$10.00" | ||
And the store has bundled product "Jim Beam double pack" priced at "$18.00" which contains "Jim Beam" and "Jim Beam Double Oak" | ||
And all store products appear under a main taxonomy | ||
Then I added product "Jim Beam double pack" to the cart | ||
And I change product "Jim Beam double pack" quantity to 5 in my cart | ||
And I should see "Jim Beam double pack" with quantity 5 in my cart | ||
@ui | ||
Scenario: Placing an order for bundled products | ||
Given I have product "Jim Beam double pack" in the cart | ||
And I have product "Jim Beam&Coke" in the cart | ||
And my cart total should be "$30.00" | ||
And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" | ||
And I proceed with "Free" shipping method and "Offline" payment | ||
When I confirm my order | ||
Then I should see the thank you page | ||
|
||
@ui | ||
Scenario: Placing an order for a bundled product | ||
Given the store has a product "Jim Beam" priced at "$10.00" | ||
And the store has a product "Jim Beam Double Oak" priced at "$10.00" | ||
And the store has bundled product "Jim Beam double pack" priced at "$18.00" which contains "Jim Beam" and "Jim Beam Double Oak" | ||
Given I have product "Jim Beam double pack" in the cart | ||
And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" | ||
And I proceed with "Free" shipping method and "Offline" payment | ||
And I confirm my order | ||
Then I should see the thank you page | ||
@ui | ||
Scenario: Placing an order for bundled products with promotion applied | ||
Given there is a promotion "Holiday promotion" | ||
And this promotion gives "$1.00" off on every product with minimum price at "$15.00" | ||
And I have product "Jim Beam double pack" in the cart | ||
And I have product "Jim Beam&Coke" in the cart | ||
And my cart total should be "$29.00" | ||
And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" | ||
And I proceed with "Free" shipping method and "Offline" payment | ||
When I confirm my order | ||
Then I should see the thank you page | ||
|
||
@ui | ||
Scenario: Placing an order for bundled products with tax applied | ||
Given I have product "Jim Beam double pack" in the cart | ||
And I have product "Jim Beam&Coke" in the cart | ||
And I have product "Coca-Cola" in the cart | ||
When I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" | ||
And I proceed with "Free" shipping method and "Offline" payment | ||
Then my cart total should be "$41.00" | ||
And my cart taxes should be "$6.00" | ||
|
||
@api | ||
Scenario: Adding product bundles to cart with API | ||
When I pick up my cart | ||
And I add bundle "Jim Beam&Coke" with quantity 5 to my cart | ||
And I add bundle "Jim Beam&Coke" with quantity 5 to my cart | ||
Then I should have bundle "Jim Beam&Coke" with quantity 10 in my cart | ||
And I should have product "Jim Beam" in bundled items | ||
And I should have product "Coca-Cola" in bundled items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@bundled_product | ||
Feature: Reviewing products from ordered bundle | ||
As a Customer | ||
I want to be able to see products in the bundle I ordered | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store ships everywhere for Free | ||
And the store allows paying Offline | ||
And the store has a product "Jim Beam" priced at "$10.00" | ||
And the store has a product "Coca-Cola" priced at "$5.00" | ||
And the store has bundled product "Jim Beam&Coke" priced at "$12.00" which contains "Jim Beam" and "Coca-Cola" | ||
And all store products appear under a main taxonomy | ||
And I am a logged in customer with name "Bundle Customer" | ||
|
||
@ui @shop | ||
Scenario: Viewing bundled products in cart | ||
Given I have product "Jim Beam&Coke" in the cart | ||
When I see the summary of my cart | ||
Then there should be one item in my cart | ||
And this item should have name "Jim Beam&Coke" | ||
And there should be bundled products listed | ||
And the list should contain "Jim Beam" | ||
And the list should contain "Coca-Cola" | ||
|
||
@ui @shop | ||
Scenario: Viewing bundled products in order history | ||
Given there is a customer "[email protected]" that placed an order "#1" later | ||
And the customer bought a single bundle "Jim Beam&Coke" | ||
And I addressed it to "Ankh Morpork", "Frost Alley", "90210" "Los Angeles" in the "United States" | ||
And for the billing address of "Ankh Morpork" in the "Frost Alley", "90210" "Los Angeles", "United States" | ||
And I chose "Free" shipping method with "Offline" payment | ||
When I view the summary of my order "#1" | ||
Then it should have the number "#1" | ||
And there should be bundled products listed in order details | ||
And the list should contain "Jim Beam" in order details | ||
And the list should contain "Coca-Cola" in order details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\BitBag\SyliusProductBundlePlugin\Behat\Context\Api; | ||
|
||
use Behat\Behat\Context\Context; | ||
use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface; | ||
use Sylius\Behat\Client\ApiClientInterface; | ||
use Sylius\Behat\Client\RequestFactoryInterface; | ||
use Sylius\Behat\Client\ResponseCheckerInterface; | ||
use Sylius\Behat\Context\Api\Resources; | ||
use Sylius\Behat\Service\SharedStorageInterface; | ||
use Symfony\Component\HttpFoundation\Request as HttpRequest; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class ProductBundleContext implements Context | ||
{ | ||
public function __construct( | ||
private readonly SharedStorageInterface $sharedStorage, | ||
private readonly ApiClientInterface $client, | ||
private readonly RequestFactoryInterface $requestFactory, | ||
private readonly ResponseCheckerInterface $responseChecker, | ||
) { | ||
} | ||
|
||
/** | ||
* @When I add bundle :product to my cart | ||
* @When I add bundle :product with quantity :quantity to my cart | ||
*/ | ||
public function iAddProductBundleToMyCart(ProductInterface $product, int $quantity = 1): void | ||
{ | ||
$request = $this->requestFactory->customItemAction( | ||
'shop', | ||
Resources::ORDERS, | ||
$this->sharedStorage->get('cart_token'), | ||
HttpRequest::METHOD_PATCH, | ||
'product-bundle', | ||
); | ||
$request->updateContent([ | ||
'productCode' => $product->getCode(), | ||
'quantity' => $quantity, | ||
]); | ||
|
||
$this->client->executeCustomRequest($request); | ||
} | ||
|
||
/** | ||
* @When I should have bundle :product with quantity :quantity in my cart | ||
*/ | ||
public function iShouldHaveBundleWithQuantityInMyCart(ProductInterface $product, int $quantity): void | ||
{ | ||
$response = $this->client->show(Resources::ORDERS, $this->sharedStorage->get('cart_token')); | ||
|
||
$item = $this->responseChecker->getValue($response, 'items')[0]; | ||
Assert::eq($item['productName'], $product->getName()); | ||
Assert::eq($item['quantity'], $quantity); | ||
} | ||
|
||
/** | ||
* @When I should have product :product in bundled items | ||
*/ | ||
public function iShouldHaveProductInBundledItems(ProductInterface $product): void | ||
{ | ||
$response = $this->client->show(Resources::ORDERS, $this->sharedStorage->get('cart_token')); | ||
|
||
$productBundleOrderItems = $this->responseChecker->getValue($response, 'items')[0]['productBundleOrderItems']; | ||
foreach ($productBundleOrderItems as $item) { | ||
if ($item['productVariant']['code'] === $product->getCode()) { | ||
return; | ||
} | ||
} | ||
|
||
throw new \InvalidArgumentException('Product not found in bundled items'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.