Skip to content

Commit

Permalink
Merge pull request #11301 from creative-commoners/pulls/5/toasts-behat
Browse files Browse the repository at this point in the history
MNT Support assert toasts if there are mutliple toasts
  • Loading branch information
GuySartorelli authored Jul 11, 2024
2 parents 3829160 + 92ffbe0 commit 68d8cfc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/behat/src/CmsUiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,20 @@ public function iShouldSeeAToast($not, $notice, $type)
// 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);
}
}

Expand Down

0 comments on commit 68d8cfc

Please sign in to comment.