Skip to content

Commit

Permalink
Start fixes on behat scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
marekrzytki committed Jun 5, 2024
1 parent 911dbb3 commit 3fb1727
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 7 deletions.
6 changes: 3 additions & 3 deletions features/creating_new_wishlist.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Feature: Creating a new wishlist
@ui @javascript
Scenario: Creating a new wishlist
When I go to "/wishlists"
When I press "create_new_wishlist_button"
And I fill in "create_new_wishlist_name" with "WishlistName"
Then I press "create_new_wishlist_save"
When I open modal to create new wishlist
And I set new wishlist name "WishlistName"
Then I save new wishlist modal
Then I should wait for one second
Then I should be on "/wishlists"
And I should have 1 wishlists
6 changes: 3 additions & 3 deletions features/editing_name_of_wishlist.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Feature: Editing wishlists name
And the store has a wishlist named "Wishlist1"
When I go to "/wishlists"
Then I should see "Wishlist1"
When I press "wishlist-edit-button-Wishlist1"
And I fill in "edit_wishlist_name" with "Wishlist2"
When I press "edit_wishlist_save"
When I edit "Wishlist1"
And I edit wishlist name "Wishlist2"
When I save edit wishlist modal
Then I go to "/wishlists"
And I should see "Wishlist2"
3 changes: 2 additions & 1 deletion src/Resources/views/WishlistGroup/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
</h1>
</div>
<div class="middle aligned column">
<button id="create_new_wishlist_button" class="ui right floated primary button" data-bb-wishlist-add="add-another-wishlist"
<button id="create_new_wishlist_button" class="ui right floated primary button"
data-bb-wishlist-add="add-another-wishlist"
data-bb-wishlist-add-url="{{ path('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_create_new_wishlist') }}"
data-bb-wishlist-add-title="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_title'|trans }}"
data-bb-wishlist-add-perform="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_perform'|trans }}"
data-bb-wishlist-add-cancel="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_cancel'|trans }}"
data-bb-wishlist-add-error="{{ 'bitbag_sylius_wishlist_plugin.ui.wishlist_modal_add_error'|trans }}"
{{ sylius_test_html_attribute('wishlist-add-new-wishlist') }}
>
{{ 'bitbag_sylius_wishlist_plugin.ui.add_another_wishlist'|trans }}
</button>
Expand Down
48 changes: 48 additions & 0 deletions tests/Behat/Context/Ui/WishlistContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,54 @@ public function iAddThisProductToSelectedWishlist(string $productName, string $w
$this->wishlistPage->addProductToSelectedWishlist($productName, $wishlistName);
}

/**
* @When I open modal to create new wishlist
*/
public function iOpenModalToCreateNewWishlist(): void
{
$this->wishlistIndexPage->addNewWishlist();
}

/**
* @When I set new wishlist name :wishlistName
*/
public function iSetNewWishlistName(string $wishlistName): void
{
$this->wishlistIndexPage->fillNewWishlistName($wishlistName);
}

/**
* @When I save new wishlist modal
*/
public function iSaveNewWishlistModal(): void
{
$this->wishlistIndexPage->saveNewWishlist();
}

/**
* @When I edit wishlist name :wishlistName
*/
public function iEditWishlistName(string $wishlistName): void
{
$this->wishlistIndexPage->fillEditWishlistName($wishlistName);
}

/**
* @When I edit :wishlistName
*/
public function iEditWishlist(string $wishlistName): void
{
$this->wishlistIndexPage->editWishlistName($wishlistName);
}

/**
* @When I save edit wishlist modal
*/
public function iSaveEditWishlistModal(): void
{
$this->wishlistIndexPage->saveEditWishlist();
}

/**
* @Then I should have :productName in selected wishlists :wishlistName
*/
Expand Down
42 changes: 42 additions & 0 deletions tests/Behat/Page/Shop/Wishlist/IndexPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,46 @@ public function getRouteName(): string
{
return 'bitbag_sylius_wishlist_plugin_shop_locale_wishlist_list_wishlists';
}

public function addNewWishlist(): void
{
$this->getElement('add_new_wishlist')->click();
}

public function fillNewWishlistName(string $name): void
{
$this->getElement('new_wishlist_name')->setValue($name);
}

public function saveNewWishlist(): void
{
$this->getElement('save_new_wishlist')->click();
}

public function editWishlistName(string $wishlistName): void
{
$this->getSession()->getPage()->find('css', '#wishlist-edit-button-' . $wishlistName)->click();

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.12.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.12.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter symfony_workflow

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter symfony_workflow

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter symfony_workflow

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.12.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.12.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine

Cannot call method click() on Behat\Mink\Element\NodeElement|null.

Check failure on line 40 in tests/Behat/Page/Shop/Wishlist/IndexPage.php

View workflow job for this annotation

GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter symfony_workflow

Cannot call method click() on Behat\Mink\Element\NodeElement|null.
}

public function fillEditWishlistName(string $newWishlistName): void
{
$this->getElement('edit_wishlist_name_input')->setValue($newWishlistName);
}

public function saveEditWishlist(): void
{
$this->getElement('save_edit_wishlist')->click();
}

protected function getDefinedElements(): array
{
return [
'add_new_wishlist' => '[data-test-wishlist-add-new-wishlist]',
'new_wishlist_name' => '#create_new_wishlist_name',
'save_new_wishlist' => '#create_new_wishlist_save',
'edit_wishlist_name' => '[data-test-wishlist-wishlist-edit]',
'edit_wishlist_name_input' => '#edit_wishlist_name',
'save_edit_wishlist' => '#edit_wishlist_save',
];
}
}
11 changes: 11 additions & 0 deletions tests/Behat/Page/Shop/Wishlist/IndexPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@

interface IndexPageInterface extends SymfonyPageInterface
{
public function addNewWishlist(): void;

public function fillNewWishlistName(string $name): void;

public function saveNewWishlist(): void;

public function editWishlistName(string $wishlistName): void;

public function fillEditWishlistName(string $newWishlistName): void;

public function saveEditWishlist(): void;
}

0 comments on commit 3fb1727

Please sign in to comment.