Merge pull request #2642 from creative-commoners/pulls/4.6/fix/behat

MNT Fix archive button behat test
This commit is contained in:
Maxime Rainville 2021-03-19 17:32:10 +13:00 committed by GitHub
commit 1cd8b76426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -82,9 +82,11 @@ Feature: Publish a page
When I press the "Unpublish" button, confirming the dialog
And I click "More options" in the "#ActionMenus" element
Then I should see an "Archive" button
# Use a css-selector instead of the the "Archive" button otherwise it will get confused with
# the "Archive" model admin
Then I see the "#Form_EditForm_action_archive" element
When I click the "#Form_EditForm_action_archive" element, confirming the dialog
When I press the "Archive" button, confirming the dialog
Then I should see a "Restore" button
And I should not see a "Published" button
And I should not see a "Publish" button

View File

@ -2,8 +2,10 @@
namespace SilverStripe\CMS\Tests\Behaviour;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Mink\Element\DocumentElement;
use Behat\Mink\Element\NodeElement;
use SilverStripe\BehatExtension\Context\BasicContext;
use SilverStripe\BehatExtension\Context\FixtureContext as BehatFixtureContext;
use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\CMS\Model\SiteTree;
@ -17,6 +19,18 @@ use SilverStripe\Versioned\Versioned;
*/
class FixtureContext extends BehatFixtureContext
{
/**
* @var BasicContext
*/
protected $basicContext;
/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope)
{
$this->basicContext = $scope->getEnvironment()->getContext(BasicContext::class);
}
protected function scaffoldDefaultFixtureFactory()
{
$factory = parent::scaffoldDefaultFixtureFactory();
@ -81,6 +95,18 @@ class FixtureContext extends BehatFixtureContext
$element->click();
}
/**
* Needs to be in single command to avoid "unexpected alert open" errors in Selenium.
*
* @When /^I click the "([^"]+)" element, confirming the dialog$/
* @param $selector
*/
public function iClickTheElementConfirmingTheDialog($selector)
{
$this->iClickTheElement($selector);
$this->basicContext->iConfirmTheDialog();
}
/**
* @When /^I see the "([^"]+)" element$/
* @param $selector