Skip to content

Commit

Permalink
OP-321: Behat tests update
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Jun 26, 2024
1 parent 9fc635b commit 36de438
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions features/admin/adding_block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Feature: Adding blocks
Scenario: Adding block
When I go to the create block page
And I fill the code with "store_description"
And I fill the name with "Store Description"
And I add it
Then I should be notified that the block has been created

Expand All @@ -20,6 +21,7 @@ Feature: Adding blocks
Given there are existing collections named "Blog" and "Homepage"
When I go to the create block page
And I fill the code with "intro"
And I fill the name with "Intro"
And I add "Blog" and "Homepage" collections to it
And I add it
Then I should be notified that the block has been created
Expand Down
2 changes: 2 additions & 0 deletions features/admin/managing_blocks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ Feature: Managing cms blocks
Scenario: Updating block
Given there is a block with "store_phone_number" code
When I go to the update "store_phone_number" block page
And I fill the name with "Store phone number" if the name field is empty
And I update it
Then I should be notified that the block has been successfully updated

@ui
Scenario: Disabling block
Given there is an existing block with "bitbag_quote" code
When I go to the update "bitbag_quote" block page
And I fill the name with "BitBag quote" if the name field is empty
And I disable it
And I update it
Then I should be notified that the block has been successfully updated
Expand Down
8 changes: 8 additions & 0 deletions tests/Behat/Context/Ui/Admin/BlockContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public function iFillTheNameWith(string $name): void
$this->resolveCurrentPage()->fillName($name);
}

/**
* @When I fill the name with :name if the name field is empty
*/
public function iFillTheNameIfItIsEmpty(string $name): void
{
$this->resolveCurrentPage()->fillNameIfItIsEmpty($name);
}

/**
* @When I fill the link with :link
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/Behat/Page/Admin/Block/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public function fillName(string $name): void
$this->getDocument()->fillField('Name', $name);
}

public function fillNameIfItIsEmpty(string $name): void
{
if (empty($this->getDocument()->findField('Name')->getValue())) {
$this->fillName($name);
}
}

public function fillLink(string $link): void
{
$this->getDocument()->fillField('Link', $link);
Expand Down

0 comments on commit 36de438

Please sign in to comment.