feat(reviews): "Мои" tab — maker self-tracking with status filter

This commit is contained in:
Александр Зимин
2026-05-14 14:06:30 +00:00
parent a6a07428ed
commit be58b61913
6 changed files with 805 additions and 71 deletions
@@ -0,0 +1,67 @@
import { describe, it, expect } from 'vitest'
import {
classifyRecordStatus,
classifySchemaStatus,
} from './MyDraftsPanel'
import type { DraftStatus, SchemaDraftStatus } from '@/api/client'
describe('classifyRecordStatus', () => {
it('PENDING → pending bucket', () => {
expect(classifyRecordStatus('PENDING')).toBe('pending')
})
it.each<DraftStatus>(['APPROVED', 'REJECTED', 'WITHDRAWN'])(
'terminal status %s → decided bucket',
(s) => {
expect(classifyRecordStatus(s)).toBe('decided')
},
)
it('covers all DraftStatus variants — exhaustiveness check', () => {
// Sanity: every DraftStatus literal must land in exactly one bucket.
// If this fails after adding a new status, update the classifier and
// the bucket count tests in ReviewsPage's myActiveCount memo.
const all: DraftStatus[] = ['PENDING', 'APPROVED', 'REJECTED', 'WITHDRAWN']
const buckets = all.map(classifyRecordStatus)
expect(new Set(buckets)).toEqual(new Set(['pending', 'decided']))
})
})
describe('classifySchemaStatus', () => {
it('review_pending → pending (reviewer action needed)', () => {
expect(classifySchemaStatus('review_pending')).toBe('pending')
})
it('approved → pending (maker still needs to publish)', () => {
expect(classifySchemaStatus('approved')).toBe('pending')
})
it('draft → wip (maker action needed)', () => {
expect(classifySchemaStatus('draft')).toBe('wip')
})
it('changes_requested → wip (reviewer returned to maker)', () => {
expect(classifySchemaStatus('changes_requested')).toBe('wip')
})
it.each<SchemaDraftStatus>(['rejected', 'published', 'withdrawn'])(
'terminal status %s → decided',
(s) => {
expect(classifySchemaStatus(s)).toBe('decided')
},
)
it('covers all SchemaDraftStatus variants — exhaustiveness check', () => {
const all: SchemaDraftStatus[] = [
'draft',
'review_pending',
'approved',
'changes_requested',
'rejected',
'published',
'withdrawn',
]
const buckets = all.map(classifySchemaStatus)
expect(new Set(buckets)).toEqual(new Set(['pending', 'wip', 'decided']))
})
})