refactor(approval-ux): eng-review fixes — extract helpers, add tests, register i18n

This commit is contained in:
Александр Зимин
2026-05-14 13:52:12 +00:00
parent 31ad140a02
commit 4c29f4e7cb
8 changed files with 365 additions and 109 deletions
@@ -0,0 +1,23 @@
import { describe, expect, it } from 'vitest'
import type { SchemaDraft } from '@/api/client'
import { pickSeedSchema } from './CreateSchemaDraftModal'
const draft = (proposed: unknown): SchemaDraft =>
({ proposedSchema: proposed } as unknown as SchemaDraft)
describe('pickSeedSchema', () => {
it('edit-mode draft wins over pre-fill and live HEAD', () => {
const seed = pickSeedSchema(draft({ type: 'edit' }), { type: 'pre-fill' }, { type: 'head' })
expect(seed).toEqual({ type: 'edit' })
})
it('caller pre-fill wins over live HEAD when no edit-mode draft', () => {
const seed = pickSeedSchema(undefined, { type: 'pre-fill' }, { type: 'head' })
expect(seed).toEqual({ type: 'pre-fill' })
})
it('falls back to live HEAD when neither edit draft nor pre-fill provided', () => {
const seed = pickSeedSchema(undefined, undefined, { type: 'head' })
expect(seed).toEqual({ type: 'head' })
})
})