Fix two CommunicationTest chains that dropped the page after script()

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 <body>, 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-14 18:28:02 +02:00
co-authored by Claude Sonnet 5
parent 636a0fe71d
commit 4bf1ca13a3
+8 -5
View File
@@ -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]')");
});