Skip to content

Commit

Permalink
MNT Support assert toasts if there are mutliple toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jul 11, 2024
1 parent bdd27b9 commit 92ffbe0
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 92ffbe0

Please sign in to comment.