Add Logbuch: project update blog with admin, media and API
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.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { db } from '~/data/db'
|
||||
import { brands, projects } from '~/data/schema'
|
||||
import { findProjectBySlug, listBrands, listProjects } from '~/data/repositories/projects'
|
||||
|
||||
describe('listProjects', () => {
|
||||
it('liefert aktive Projekte nach Sortierung und Namen', async () => {
|
||||
const [brand] = await db.insert(brands).values({ slug: 'nyo', name: 'NYO' }).returning()
|
||||
await db.insert(projects).values([
|
||||
{ brandId: brand!.id, slug: 'trakk', name: 'Trakk', sort: 2 },
|
||||
{ brandId: brand!.id, slug: 'mta360', name: 'MTA360', sort: 1 },
|
||||
{ brandId: brand!.id, slug: 'alt', name: 'Altprojekt', isActive: false, sort: 0 },
|
||||
])
|
||||
|
||||
const result = await listProjects()
|
||||
|
||||
expect(result.map(project => project.slug)).toEqual(['mta360', 'trakk'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('listProjects sortiert nach der Spalte, nicht nach dem Alphabet', () => {
|
||||
it('stellt ein Projekt mit kleinerer Sortierung vor ein alphabetisch früheres', async () => {
|
||||
const [brand] = await db.insert(brands).values({ slug: 'nyo', name: 'NYO' }).returning()
|
||||
await db.insert(projects).values([
|
||||
{ brandId: brand!.id, slug: 'aaa', name: 'Aaa', sort: 9 },
|
||||
{ brandId: brand!.id, slug: 'zzz', name: 'Zzz', sort: 1 },
|
||||
])
|
||||
|
||||
const result = await listProjects()
|
||||
|
||||
expect(result.map(project => project.slug)).toEqual(['zzz', 'aaa'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('findProjectBySlug', () => {
|
||||
it('findet ein Projekt über seinen Slug', async () => {
|
||||
const [brand] = await db.insert(brands).values({ slug: 'nyo', name: 'NYO' }).returning()
|
||||
await db.insert(projects).values({ brandId: brand!.id, slug: 'trakk', name: 'Trakk' })
|
||||
|
||||
const project = await findProjectBySlug('trakk')
|
||||
|
||||
expect(project?.name).toBe('Trakk')
|
||||
})
|
||||
|
||||
it('liefert nichts für einen unbekannten Slug', async () => {
|
||||
await expect(findProjectBySlug('gibtsnicht')).resolves.toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('listBrands', () => {
|
||||
it('sortiert Marken nach Sortierung und Namen', async () => {
|
||||
await db.insert(brands).values([
|
||||
{ slug: 'pocket-rocket', name: 'Pocket Rocket', sort: 2 },
|
||||
{ slug: 'nyo', name: 'NYO', sort: 1 },
|
||||
])
|
||||
|
||||
const result = await listBrands()
|
||||
|
||||
expect(result.map(brand => brand.slug)).toEqual(['nyo', 'pocket-rocket'])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user