Files
logbuch/tests/components/entry-status-control.test.tsx
Matthias G f8bc2d6108 Choose any allowed status in the table, set the cover on create
- the status cell offers every transition the entry allows, scheduling
  asks for the date right there
- POST /api/v1/posts takes cover_media_id, no second call needed
- the row grid follows its content so long type names stop overlapping
2026-08-01 15:34:13 +02:00

52 lines
1.5 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import type { PostStatus } from '~/domain/types'
vi.mock('next-intl', () => ({
useTranslations: () => (key: string) => key,
}))
vi.mock('~/lib/entry-actions', () => ({
archiveEntry: vi.fn(),
publishEntry: vi.fn(),
resumeEntry: vi.fn(),
scheduleEntry: vi.fn(),
}))
const { EntryStatusControl } = await import('~/components/admin/EntryStatusControl')
function render(status: PostStatus): string {
return renderToStaticMarkup(<EntryStatusControl id="e1f7f2f0-0000-4000-8000-000000000001" status={status} />)
}
describe('EntryStatusControl', () => {
it('stellt jedem Status seine erlaubten Ziele zur Wahl', () => {
const draft = render('draft')
expect(draft).toContain('move.scheduled')
expect(draft).toContain('move.published')
expect(draft).toContain('move.archived')
expect(draft).not.toContain('move.draft')
})
it('lässt Veröffentlichtes nur zurückziehen', () => {
const published = render('published')
expect(published).toContain('move.archived')
expect(published).not.toContain('move.published')
expect(published).not.toContain('move.scheduled')
})
it('führt Zurückgezogenes zurück in den Entwurf', () => {
const archived = render('archived')
expect(archived).toContain('move.draft')
expect(archived).not.toContain('move.archived')
})
it('zeigt den Status immer an', () => {
expect(render('draft')).toContain('status.draft')
expect(render('published')).toContain('status.published')
})
})