From 92ffbe03fb59a516a883a4859329f5a62ffb55a6 Mon Sep 17 00:00:00 2001
From: Steve Boyd <emteknetnz@gmail.com>
Date: Thu, 11 Jul 2024 12:10:28 +1200
Subject: [PATCH] MNT Support assert toasts if there are mutliple toasts

---
 tests/behat/src/CmsUiContext.php | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tests/behat/src/CmsUiContext.php b/tests/behat/src/CmsUiContext.php
index 1adb97252..7bc4a3bfc 100644
--- a/tests/behat/src/CmsUiContext.php
+++ b/tests/behat/src/CmsUiContext.php
@@ -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);
         }
     }