fix(short-drama-agent-front): 修复代码格式检查问题
This commit is contained in:
1 parent
81d6a85260
commit
48fce3975f
87 files changed
+5714
-1436
No files matched your search
@@ -7,12 +7,25 @@ import { policyReceipt } from '../../fixtures/quality-policy'
|
||||
import { commitPreview } from '../../fixtures/breakdown-candidate'
|
||||
|
||||
/** 当前规则;格式版本不能代替服务修订版本。 */
|
||||
const policy = { version: 1 as const, physicsMode: 'realistic' as const, allowExaggeratedMotion: false, allowNonPhysicalActions: false, allowSupernaturalAbilities: false, customRules: [] }
|
||||
afterEach(() => { vi.restoreAllMocks(); vi.unstubAllGlobals(); localStorage.clear() })
|
||||
const policy = {
|
||||
version: 1 as const,
|
||||
physicsMode: 'realistic' as const,
|
||||
allowExaggeratedMotion: false,
|
||||
allowNonPhysicalActions: false,
|
||||
allowSupernaturalAbilities: false,
|
||||
customRules: []
|
||||
}
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
vi.unstubAllGlobals()
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
describe('服务端规则确认契约', () => {
|
||||
it('保存发送规则和期望修订,明确确认使用独立接口', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: policyReceipt('p', policy) })))
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: policyReceipt('p', policy) })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await projectsApi.saveQualityPolicy('p', policy, 2)
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]?.[1]?.body))).toEqual({ policy, expectedRevision: 2 })
|
||||
@@ -21,7 +34,9 @@ describe('服务端规则确认契约', () => {
|
||||
expect(JSON.parse(String(fetcher.mock.calls[1]?.[1]?.body))).toEqual({ expectedRevision: 2 })
|
||||
})
|
||||
it('服务已确认的规则跨浏览器直接进入费用确认,启动携带真实修订版本', async () => {
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(policyReceipt('p', policy, { confirmed: true, confirmedRevision: 2, confirmedAt: '2026-10-17T15:00:00Z' }))
|
||||
vi.spyOn(projectsApi, 'qualityPolicy').mockResolvedValue(
|
||||
policyReceipt('p', policy, { confirmed: true, confirmedRevision: 2, confirmedAt: '2026-10-17T15:00:00Z' })
|
||||
)
|
||||
const scope = effectScope()
|
||||
try {
|
||||
const flow = scope.run(() => useBreakdownStartPolicy(ref('p'), ref('scope'), ref(true)))!
|
||||
@@ -31,11 +46,19 @@ describe('服务端规则确认契约', () => {
|
||||
expect(await flow.verifyStart()).toBe(true)
|
||||
expect(flow.consumePermit()).toEqual({ expectedRevision: 2 })
|
||||
expect(flow.consumePermit()).toBeNull()
|
||||
} finally { scope.stop() }
|
||||
} finally {
|
||||
scope.stop()
|
||||
}
|
||||
})
|
||||
it('候选安全检查必须包含规则匹配,缺失或 false 均不可提交', () => {
|
||||
const preview = commitPreview()
|
||||
expect(candidatePreviewReady({ ...preview, checks: { ...preview.checks, qualityPolicyMatches: false } }, preview.projectId, preview.checkpointId)).toBe(false)
|
||||
expect(
|
||||
candidatePreviewReady(
|
||||
{ ...preview, checks: { ...preview.checks, qualityPolicyMatches: false } },
|
||||
preview.projectId,
|
||||
preview.checkpointId
|
||||
)
|
||||
).toBe(false)
|
||||
const missing = structuredClone(preview)
|
||||
delete (missing.checks as Partial<typeof missing.checks>).qualityPolicyMatches
|
||||
expect(candidatePreviewReady(missing, preview.projectId, preview.checkpointId)).toBe(false)
|
||||
|
||||
Reference in new issue
Block a user