Skip to content

Commit

Permalink
[StorageList] add tests for share function
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Dec 5, 2022
1 parent 0346cfe commit a73e4c9
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
13 changes: 13 additions & 0 deletions features/ui/frontend/wishlist/share_wishlist_link.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ui @wishlist
Feature: Adding a product to the wishlist
Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store

Scenario: Adding a simple product to the wishlist
Given the site has a product "TShirt" priced at 10000
And the product is active and published and available for store "Austria"
When I add this product to the wishlist
Then I should be on the wishlist summary page
And this wishlist item should have name "TShirt"
And I can see the share wishlist link
13 changes: 13 additions & 0 deletions features/ui/frontend/wishlist/show_shared_wishlist.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ui @wishlist
Feature: Adding a product to the wishlist
Background:
Given the site operates on a store in "Austria"
And the store "Austria" is the default store
And the site has a product "TShirt" priced at 10000
And the product is active and published and available for store "Austria"
When I add this product to the wishlist
Then I should be on the wishlist summary page

Scenario: Show shared Wishlist
Given I visit the share wishlist link
Then this wishlist item should have name "TShirt"
17 changes: 17 additions & 0 deletions src/CoreShop/Behat/Context/Ui/Frontend/WishlistContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,21 @@ public function thisProductShouldHaveName($itemName): void
{
Assert::true($this->wishlistPage->hasItemNamed($itemName));
}
/**
* @Then I can see the share wishlist link
*/
public function iCanSeeTheShareWishlistLink(): void
{
Assert::true($this->wishlistPage->hasShareWishlistLink());
}


/**
* @Given I visit the share wishlist link
*/
public function iVisitTheShareWishlistLink(): void
{
$this->wishlistPage->open();
$this->wishlistPage->tryToOpenWithUri($this->wishlistPage->getShareWishlistLink());
}
}
13 changes: 13 additions & 0 deletions src/CoreShop/Behat/Page/Frontend/WishlistPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,23 @@ private function hasItemWith(string $attributeName, string|array $selector): boo
return false;
}

public function hasShareWishlistLink(): bool
{
$this->getElement('share_wishlist_link');

return true;
}

public function getShareWishlistLink(): string
{
return $this->getElement('share_wishlist_link')->getValue();
}

protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
'wishlist_empty' => '[data-test-wishlist-empty]',
'share_wishlist_link' => '[data-test-share-wishlist-link]',
'wishlist_items' => '[data-test-wishlist-items]',
'delete_button' => '[data-test-wishlist-remove-button="%name%"]',
]);
Expand Down
4 changes: 4 additions & 0 deletions src/CoreShop/Behat/Page/Frontend/WishlistPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ public function isEmpty(): bool;

public function hasItemNamed(string $name): bool;

public function hasShareWishlistLink(): bool;

public function getShareWishlistLink(): string;

public function removeProduct(string $productName): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% if share_link is defined and share_link %}
<div class="input-group mb-3">
<input type="text" class="form-control" readonly="readonly" id="link" value="{{ share_link }}" >
<input {{ coreshop_test_html_attribute('share-wishlist-link') }} type="text" class="form-control" readonly="readonly" id="link" value="{{ share_link }}" >
<div class="input-group-append">
<button class="btn btn-outline-success copy-to-clipboard" data-copied-text="{{ 'coreshop.ui.copied'|trans }}" data-target="link" type="button" id="button-addon2">{{ 'coreshop.ui.copy'|trans }}</button>
</div>
Expand Down

0 comments on commit a73e4c9

Please sign in to comment.