From dbc9d7fd264ed68419286d4edfc3b98ca5a2dbe0 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 8 Jul 2025 00:54:44 -0400 Subject: Bug: the login form generates incorrect requests (once per pageview). Steps to reproduce: **Note**: You will need to watch the traffic in a DOM inspector; this has no user-observable symptoms because there's presently no error reporting for the login form. 1. In a new private tab, visit the `/login` page of a Pilcrow instance. 2. **Without touching the username or password fields**, click `sign in`. The client _should_ send a request to `/api/auth/login` with the following payload: ```json { "name": "", "password": "" } ``` However, it instead sends an empty payload, leading to a 422 Unprocessable Content response as the request is missing required fields. Subsequent requests, or any request after the user enters data in the input fields, are correctly serialized. --- ui/tests/lib/components/LogIn.svelte.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/tests/lib/components/LogIn.svelte.test.js b/ui/tests/lib/components/LogIn.svelte.test.js index 00abb5c..0835870 100644 --- a/ui/tests/lib/components/LogIn.svelte.test.js +++ b/ui/tests/lib/components/LogIn.svelte.test.js @@ -31,4 +31,11 @@ describe('LogIn', async () => { 'my very creative and long password', ); }); + + it('sends empty strings before being populated', async () => { + const signIn = screen.getByRole('button'); + await user.click(signIn); + + expect(mocks.logIn).toHaveBeenCalledExactlyOnceWith('', ''); + }); }); -- cgit v1.2.3