mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #11301 from creative-commoners/pulls/5/toasts-behat
MNT Support assert toasts if there are mutliple toasts
This commit is contained in:
commit
68d8cfcd4b
@ -105,7 +105,20 @@ class CmsUiContext implements Context
|
|||||||
// no-op - if the element doesn't exist at all, then that passes the test.
|
// no-op - if the element doesn't exist at all, then that passes the test.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->getMainContext()->assertElementContains('.toast--' . $type, $notice);
|
$page = $this->getSession()->getPage();
|
||||||
|
$container = $page->find('css', '.toasts');
|
||||||
|
if (!$container) {
|
||||||
|
Assert::assertNull('Not found', 'No toast container found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($container->findAll('css', '.toast--' . $type) as $toast) {
|
||||||
|
$text = $toast->getText();
|
||||||
|
if (str_contains($text, $notice)) {
|
||||||
|
Assert::assertStringContainsString($notice, $text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Assert::assertNull('Not found', 'No toast container found with text: ' . $notice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user