From 534149ba22f8be5780ca0771b927b57e9ca40144 Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 21 Apr 2026 21:52:46 +0200 Subject: [PATCH] fix(test): query form by tag since Save button is now in Modal footer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After moving Save/Cancel into the Modal's sticky footer prop, the button no longer lives inside the
element, so walking up via closest('form') returns null. Query the form directly via document.querySelector('form') — same semantics, just doesn't assume the button is a descendant of the form. --- client/src/components/Planner/ReservationModal.test.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/components/Planner/ReservationModal.test.tsx b/client/src/components/Planner/ReservationModal.test.tsx index 7710a188..4cf9c208 100644 --- a/client/src/components/Planner/ReservationModal.test.tsx +++ b/client/src/components/Planner/ReservationModal.test.tsx @@ -203,8 +203,10 @@ describe('ReservationModal', () => { fireEvent.change(datePickers[1], { target: { value: '2025-06-09' } }); fireEvent.change(timePickers[1], { target: { value: '09:00' } }); - // When isEndBeforeStart=true the submit button is disabled, so submit the form directly - const form = screen.getByRole('button', { name: /^Add$/i }).closest('form')!; + // When isEndBeforeStart=true the submit button is disabled, so fire submit on the form directly. + // The Save button now lives in the Modal's sticky footer (outside the ), so we query + // the form by tag instead of walking up from the button. + const form = document.querySelector('form')!; fireEvent.submit(form); expect(onSave).not.toHaveBeenCalled();