refactor(approval-ux): eng-review fixes — extract helpers, add tests, register i18n
This commit is contained in:
@@ -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' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user