Files
replypier/frontend/src/__tests__/services/knowledge.errors.spec.ts
T
WangShen007 6cd904d460 docs: 交付文档、维护指引与端到端回归
补齐 README、开发计划、维护交接与 E2E 用例,执行最终验收。
2026-10-21 21:40:00 +08:00

16 lines
680 B
TypeScript

import { describe, it, expect, vi } from 'vitest'
vi.mock('@/services/api', () => ({ default: { post: vi.fn() } }))
import api from '@/services/api'
import { knowledgeService } from '@/services/knowledge'
describe('knowledgeService errors', () => {
it('a URL the server refuses reads as a sentence, not [object Object]', async () => {
vi.mocked(api.post).mockRejectedValue({
response: { status: 422, data: { detail: [{ loc: ['body', 'websites'], msg: 'Value error, URL must contain a valid domain with TLD' }] } },
})
await expect(knowledgeService.addUrls('org-1', ['https://localhost'])).rejects.toThrow('URL must contain a valid domain with TLD')
})
})