b90ff252d1
Public archive with sidebar navigation, project pages, month archive, search and entry pages with image blocks. Admin area for brands, projects, post types, users, api clients, media and the entry editor with drag and drop images, preview per audience, scheduling and publish checks. Read and write API with bearer tokens, audience scoping, idempotent creation, OpenAPI document and editorial guide. Magic link login with configurable allowed domains, whole app behind the session gate. 456 tests including design rule checks.
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { canTransition } from '~/domain/post-status'
|
|
import type { PostStatus } from '~/domain/types'
|
|
|
|
describe('canTransition', () => {
|
|
it('erlaubt den Weg vom Entwurf bis zur Veröffentlichung', () => {
|
|
expect(canTransition('draft', 'review')).toBe(true)
|
|
expect(canTransition('review', 'published')).toBe(true)
|
|
expect(canTransition('draft', 'published')).toBe(true)
|
|
expect(canTransition('draft', 'scheduled')).toBe(true)
|
|
expect(canTransition('scheduled', 'published')).toBe(true)
|
|
})
|
|
|
|
it('erlaubt Zurückziehen und Wiederaufnahme', () => {
|
|
expect(canTransition('published', 'archived')).toBe(true)
|
|
expect(canTransition('archived', 'draft')).toBe(true)
|
|
})
|
|
|
|
it('verbietet Sprünge zurück aus der Veröffentlichung in den Entwurf', () => {
|
|
expect(canTransition('published', 'draft')).toBe(false)
|
|
expect(canTransition('published', 'review')).toBe(false)
|
|
})
|
|
|
|
it('verbietet gleichbleibenden Status als Übergang', () => {
|
|
expect(canTransition('draft', 'draft')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('canTransition deckt alle 25 Paare ab', () => {
|
|
const states: PostStatus[] = ['draft', 'review', 'scheduled', 'published', 'archived']
|
|
|
|
const expected: Record<PostStatus, PostStatus[]> = {
|
|
draft: ['review', 'scheduled', 'published', 'archived'],
|
|
review: ['draft', 'scheduled', 'published', 'archived'],
|
|
scheduled: ['draft', 'published', 'archived'],
|
|
published: ['archived'],
|
|
archived: ['draft'],
|
|
}
|
|
|
|
for (const from of states) {
|
|
for (const to of states) {
|
|
const allowed = expected[from].includes(to)
|
|
|
|
it(`${from} nach ${to}: ${allowed}`, () => {
|
|
expect(canTransition(from, to)).toBe(allowed)
|
|
})
|
|
}
|
|
}
|
|
})
|