feat: refine task and countdown interactions
ci / gitleaks (push) Successful in 9s
ci / docker (push) Successful in 3m31s

This commit is contained in:
2026-09-17 09:32:22 +08:00
parent bdf2a53fa9
commit 1571c3946f
14 changed files with 388 additions and 31 deletions
+22 -1
View File
@@ -195,7 +195,28 @@ describe('countdown modal accessibility', () => {
newPin.resolve(json({})); await flush()
})
it('keeps the normal current-detail pin flow working', async () => {
it('pins and unpins from detail without duplicate requests', async () => {
const mutation = deferred<Response>()
const pinned = { ...countdown, pinned: true }
const fetchMock = vi.fn((url: string, options?: RequestInit) => {
if (url.endsWith('/countdowns/c1/pin') && options?.method === 'DELETE') return mutation.promise
if (url.endsWith('/countdowns')) return Promise.resolve(json([pinned]))
if (url.includes('archived=true')) return Promise.resolve(json([]))
throw new Error(`unexpected ${url}`)
})
const { host, notices } = await mountWithFetch(fetchMock)
clickCountdown(host, '发布日'); await nextTick()
const button = detailButton('取消置顶')
button.click(); button.click()
await nextTick()
expect(fetchMock.mock.calls.filter(([url]) => String(url).endsWith('/countdowns/c1/pin'))).toHaveLength(1)
expect(button.disabled).toBe(true)
mutation.resolve(json({ ...pinned, pinned: false })); await flush()
expect(notices).toEqual(['已取消置顶'])
expect(document.querySelector('.countdown-detail-sheet')).toBeNull()
})
it('keeps normal current-detail pin flow working', async () => {
const pin = deferred<Response>()
const fetchMock = vi.fn((url: string) => {
if (url.endsWith('/countdowns/c1/pin')) return pin.promise