From 59ce979641c38cfcc16a0d8a2a7bf924615e31e8 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Mon, 6 Jul 2026 00:52:57 +0200 Subject: [PATCH 1/2] fix(frontend): call toBeDefined() matcher to clear eslint no-unused-expressions The assertion at users.test.ts:1861 was missing its call parentheses, causing two problems: (1) eslint @typescript-eslint/no-unused-expressions reported it as an error, failing the Build-frontend CI job on every open PR in the repo; (2) the assertion never actually ran, so the test was silently not checking anything. This was the sole error (1 error / 89 warnings) in `npm run lint`; after the fix lint exits 0. All 207 users.test.ts tests still pass. --- frontend/src/__tests__/users.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/__tests__/users.test.ts b/frontend/src/__tests__/users.test.ts index 0e3d78afe..693d0ca0a 100644 --- a/frontend/src/__tests__/users.test.ts +++ b/frontend/src/__tests__/users.test.ts @@ -1858,7 +1858,7 @@ describe('users/handlers', () => { userHandlers.setupUserHandlers(); const form = document.getElementById('user-form'); - expect(form?.onsubmit || form?.getAttribute('data-handler')).toBeDefined; + expect(form?.onsubmit || form?.getAttribute('data-handler')).toBeDefined(); }); it('should set up search input handler', () => { From 6900476129e02f867f9ee5c35387c867bae4c905 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Mon, 6 Jul 2026 01:33:48 +0200 Subject: [PATCH 2/2] test(frontend): assert submit handler is actually wired, not just non-undefined The prior assertion checked `.toBeDefined()` on `form?.onsubmit || form?.getAttribute('data-handler')`, which always evaluated to null: setupUserHandlers wires the submit handler via addEventListener('submit', ...), so form.onsubmit stays null and no data-handler attribute is set. toBeDefined() accepts null, so the assertion passed unconditionally and never proved the handler was wired. Now spy on userModals.saveUser, dispatch a real submit event on the form, and assert saveUser was invoked once, matching how sibling handler tests in this file assert wiring via observable side effects. Verified the assertion fails (0 calls) when setupUserHandlers is not called. --- frontend/src/__tests__/users.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/__tests__/users.test.ts b/frontend/src/__tests__/users.test.ts index 693d0ca0a..f623080fd 100644 --- a/frontend/src/__tests__/users.test.ts +++ b/frontend/src/__tests__/users.test.ts @@ -1855,10 +1855,18 @@ describe('users/handlers', () => { }); it('should set up form submit handler', () => { + // saveUser is wired via addEventListener('submit', ...), so form.onsubmit + // stays null. Prove the listener is actually attached by spying on saveUser + // and dispatching a real submit event, then asserting the observable call. + const saveUserSpy = jest.spyOn(userModals, 'saveUser').mockResolvedValue(undefined); + userHandlers.setupUserHandlers(); - const form = document.getElementById('user-form'); - expect(form?.onsubmit || form?.getAttribute('data-handler')).toBeDefined(); + const form = document.getElementById('user-form') as HTMLFormElement; + form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true })); + + expect(saveUserSpy).toHaveBeenCalledTimes(1); + saveUserSpy.mockRestore(); }); it('should set up search input handler', () => {