feat: 全局资产库直接展示全部图片

This commit is contained in:
GouJ
2026-09-22 10:54:23 +08:00
parent eec957a2e4
commit fec3b8dcac
5 changed files with 250 additions and 59 deletions
+13
View File
@@ -20,6 +20,19 @@ const asset: ProjectAsset = {
afterEach(() => vi.unstubAllGlobals())
describe('项目资产 API', () => {
it('通过单个全局接口读取全部项目素材', async () => {
const globalAsset = {
...asset,
project: { id: 'project-db-1', title: '记忆当铺', topic: '记忆交易', status: 'completed' }
}
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(new Response(JSON.stringify({ data: [globalAsset] })))
vi.stubGlobal('fetch', fetcher)
await expect(projectAssetsApi.listAll()).resolves.toEqual([globalAsset])
expect(fetcher).toHaveBeenCalledOnce()
expect(fetcher).toHaveBeenCalledWith('/api/assets', expect.objectContaining({ method: 'GET' }))
})
it('使用 multipart 上传文件,不手工设置 Content-Type', async () => {
const fetcher = vi
.fn<typeof fetch>()