MNT Fix archive button behat test

This commit is contained in:
Steve Boyd 2021-03-18 15:15:16 +13:00
parent 3bbc4aa6b3
commit 1ccf67b158
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