Skip to content

Commit

Permalink
fix(ui): header flicker and hamburger on thread page (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrisse authored Sep 18, 2024
1 parent 3994547 commit 84a6d70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/leapfrogai_ui/src/lib/components/LFHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
let signOutForm: HTMLFormElement;
$: innerWidth = 0;
let innerWidth: number;
$: innerWidth;
const threadId = $page.params.thread_id;
const handleLogOut = (e) => {
e.preventDefault();
Expand All @@ -26,7 +29,7 @@
: '/chat'}
data-testid="logo-link"
>
{#if innerWidth < 1024 && $page.url.pathname === '/chat'}
{#if innerWidth !== undefined && innerWidth < 1024 && ($page.url.pathname === '/chat' || $page.url.pathname === `/chat/${threadId}`)}
<Button
outline={true}
class="mr-2 !p-2"
Expand Down
23 changes: 22 additions & 1 deletion src/leapfrogai_ui/tests/header.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { expect, test } from './fixtures';
import {
deleteActiveThread,
getLastUrlParam,
sendMessage,
waitForResponseToComplete
} from './helpers/threadHelpers';
import { getSimpleMathQuestion } from './helpers/helpers';

test('it only shows the open/close sidebar button on small screens', async ({ page }) => {
await page.setViewportSize({ width: 600, height: 600 });
Expand All @@ -22,7 +29,7 @@ test('it opens the sidebar when the open/close sidebar button is clicked', async
await expect(page.getByTestId('sidebar')).toBeVisible();
});

test('only shows the menu open/close btn on the main chat page', async ({ page }) => {
test('does not show the menu open/close btn non-chat pages', async ({ page }) => {
await page.setViewportSize({ width: 600, height: 600 });
await page.goto('/chat');

Expand All @@ -34,3 +41,17 @@ test('only shows the menu open/close btn on the main chat page', async ({ page }
await expect(page.getByTestId('open-sidebar-btn')).not.toBeVisible();
await expect(page.getByTestId('close-sidebar-btn')).not.toBeVisible();
});

test('shows the menu open/close btn on chat thread pages', async ({ page, openAIClient }) => {
// Test it also shows on an active thread (not just /chat)
await page.goto('/chat');
await sendMessage(page, getSimpleMathQuestion());
await waitForResponseToComplete(page);
const threadId = getLastUrlParam(page);
expect(threadId).toBeDefined();
await page.setViewportSize({ width: 600, height: 600 });
await page.goto(`/chat/${threadId}`); // reload page, dynamic resizing won't be detected in playwright
await page.getByTestId('open-sidebar-btn').click();
await expect(page.getByTestId('sidebar')).toBeVisible();
await deleteActiveThread(page, openAIClient);
});

0 comments on commit 84a6d70

Please sign in to comment.