mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MNT Support assert toasts if there are mutliple toasts
This commit is contained in:
parent
bdd27b96b7
commit
92ffbe03fb
@ -105,7 +105,20 @@ class CmsUiContext implements Context
|
||||
// no-op - if the element doesn't exist at all, then that passes the test.
|
||||
}
|
||||
} 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