From 086158511c0256bbdd68a1947ed7e8db11c8261e Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Thu, 23 Apr 2026 02:52:00 +0200 Subject: [PATCH] test(join-space): update stale assertions to match current UI and API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four assertions drifted from the current JoinSpace modal, carried over when the file was renamed from the old JoinServer component in fc06e25 without being updated: - Placeholder was expanded to cover URL-form invite input ('e.g. abc123' → 'e.g. abc123 or https://instance.com/join/abc123'). - 'shows validation error when submitting empty code' asserted a code path that no longer exists: the submit button is now disabled when the trimmed input is empty (JoinSpace.tsx line 166), so clicking it is a no-op and the 'Invite code is required' error from the parser is unreachable from the rendered form. Replaced with an assertion that the button is disabled while the input is empty — the actual validation UX. - joinByCode signature took on a second `origin` argument during the S2S DM unification + federated-join work (spaceStore.ts line 69). parseInviteInput returns { code, origin: undefined } for a bare code, so the call is `joinByCode('my-invite-code', undefined)`. Assertion updated to match exactly. No code behavior change — tests now reflect actual behavior, which was already correct and deployed. Closes backlog #28. --- .../src/components/modals/JoinSpace.test.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/web/src/components/modals/JoinSpace.test.tsx b/packages/web/src/components/modals/JoinSpace.test.tsx index f86cb364..c4117388 100644 --- a/packages/web/src/components/modals/JoinSpace.test.tsx +++ b/packages/web/src/components/modals/JoinSpace.test.tsx @@ -55,19 +55,20 @@ describe('JoinSpaceModal', () => { useUIStore.setState({ activeModal: 'joinSpace' }); renderModal(); expect(screen.getByText('Join a Space')).toBeInTheDocument(); - expect(screen.getByPlaceholderText('e.g. abc123')).toBeInTheDocument(); + expect( + screen.getByPlaceholderText('e.g. abc123 or https://instance.com/join/abc123') + ).toBeInTheDocument(); expect(screen.getByText('Join Space')).toBeInTheDocument(); }); - it('shows validation error when submitting empty code', async () => { - const user = userEvent.setup(); + it('disables the Join Space button while the input is empty', () => { useUIStore.setState({ activeModal: 'joinSpace' }); renderModal(); - const submitButton = screen.getByText('Join Space'); - await user.click(submitButton); - - expect(screen.getByText('Invite code is required')).toBeInTheDocument(); + // The submit button is the validation gate in this UI — there is no + // click-to-show-error path. parseInviteInput's 'Invite code is required' + // branch is defensive only and unreachable from the rendered form. + expect(screen.getByText('Join Space')).toBeDisabled(); }); it('calls joinByCode with the entered invite code and navigates on success', async () => { @@ -79,16 +80,17 @@ describe('JoinSpaceModal', () => { renderModal(); // Type invite code - const input = screen.getByPlaceholderText('e.g. abc123'); + const input = screen.getByPlaceholderText('e.g. abc123 or https://instance.com/join/abc123'); await user.type(input, 'my-invite-code'); // Click join const submitButton = screen.getByText('Join Space'); await user.click(submitButton); - // joinByCode should be called with the code + // joinByCode(code, origin) — bare code has no origin, so second arg is + // undefined (parseInviteInput returns { code, origin: undefined }). await waitFor(() => { - expect(mockJoinByCode).toHaveBeenCalledWith('my-invite-code'); + expect(mockJoinByCode).toHaveBeenCalledWith('my-invite-code', undefined); }); // Should navigate to the new space @@ -108,7 +110,7 @@ describe('JoinSpaceModal', () => { renderModal(); - const input = screen.getByPlaceholderText('e.g. abc123'); + const input = screen.getByPlaceholderText('e.g. abc123 or https://instance.com/join/abc123'); await user.type(input, 'bad-code'); const submitButton = screen.getByText('Join Space');