veza/apps/web/src/components/search/Search.stories.tsx
senke 0a29c544af fix(web): resolve all 568 TypeScript errors — tsc --noEmit now passes with zero errors
Major categories fixed:
- TS6133 (188): Remove unused imports (React, icons, types) and variables
- TS2322 (222): Fix type mismatches in stories (satisfies Meta -> const meta: Meta),
  add nullish coalescing for optional values, fix component prop types
- TS2345 (43): Fix argument type mismatches with proper null checks and type narrowing
- TS2741 (21): Add missing required properties to mock/story data
- TS2339 (19): Fix property access on incorrect types, add type guards
- TS2353 (13): Remove extra properties from object literals or extend interfaces
- TS2352 (11): Fix type conversion chains
- TS2307 (9): Fix import paths and module references
- Other (42): Fix implicit any, possibly undefined, export declarations

Vite build and tsc --noEmit both pass cleanly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 00:32:08 +01:00

77 lines
2.1 KiB
TypeScript

import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';
import { Search } from './Search';
const mockResults = [
{ id: '1', type: 'track' as const, title: 'Neon Lights', subtitle: 'Synthwave Boy', image: 'https://placehold.co/40' },
{ id: '2', type: 'user' as const, title: 'DJ Cool', subtitle: 'Pro User', image: 'https://placehold.co/40' },
{ id: '3', type: 'playlist' as const, title: 'Summer Vibes', subtitle: 'Public', image: 'https://placehold.co/40' },
];
const meta = {
title: 'Components/Features/Search/Search',
component: Search,
tags: ['autodocs'],
parameters: {
layout: 'centered',
},
decorators: [
(Story) => (
<div className="max-w-2xl w-full p-4 min-h-layout-story">
<Story />
</div>
),
],
args: {
onSearch: fn(),
},
} satisfies Meta<typeof Search>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
fetchSuggestions: async (query) => {
await new Promise((r) => setTimeout(r, 500));
return mockResults.filter((r) => r.title.toLowerCase().includes(query.toLowerCase()));
},
},
};
export const NoHistory: Story = {
args: {
showHistory: false,
fetchSuggestions: async () => {
await new Promise((r) => setTimeout(r, 500));
return mockResults;
},
},
};
/** Suggestions loading (delay 2s). Type to see loading state. */
export const Loading: Story = {
args: {
fetchSuggestions: async () => {
await new Promise((r) => setTimeout(r, 2000));
return mockResults;
},
},
};
/** No results for query. */
export const Empty: Story = {
args: {
fetchSuggestions: async () => [],
},
};
/** Fetch fails — error is logged, empty list shown. */
const searchError = new globalThis.Error('Search service unavailable');
export const Error: Story = {
args: {
fetchSuggestions: async () => {
throw searchError;
},
},
};