Files
llama.cpp/tools/ui/tests/stories/SidebarNavigation.stories.svelte
Aleksander Grygier 21444c822e ui: Fixed packages (#24119)
* chore(ui): pin package versions to currently installed

- Update all dependencies and devDependencies to match exactly what's in package-lock.json
- This ensures reproducible builds by locking to specific versions rather than semver ranges

* chore: Update packages

* chore: Move remaining dependencies to devDependencies

* fix: Add missing `mermaid` package

* chore: Update `cookie` package to `v1.1.1`

* chore: Formatting

* test: Update test configs
2026-06-04 16:23:08 +02:00

114 lines
2.7 KiB
Svelte

<script module lang="ts">
import { defineMeta } from '@storybook/addon-svelte-csf';
import SidebarNavigation from '$lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte';
import { waitFor } from 'storybook/test';
import { screen } from 'storybook/test';
const { Story } = defineMeta({
title: 'Components/SidebarNavigation',
component: SidebarNavigation,
parameters: {
layout: 'centered'
}
});
</script>
<script lang="ts">
import * as Sidebar from '$lib/components/ui/sidebar/index.js';
let sidebarOpen = $state(true);
// Mock conversations for the sidebar
const mockConversations: DatabaseConversation[] = [
{
id: 'conv-1',
name: 'Getting Started with AI',
lastModified: Date.now() - 1000 * 60 * 5, // 5 minutes ago
currNode: 'msg-1'
},
{
id: 'conv-2',
name: 'Python Programming Help',
lastModified: Date.now() - 1000 * 60 * 60 * 2, // 2 hours ago
currNode: 'msg-2'
},
{
id: 'conv-3',
name: 'Creative Writing Ideas',
lastModified: Date.now() - 1000 * 60 * 60 * 24, // 1 day ago
currNode: 'msg-3'
},
{
id: 'conv-4',
name: 'This is a very long conversation title that should be truncated properly when displayed',
lastModified: Date.now() - 1000 * 60 * 60 * 24 * 3, // 3 days ago
currNode: 'msg-4'
},
{
id: 'conv-5',
name: 'Math Problem Solving',
lastModified: Date.now() - 1000 * 60 * 60 * 24 * 7, // 1 week ago
currNode: 'msg-5'
}
];
</script>
<Story
asChild
name="Default"
play={async () => {
const { conversationsStore } = await import('$lib/stores/conversations.svelte');
waitFor(() =>
setTimeout(() => {
conversationsStore.conversations = mockConversations;
}, 0)
);
}}
>
<Sidebar.Provider bind:open={sidebarOpen}>
<div class="flex-column h-full h-screen w-72 bg-background">
<SidebarNavigation />
</div>
</Sidebar.Provider>
</Story>
<Story
asChild
name="SearchActive"
play={async ({ userEvent }) => {
const { conversationsStore } = await import('$lib/stores/conversations.svelte');
waitFor(() =>
setTimeout(() => {
conversationsStore.conversations = mockConversations;
}, 0)
);
const searchTrigger = screen.getByText('Search');
userEvent.click(searchTrigger);
}}
>
<Sidebar.Provider bind:open={sidebarOpen}>
<div class="flex-column h-full h-screen w-72 bg-background">
<SidebarNavigation />
</div>
</Sidebar.Provider>
</Story>
<Story
asChild
name="Empty"
play={async () => {
// Mock empty conversations store
const { conversationsStore } = await import('$lib/stores/conversations.svelte');
conversationsStore.conversations = [];
}}
>
<Sidebar.Provider bind:open={sidebarOpen}>
<div class="flex-column h-full h-screen w-72 bg-background">
<SidebarNavigation />
</div>
</Sidebar.Provider>
</Story>