From 7cdd58f149d79bf662e9453f0f9f0385ae7a58ad Mon Sep 17 00:00:00 2001 From: aurelienrichard Date: Wed, 15 May 2024 13:26:22 +0200 Subject: [PATCH] autofocus input fields on page load to improve ux --- apps/privelte/src/lib/components/Chat.svelte | 12 ++- .../src/lib/components/Chat.svelte.test.ts | 8 +- .../src/lib/components/Message.svelte.test.ts | 4 - .../src/lib/components/NewMessageForm.svelte | 6 +- .../components/NewMessageForm.svelte.test.ts | 4 - .../src/routes/room/[id]/join/+page.svelte | 81 ++++++++++--------- 6 files changed, 60 insertions(+), 55 deletions(-) diff --git a/apps/privelte/src/lib/components/Chat.svelte b/apps/privelte/src/lib/components/Chat.svelte index a00eaf3..073d36d 100644 --- a/apps/privelte/src/lib/components/Chat.svelte +++ b/apps/privelte/src/lib/components/Chat.svelte @@ -29,14 +29,18 @@
-

- You're all +

+ Share the link setbelow + to invite + participants.

-

Share the link below to invite participants.


diff --git a/apps/privelte/src/lib/components/Chat.svelte.test.ts b/apps/privelte/src/lib/components/Chat.svelte.test.ts index 77e6cc6..c7c12b5 100644 --- a/apps/privelte/src/lib/components/Chat.svelte.test.ts +++ b/apps/privelte/src/lib/components/Chat.svelte.test.ts @@ -6,14 +6,10 @@ import type { Payload, Presence } from '$lib/types/types' describe('Chat component', () => { const userId = '1' - test('should render', () => { - render(Chat, { userId, entries: [], subscribed: 'ok' }) - }) - test('should render share link message and clipboard component', () => { - const { getByText, getByRole } = render(Chat, { userId, entries: [], subscribed: 'ok' }) + const { getByRole } = render(Chat, { userId, entries: [], subscribed: 'ok' }) - expect(getByText('Share the link below to invite participants.')).toBeInTheDocument() + expect(getByRole('heading', { level: 1 })).toBeInTheDocument() expect(getByRole('button', { name: 'Copy to clipboard.' })).toBeInTheDocument() }) diff --git a/apps/privelte/src/lib/components/Message.svelte.test.ts b/apps/privelte/src/lib/components/Message.svelte.test.ts index 44dc006..7ca3c18 100644 --- a/apps/privelte/src/lib/components/Message.svelte.test.ts +++ b/apps/privelte/src/lib/components/Message.svelte.test.ts @@ -13,10 +13,6 @@ describe('Message component', () => { id: '2' } - test('should render', () => { - render(Message, { payload, status: 'success', isOwnMessage: false }) - }) - test('should display the message and username', () => { const { getByText } = render(Message, { payload, status: 'success', isOwnMessage: false }) diff --git a/apps/privelte/src/lib/components/NewMessageForm.svelte b/apps/privelte/src/lib/components/NewMessageForm.svelte index 5fdd551..059669b 100644 --- a/apps/privelte/src/lib/components/NewMessageForm.svelte +++ b/apps/privelte/src/lib/components/NewMessageForm.svelte @@ -1,5 +1,5 @@
@@ -22,44 +29,46 @@ >username. -

- It will be exclusive to this room and serve only as a display name for the messages you - send. -

+

Usernames are exclusive to each room.

- + {#if loading} + + {:else} + + + + {/if} + +