feat(admin): album management pages with members and categories

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-18 12:33:46 +08:00
parent a6cc190751
commit 50c59ca9d4
27 changed files with 2977 additions and 16 deletions
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest'
import { accumulatePage, firstPage, type CursorPage } from './cursorList'
const pageOf = <T>(items: T[], nextCursor: string | null): CursorPage<T> => ({
items,
nextCursor,
hasMore: nextCursor !== null
})
describe('cursorList 游标累积', () => {
it('首页整页替换并保留游标', () => {
const state = firstPage(pageOf([1, 2], 'c1'))
expect(state.items).toEqual([1, 2])
expect(state.nextCursor).toBe('c1')
expect(state.hasMore).toBe(true)
})
it('加载更多按序追加,nextCursor 为 null 即到底', () => {
let state = firstPage(pageOf([1, 2], 'c1'))
state = accumulatePage(state, pageOf([3], 'c2'))
expect(state.items).toEqual([1, 2, 3])
expect(state.hasMore).toBe(true)
state = accumulatePage(state, pageOf([4], null))
expect(state.items).toEqual([1, 2, 3, 4])
expect(state.hasMore).toBe(false)
})
it('keyOf 去重:跨页重复行不重复 append', () => {
let state = firstPage(pageOf([{ id: 'a' }, { id: 'b' }], 'c1'))
state = accumulatePage(state, pageOf([{ id: 'b' }, { id: 'c' }], null), (x) => x.id)
expect(state.items.map((x) => x.id)).toEqual(['a', 'b', 'c'])
})
})