refactor: remove obsolete project mode

This commit is contained in:
saturn
2026-03-25 15:39:16 +08:00
parent fd8f5f8635
commit ca5d8a58f7
47 changed files with 40 additions and 157 deletions

View File

@@ -68,14 +68,14 @@ vi.mock('@/lib/api-auth', () => {
if (!authState.authenticated) return unauthorized()
return {
session: { user: { id: 'user-1' } },
project: { id: projectId, userId: 'user-1', mode: 'novel-promotion' },
project: { id: projectId, userId: 'user-1' },
}
},
requireProjectAuthLight: async (projectId: string) => {
if (!authState.authenticated) return unauthorized()
return {
session: { user: { id: 'user-1' } },
project: { id: projectId, userId: 'user-1', mode: 'novel-promotion' },
project: { id: projectId, userId: 'user-1' },
}
},
}

View File

@@ -4,7 +4,6 @@ import { buildMockRequest } from '../../../helpers/request'
type AuthState = {
authenticated: boolean
projectMode: 'novel-promotion' | 'other'
}
type SubmitResult = {
@@ -28,7 +27,6 @@ type DirectRouteCase = {
const authState = vi.hoisted<AuthState>(() => ({
authenticated: true,
projectMode: 'novel-promotion',
}))
const submitTaskMock = vi.hoisted(() => vi.fn<(...args: unknown[]) => Promise<SubmitResult>>())
@@ -218,14 +216,14 @@ vi.mock('@/lib/api-auth', () => {
if (!authState.authenticated) return unauthorized()
return {
session: { user: { id: 'user-1' } },
project: { id: projectId, userId: 'user-1', mode: authState.projectMode },
project: { id: projectId, userId: 'user-1' },
}
},
requireProjectAuthLight: async (projectId: string) => {
if (!authState.authenticated) return unauthorized()
return {
session: { user: { id: 'user-1' } },
project: { id: projectId, userId: 'user-1', mode: authState.projectMode },
project: { id: projectId, userId: 'user-1' },
}
},
}
@@ -534,7 +532,6 @@ describe('api contract - direct submit routes (behavior)', () => {
beforeEach(() => {
vi.clearAllMocks()
authState.authenticated = true
authState.projectMode = 'novel-promotion'
let seq = 0
submitTaskMock.mockImplementation(async () => ({
taskId: `task-${++seq}`,

View File

@@ -5,7 +5,6 @@ import { buildMockRequest } from '../../../helpers/request'
type AuthState = {
authenticated: boolean
projectMode: 'novel-promotion' | 'other'
}
type LLMRouteCase = {
@@ -23,7 +22,6 @@ type RouteContext = {
const authState = vi.hoisted<AuthState>(() => ({
authenticated: true,
projectMode: 'novel-promotion',
}))
const maybeSubmitLLMTaskMock = vi.hoisted(() =>
@@ -77,14 +75,14 @@ vi.mock('@/lib/api-auth', () => {
if (!authState.authenticated) return unauthorized()
return {
session: { user: { id: 'user-1' } },
project: { id: projectId, userId: 'user-1', mode: authState.projectMode },
project: { id: projectId, userId: 'user-1' },
}
},
requireProjectAuthLight: async (projectId: string) => {
if (!authState.authenticated) return unauthorized()
return {
session: { user: { id: 'user-1' } },
project: { id: projectId, userId: 'user-1', mode: authState.projectMode },
project: { id: projectId, userId: 'user-1' },
}
},
}
@@ -329,7 +327,6 @@ describe('api contract - llm observe routes (behavior)', () => {
beforeEach(() => {
vi.clearAllMocks()
authState.authenticated = true
authState.projectMode = 'novel-promotion'
maybeSubmitLLMTaskMock.mockResolvedValue(
NextResponse.json({
success: true,

View File

@@ -4,7 +4,7 @@ import { buildMockRequest } from '../../../helpers/request'
const authMock = vi.hoisted(() => ({
requireProjectAuthLight: vi.fn(async () => ({
session: { user: { id: 'user-1', name: 'User 1' } },
project: { id: 'project-1', userId: 'user-1', mode: 'novel-promotion', name: 'Project 1' },
project: { id: 'project-1', userId: 'user-1', name: 'Project 1' },
})),
isErrorResponse: vi.fn((value: unknown) => value instanceof Response),
}))

View File

@@ -27,7 +27,7 @@ type StoryboardRecord = {
const authMock = vi.hoisted(() => ({
requireProjectAuthLight: vi.fn(async () => ({
session: { user: { id: 'user-1' } },
project: { id: 'project-1', userId: 'user-1', mode: 'novel-promotion' },
project: { id: 'project-1', userId: 'user-1' },
})),
isErrorResponse: vi.fn((value: unknown) => value instanceof Response),
}))

View File

@@ -28,7 +28,6 @@ const prismaMock = vi.hoisted(() => ({
id: 'project-1',
name: 'Test Project',
description: null,
mode: 'novel-promotion',
userId: 'user-1',
})),
},
@@ -60,6 +59,13 @@ describe('api specific - project create default audio model', () => {
const res = await mod.POST(req, routeContext)
expect(res.status).toBe(201)
expect(prismaMock.project.create).toHaveBeenCalledWith({
data: {
name: 'Test Project',
description: null,
userId: 'user-1',
},
})
expect(prismaMock.novelPromotionProject.create).toHaveBeenCalledWith({
data: expect.objectContaining({
projectId: 'project-1',

View File

@@ -4,7 +4,7 @@ import { buildMockRequest } from '../../../helpers/request'
const authMock = vi.hoisted(() => ({
requireProjectAuthLight: vi.fn(async () => ({
session: { user: { id: 'user-1' } },
project: { id: 'project-1', userId: 'user-1', mode: 'novel-promotion' },
project: { id: 'project-1', userId: 'user-1' },
})),
isErrorResponse: vi.fn((value: unknown) => value instanceof Response),
}))

View File

@@ -4,7 +4,7 @@ import { buildMockRequest } from '../../../helpers/request'
const authMock = vi.hoisted(() => ({
requireProjectAuthLight: vi.fn(async () => ({
session: { user: { id: 'user-1' } },
project: { id: 'project-1', userId: 'user-1', mode: 'novel-promotion' },
project: { id: 'project-1', userId: 'user-1' },
})),
isErrorResponse: vi.fn((value: unknown) => value instanceof Response),
}))

View File

@@ -14,7 +14,7 @@ const queueState = vi.hoisted(() => ({
const prismaMock = vi.hoisted(() => ({
project: {
findUnique: vi.fn(async () => ({ id: 'project-1', mode: 'novel-promotion' })),
findUnique: vi.fn(async () => ({ id: 'project-1' })),
},
novelPromotionProject: {
findFirst: vi.fn(async () => ({ id: 'np-project-1' })),