From 4bf1ca13a3e89bc1d75d366681bdf73ae0e94fbb Mon Sep 17 00:00:00 2001 From: Andreas Reinhold / reini Date: Mon, 14 Sep 2026 18:28:02 +0200 Subject: [PATCH] Fix two CommunicationTest chains that dropped the page after script() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both chained keys()/assertScript() straight off script()'s return value, which is the evaluated script's result, not the page — so a snackbar whose dismiss button had just been focused, or whose page focus had just been reset to , called keys() on null. Splits each into its own statement, as the FAB menu scroll test in ActionsTest.php was fixed in the same way. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9 --- tests/Browser/CommunicationTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/Browser/CommunicationTest.php b/tests/Browser/CommunicationTest.php index 7779c118..1531fe61 100644 --- a/tests/Browser/CommunicationTest.php +++ b/tests/Browser/CommunicationTest.php @@ -162,9 +162,11 @@ it('dismisses a focused snackbar with Escape', function () { $page->script("materialToast('Share deleted', { action: { label: 'Undo', handler: () => {} } })"); - $page->assertScript(TOAST."?.textContent.includes('Share deleted')") - ->script("document.querySelector('[data-md-toast-dismiss]').focus()") - ->keys(':focus', 'Escape') + $page->assertScript(TOAST."?.textContent.includes('Share deleted')"); + + $page->script("document.querySelector('[data-md-toast-dismiss]').focus()"); + + $page->keys(':focus', 'Escape') ->assertScript(TOAST.' === null'); }); @@ -189,8 +191,9 @@ it('grows to M3\'s two-line height with a description, and Alt+G reaches its act // Focused somewhere else on the page first: the shortcut has to reach the snackbar from // wherever the keyboard already was, since a snackbar never takes the focus on its own. - $page->script("document.body.setAttribute('tabindex', '-1'); document.body.focus()") - ->keys(':focus', 'Alt+g') + $page->script("document.body.setAttribute('tabindex', '-1'); document.body.focus()"); + + $page->keys(':focus', 'Alt+g') ->assertScript('document.activeElement === '.TOAST."?.querySelector('[data-md-toast-action]')"); });