mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
filter the blog a bit
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { act, render } from '@testing-library/svelte'
|
||||
import { act, render, waitFor } from '@testing-library/svelte'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { APP_SERVICES } from '$lib/app-services'
|
||||
import type { Account } from '$lib/api/types'
|
||||
import { account, deferred, session, testServices, theme } from '$test/fixtures'
|
||||
import { account, deferred, session, status, testServices, theme } from '$test/fixtures'
|
||||
import Profile from './Profile.svelte'
|
||||
|
||||
describe('Profile', () => {
|
||||
@@ -24,4 +24,46 @@ describe('Profile', () => {
|
||||
|
||||
expect(applyProfileCss).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('shows only original top-level notes in Latest Blog Entries', async () => {
|
||||
const original = status({
|
||||
id: 'original',
|
||||
content: '<p>Original note</p>',
|
||||
})
|
||||
const boostedNote = status({
|
||||
id: 'boost-wrapper',
|
||||
content: '',
|
||||
reblog: status({ id: 'boosted', content: '<p>Someone else’s note</p>' }),
|
||||
})
|
||||
const reply = status({
|
||||
id: 'reply',
|
||||
content: '<p>A reply</p>',
|
||||
in_reply_to_id: 'parent',
|
||||
})
|
||||
const fetchAccountStatuses = vi.fn().mockResolvedValue({
|
||||
items: [original, boostedNote, reply],
|
||||
links: {},
|
||||
})
|
||||
const services = testServices({
|
||||
session: session(),
|
||||
theme: theme(),
|
||||
endpoints: {
|
||||
lookupAccount: vi.fn().mockResolvedValue(account()),
|
||||
fetchAccountStatuses,
|
||||
},
|
||||
})
|
||||
const view = render(Profile, {
|
||||
props: { acct: 'alice', view: 'profile' },
|
||||
context: new Map([[APP_SERVICES, services]]),
|
||||
})
|
||||
|
||||
await waitFor(() => expect(fetchAccountStatuses).toHaveBeenCalledOnce())
|
||||
expect(fetchAccountStatuses.mock.calls[0][3]).toEqual({
|
||||
exclude_replies: true,
|
||||
exclude_reblogs: true,
|
||||
})
|
||||
expect(await view.findByText('Original note')).toBeInTheDocument()
|
||||
expect(view.queryByText('Someone else’s note')).not.toBeInTheDocument()
|
||||
expect(view.queryByText('A reply')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user