feat: link media to conversations
This commit is contained in:
1 parent
e8f56b42e6
commit
acc610c2bf
4 files changed
+39
-5
No files matched your search
@@ -7,6 +7,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { HttpResponse, http } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { MediaPage } from '../../apps/dashboard/src/features/media/media-page.js';
|
||||
|
||||
const now = Date.now();
|
||||
@@ -15,6 +16,7 @@ const mediaItems = [
|
||||
id: 'one', chatUsername: 'alice', chatRoomId: 'room-a', sender: 'alice',
|
||||
timestamp: now - 60_000, originalUrl: 'https://media.example/one.jpg', fileName: 'one.jpg',
|
||||
relativePath: 'one.jpg', createdAt: now - 50_000, urlPath: '/media/one.jpg',
|
||||
owner: { accountId: '@t2_bot:reddit.com', redditUsername: 'bot-account' },
|
||||
},
|
||||
{
|
||||
id: 'two', chatUsername: 'bob', chatRoomId: 'room-b', sender: 'charlie',
|
||||
@@ -52,7 +54,9 @@ function renderMedia() {
|
||||
});
|
||||
const view = render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<MediaPage />
|
||||
<MemoryRouter>
|
||||
<MediaPage />
|
||||
</MemoryRouter>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
return { ...view, queryClient };
|
||||
@@ -124,6 +128,19 @@ describe('media page', () => {
|
||||
expect(screen.queryByRole('dialog', { name: 'Media from alice' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('links media cards to their account-owned conversations', async () => {
|
||||
installMediaApi();
|
||||
renderMedia();
|
||||
|
||||
const conversationLinks = await screen.findAllByRole('link', { name: 'Open conversation' });
|
||||
expect(conversationLinks).toHaveLength(3);
|
||||
expect(conversationLinks[0]).toHaveAttribute(
|
||||
'href',
|
||||
'/conversations/%2540t2_bot%253Areddit.com~room-a',
|
||||
);
|
||||
expect(conversationLinks[1]).toHaveAttribute('href', '/conversations/room-b');
|
||||
});
|
||||
|
||||
it('filters by conversation, sender, media type, and age with an explicit no-match state', async () => {
|
||||
installMediaApi();
|
||||
const user = userEvent.setup();
|
||||
|
||||
Reference in new issue
Block a user