more targeted refresh

This commit is contained in:
Moon.eth
2026-07-29 12:51:33 +09:00
parent 4f682857ac
commit a42145c678
11 changed files with 229 additions and 4 deletions
+28
View File
@@ -2,6 +2,7 @@ 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 { TIMELINE_REFRESH, TimelineRefreshController } from '$lib/timeline-refresh'
import { account, deferred, session, status, testServices, theme } from '$test/fixtures'
import Profile from './Profile.svelte'
@@ -139,4 +140,31 @@ describe('Profile', () => {
expect(view.queryByText('A movie')).not.toBeInTheDocument()
expect(view.queryByText('A reposted picture')).not.toBeInTheDocument()
})
it('refreshes only the entry feed without reloading the profile', async () => {
const lookupAccount = vi.fn().mockResolvedValue(account())
const fetchAccountStatuses = vi.fn().mockResolvedValue({
items: [status({ content: '<p>Timeline note</p>' })],
links: {},
})
const services = testServices({
session: session(),
theme: theme(),
endpoints: { lookupAccount, fetchAccountStatuses },
})
const refresh = new TimelineRefreshController()
const context = new Map()
context.set(APP_SERVICES, services)
context.set(TIMELINE_REFRESH, refresh)
const view = render(Profile, {
props: { acct: 'alice', view: 'blog' },
context,
})
expect(await view.findByText('Timeline note')).toBeInTheDocument()
expect(refresh.refresh()).toBe(true)
await waitFor(() => expect(fetchAccountStatuses).toHaveBeenCalledTimes(2))
expect(lookupAccount).toHaveBeenCalledOnce()
})
})