f8bc2d6108
- 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
52 lines
1.5 KiB
TypeScript
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')
|
|
})
|
|
})
|