From 4cc5a7363fa53019dc3b3c95d2977a6e6e9cf4ed Mon Sep 17 00:00:00 2001 From: Andreas Reinhold / reini Date: Mon, 14 Sep 2026 19:38:25 +0200 Subject: [PATCH] Fix two datepicker browser assertions that could never pass Plan step 36 review of 72d9dbfc's new full-screen range test, written but not run. It chained click() off script(), whose return value is the evaluated script's result rather than the page (the chaining bug 4bf1ca13 fixed elsewhere), and asserted the close and Save buttons with a bare querySelector, which assertScript compares strictly with true. The chain is split, and the buttons are asserted as drawn. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9 --- tests/Browser/DatepickerTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Browser/DatepickerTest.php b/tests/Browser/DatepickerTest.php index da1fd93f..bfc6fbb8 100644 --- a/tests/Browser/DatepickerTest.php +++ b/tests/Browser/DatepickerTest.php @@ -514,8 +514,8 @@ it('opens the range picker full screen below 600px and grows its month list both ->assertScript("{$picker}.matches(':modal')") ->assertScript("document.querySelector('#trip-field-picker [data-md-datepicker-app-bar]').offsetHeight > 0") // M3's 14-element anatomy: a close (×) icon button and Save in the app bar, not Cancel/OK. - ->assertScript("document.querySelector('#trip-field-picker [data-md-datepicker-close]')") - ->assertScript("document.querySelector('#trip-field-picker [data-md-datepicker-save]')") + ->assertScript("document.querySelector('#trip-field-picker [data-md-datepicker-close]').getClientRects().length > 0") + ->assertScript("document.querySelector('#trip-field-picker [data-md-datepicker-save]').getClientRects().length > 0") ->assertScript("getComputedStyle(document.querySelector('#trip-field-picker [data-md-datepicker-actions]')).display === 'none'") // The window opens six months either side of the trip's start month. ->assertScript("{$scope}.monthsFrom === '2026-03-01' && {$scope}.monthsTo === '2027-03-01'") @@ -540,8 +540,10 @@ it('opens the range picker full screen below 600px and grows its month list both ->assertScript("[...document.querySelectorAll('#trip-field-picker [data-md-datepicker-month-label]')].some((label) => label.textContent.trim() === 'February 2026')"); // Picking a range and pressing Save commits it and closes the dialog. - $page->script("{$scope}.moveTo('2026-09-13', false)") - ->click(day('trip-field', '2026-09-20')) + // script() returns the script's result, not the page, so the chain starts again after it. + $page->script("{$scope}.moveTo('2026-09-13', false)"); + + $page->click(day('trip-field', '2026-09-20')) ->click(day('trip-field', '2026-09-24')) ->click('#trip-field-picker [data-md-datepicker-save]') ->assertSeeIn('#trip', '{"start":"2026-09-20","end":"2026-09-24"}')