feat: render flash messages as toasts
Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
5a6db29205
commit
9b35c730ab
9 files changed
+75
-14
No files matched your search
@@ -48,7 +48,7 @@ class HtmxErrorFlashListenerTest extends WebTestCase
|
||||
self::assertFalse($this->client->getResponse()->headers->has('HX-Retarget'));
|
||||
|
||||
$this->client->request('GET', '/');
|
||||
self::assertSelectorTextContains('#flashes', self::MESSAGE);
|
||||
self::assertSelectorExists(self::toastSelector(self::MESSAGE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +61,15 @@ class HtmxErrorFlashListenerTest extends WebTestCase
|
||||
self::assertResponseStatusCodeSame(Response::HTTP_FORBIDDEN);
|
||||
|
||||
$this->client->request('GET', '/');
|
||||
self::assertSelectorTextNotContains('#flashes', self::MESSAGE);
|
||||
self::assertSelectorNotExists('#flashes [data-controller~="toast"]');
|
||||
}
|
||||
|
||||
/**
|
||||
* A flash carries its text in the Stimulus value that toast_controller hands to Toastify, so
|
||||
* there is nothing to read as element text -- the element itself stays empty.
|
||||
*/
|
||||
private static function toastSelector(string $message): string
|
||||
{
|
||||
return \sprintf('#flashes [data-controller~="toast"][data-toast-text-value*="%s"]', $message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user