feat: initial release v0.3.0

This commit is contained in:
saturn
2026-03-08 03:15:27 +08:00
commit 881ed44996
1311 changed files with 225407 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { buildMockRequest } from '../../../helpers/request'
import {
installAuthMocks,
mockAuthenticated,
mockUnauthenticated,
resetAuthMockState,
} from '../../../helpers/auth'
describe('api specific - characters POST', () => {
beforeEach(() => {
vi.resetModules()
resetAuthMockState()
})
it('returns unauthorized when user is not authenticated', async () => {
installAuthMocks()
mockUnauthenticated()
const mod = await import('@/app/api/asset-hub/characters/route')
const req = buildMockRequest({
path: '/api/asset-hub/characters',
method: 'POST',
body: { name: 'A' },
})
const res = await mod.POST(req, { params: Promise.resolve({}) })
expect(res.status).toBe(401)
})
it('returns invalid params when name is missing', async () => {
installAuthMocks()
mockAuthenticated('user-a')
const mod = await import('@/app/api/asset-hub/characters/route')
const req = buildMockRequest({
path: '/api/asset-hub/characters',
method: 'POST',
body: {},
})
const res = await mod.POST(req, { params: Promise.resolve({}) })
const body = await res.json()
expect(res.status).toBe(400)
expect(body.error.code).toBe('INVALID_PARAMS')
})
it('returns invalid params when artStyle is missing', async () => {
installAuthMocks()
mockAuthenticated('user-a')
const mod = await import('@/app/api/asset-hub/characters/route')
const req = buildMockRequest({
path: '/api/asset-hub/characters',
method: 'POST',
body: { name: 'Hero' },
})
const res = await mod.POST(req, { params: Promise.resolve({}) })
const body = await res.json()
expect(res.status).toBe(400)
expect(body.error.code).toBe('INVALID_PARAMS')
})
})