Filter detected sellers from conversations

This commit is contained in:
jjbrunton committed 2026-08-09 14:38:03 +01:00
1 parent d5ebdec076
commit 92c54feedc
14 files changed
+97 -7

No files matched your search

+16
View File
@@ -17,6 +17,7 @@ interface ChatFixtureOptions {
isFromUs?: boolean;
lastMessageSnippet?: string;
hasReceivedImages?: boolean;
sellerDetected?: boolean;
}
function chatFixture(options: ChatFixtureOptions) {
@@ -30,6 +31,7 @@ function chatFixture(options: ChatFixtureOptions) {
isFromUs: options.isFromUs ?? false,
unread: options.unread ?? false,
...(options.hasReceivedImages === undefined ? {} : { hasReceivedImages: options.hasReceivedImages }),
...(options.sellerDetected === undefined ? {} : { sellerDetected: options.sellerDetected }),
};
}
@@ -149,6 +151,20 @@ describe('ConversationsPage', () => {
expect(screen.getByRole('img', { name: 'Source post: Looking for a chat' })).not.toHaveClass('is-blurred');
});
it('hides detected sellers by default and reveals marked conversations on request', async () => {
const seller = chatFixture({ username: 'seller', roomId: 'room-seller', sellerDetected: true });
server.use(http.get('/api/conversations', () => HttpResponse.json([alice, seller])));
const user = userEvent.setup();
renderConversations();
expect(await screen.findByRole('button', { name: /u\/alice/ })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /u\/seller/ })).not.toBeInTheDocument();
await user.click(screen.getByRole('checkbox', { name: 'Show sellers' }));
expect(screen.getByRole('button', { name: /u\/seller.*Seller/ })).toBeInTheDocument();
expect(screen.getByText('Seller')).toBeInTheDocument();
});
it('orders conversations by latest message activity', async () => {
const oldest = chatFixture({ username: 'oldest', roomId: 'room-oldest', lastMessageTime: 100 });
const newest = chatFixture({ username: 'newest', roomId: 'room-newest', lastMessageTime: 300 });
+2 -1
View File
@@ -32,10 +32,11 @@ describe('route-friendly filters', () => {
it('hydrates and writes conversation search and status filters', async () => {
server.use(http.get('/api/conversations', () => HttpResponse.json([])));
const user = userEvent.setup();
renderRoute('/conversations?q=alice&filter=received-images', <ConversationRoute />);
renderRoute('/conversations?q=alice&filter=received-images&showSellers=true', <ConversationRoute />);
const search = await screen.findByRole('searchbox', { name: 'Search conversations' });
expect(search).toHaveValue('alice');
expect(screen.getByRole('combobox', { name: 'Filter conversations' })).toHaveValue('received-images');
expect(screen.getByRole('checkbox', { name: 'Show sellers' })).toBeChecked();
await user.clear(search);
await user.type(search, 'bob');
expect(screen.getByLabelText('Current URL')).toHaveTextContent('q=bob');