fix: resolve confirmed character hidden bug, remove online font dependency, improve UI/UX experience

This commit is contained in:
saturn
2026-03-21 14:35:32 +08:00
parent f364bbc9e4
commit a6ad11b9c4
42 changed files with 1189 additions and 553 deletions

View File

@@ -11,7 +11,10 @@ const prismaMock = vi.hoisted(() => ({
novelPromotionEpisode: { findFirst: vi.fn() },
novelPromotionCharacter: { create: vi.fn(async () => ({ id: 'char-new-1' })) },
novelPromotionLocation: { create: vi.fn(async () => ({ id: 'loc-new-1' })) },
locationImage: { create: vi.fn(async () => ({})) },
locationImage: {
create: vi.fn(async () => ({})),
createMany: vi.fn(async () => ({ count: 1 })),
},
}))
const llmMock = vi.hoisted(() => ({
@@ -49,6 +52,7 @@ vi.mock('@/lib/prompt-i18n', () => ({
PROMPT_IDS: {
NP_AGENT_CHARACTER_PROFILE: 'char',
NP_SELECT_LOCATION: 'loc',
NP_SELECT_PROP: 'prop',
},
buildPrompt: vi.fn(() => 'analysis-prompt'),
}))
@@ -75,6 +79,10 @@ describe('worker analyze-novel behavior', () => {
beforeEach(() => {
vi.clearAllMocks()
prismaMock.novelPromotionLocation.create
.mockResolvedValueOnce({ id: 'loc-new-1' })
.mockResolvedValueOnce({ id: 'prop-new-1' })
prismaMock.project.findUnique.mockResolvedValue({
id: 'project-1',
mode: 'novel-promotion',
@@ -114,6 +122,14 @@ describe('worker analyze-novel behavior', () => {
},
],
}))
.mockReturnValueOnce(JSON.stringify({
props: [
{
name: '金箍棒',
summary: '一根两头包裹金片的黑铁长棍',
},
],
}))
})
it('no global text and no episode text -> explicit error', async () => {
@@ -137,10 +153,10 @@ describe('worker analyze-novel behavior', () => {
success: true,
characters: [{ id: 'char-new-1' }],
locations: [{ id: 'loc-new-1' }],
props: [],
props: [{ id: 'prop-new-1' }],
characterCount: 1,
locationCount: 1,
propCount: 0,
propCount: 1,
})
expect(prismaMock.novelPromotionCharacter.create).toHaveBeenCalledWith(
@@ -163,12 +179,24 @@ describe('worker analyze-novel behavior', () => {
}),
)
expect(prismaMock.locationImage.create).toHaveBeenCalledWith({
data: {
locationId: 'loc-new-1',
imageIndex: 0,
description: '雨夜街道',
},
expect(prismaMock.locationImage.create).not.toHaveBeenCalled()
expect(prismaMock.locationImage.createMany).toHaveBeenNthCalledWith(1, {
data: [
{
locationId: 'loc-new-1',
imageIndex: 0,
description: '雨夜街道',
},
],
})
expect(prismaMock.locationImage.createMany).toHaveBeenNthCalledWith(2, {
data: [
{
locationId: 'prop-new-1',
imageIndex: 0,
description: '一根两头包裹金片的黑铁长棍',
},
],
})
expect(prismaMock.novelPromotionProject.update).toHaveBeenCalledWith({