pics timeline

This commit is contained in:
Moon.eth
2026-07-29 11:04:22 +09:00
parent dd88daaf1c
commit 2f0c8821f3
5 changed files with 279 additions and 7 deletions
+73
View File
@@ -66,4 +66,77 @@ describe('Profile', () => {
expect(view.queryByText('Someone elses note')).not.toBeInTheDocument()
expect(view.queryByText('A reply')).not.toBeInTheDocument()
})
it('builds Pics from the accounts own image attachments', async () => {
const ownPicture = status({
id: 'picture-entry',
content: '<p>A day at the beach</p>',
media_attachments: [
{
id: 'picture',
type: 'image',
url: 'https://media.example/beach.jpg',
preview_url: 'https://media.example/beach-small.jpg',
description: 'Sunset over the beach',
},
],
})
const video = status({
id: 'video-entry',
content: '<p>A video that does not belong in Pics</p>',
media_attachments: [
{
id: 'video',
type: 'video',
url: 'https://media.example/movie.mp4',
preview_url: 'https://media.example/movie.jpg',
description: 'A movie',
},
],
})
const repostedPicture = status({
id: 'repost',
reblog: status({
id: 'someone-elses-picture',
content: '<p>Someone elses picture</p>',
media_attachments: [
{
id: 'reposted-picture',
type: 'image',
url: 'https://media.example/reposted.jpg',
preview_url: null,
description: 'A reposted picture',
},
],
}),
})
const fetchAccountStatuses = vi.fn().mockResolvedValue({
items: [ownPicture, video, repostedPicture],
links: {},
})
const services = testServices({
session: session(),
theme: theme(),
endpoints: {
lookupAccount: vi.fn().mockResolvedValue(account()),
fetchAccountStatuses,
},
})
const view = render(Profile, {
props: { acct: 'alice', view: 'pics' },
context: new Map([[APP_SERVICES, services]]),
})
expect(await view.findByRole('img', { name: 'Sunset over the beach' })).toHaveAttribute(
'src',
'https://media.example/beach-small.jpg',
)
expect(fetchAccountStatuses.mock.calls[0][3]).toEqual({
only_media: true,
exclude_reblogs: true,
})
expect(view.getByText('Sunset over the beach')).toBeInTheDocument()
expect(view.queryByText('A movie')).not.toBeInTheDocument()
expect(view.queryByText('A reposted picture')).not.toBeInTheDocument()
})
})