feat(web): add search page with full-text message search UI
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { SearchResults } from './page';
|
||||
|
||||
const makeHit = (id: string, content: string) => ({
|
||||
id,
|
||||
content,
|
||||
senderName: 'Alice',
|
||||
sourceGroupName: 'UP Parivar Dallas',
|
||||
tags: ['#important'],
|
||||
approvedAt: 1748390400000,
|
||||
});
|
||||
|
||||
describe('SearchResults', () => {
|
||||
it('shows "no results" when hits array is empty', () => {
|
||||
render(<SearchResults hits={[]} total={0} q="missing" page={1} />);
|
||||
expect(screen.getByText(/no results/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders each hit content', () => {
|
||||
render(
|
||||
<SearchResults
|
||||
hits={[makeHit('m1', 'Hello world'), makeHit('m2', 'Event tonight')]}
|
||||
total={2}
|
||||
q="hello"
|
||||
page={1}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText('Hello world')).toBeInTheDocument();
|
||||
expect(screen.getByText('Event tonight')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the total result count', () => {
|
||||
render(<SearchResults hits={[makeHit('m1', 'Test')]} total={42} q="test" page={1} />);
|
||||
expect(screen.getByText(/42/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows sender name and group name for each hit', () => {
|
||||
render(<SearchResults hits={[makeHit('m1', 'Test')]} total={1} q="test" page={1} />);
|
||||
expect(screen.getByText(/alice/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/UP Parivar Dallas/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows tags for each hit', () => {
|
||||
render(<SearchResults hits={[makeHit('m1', 'Test')]} total={1} q="test" page={1} />);
|
||||
expect(screen.getByText('#important')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user