API Add new behat method for interacting with toasts (#9695)

This commit is contained in:
Maxime Rainville 2020-09-17 17:12:35 +12:00 committed by GitHub
parent 0746230172
commit ff18dec2e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 1 deletions

View File

@ -77,10 +77,49 @@ class CmsUiContext implements Context
/**
* @Then /^I should see a "([^"]*)" notice$/
* @deprecated 4.7.0 Use `iShouldSeeAToast` instead
*/
public function iShouldSeeANotice($notice)
{
$this->getMainContext()->assertElementContains('.notice-wrap', $notice);
$this->getMainContext()->assertElementContains('.toast, .notice-wrap', $notice);
}
/**
* @Then /^I should see a "([^"]+)" (\w+) toast$/
*/
public function iShouldSeeAToast($notice, $type)
{
$this->getMainContext()->assertElementContains('.toast--' . $type, $notice);
}
/**
* @Then /^I should see a "([^"]+)" (\w+) toast with these actions: (.+)$/
*/
public function iShouldSeeAToastWithAction($notice, $type, $actions)
{
$this->iShouldSeeAToast($notice, $type);
$actions = explode(',', $actions);
foreach ($actions as $order => $action) {
$this->getMainContext()->assertElementContains(
sprintf('.toast--%s .toast__action:nth-child(%s)', $type, $order+1),
trim($action)
);
}
}
/**
* @param $action
* @When /^I click the "([^"]*)" toast action$/
*/
public function stepIClickTheToastAction($action)
{
$page = $this->getMainContext()->getSession()->getPage();
$toasts = $page->find('css', '.toasts');
assertNotNull($toasts, "We have a toast container");
$toastAction = $toasts->find('named', ['link_or_button', "'{$action}'"]);
assertNotNull($toastAction, "We have a $action toast action");
$toastAction->click();
}
/**