Publication IA: - 4 templates (magazine, brief, essay, simple) avec CSS riche - Rewrite IA (article/exercises/tutorial/reference/mixed) - Modération avec timeout 12s + fallback safe - Quotas publish_enhance par tier (basic=2, pro=15, business=100) - Détection contenu stale (hash) - Migration DB publishedContent/publishedTemplate/publishedSourceHash Fixes: - cheerio v1.2: Element -> AnyNode (domhandler), decodeEntities cast - _isShared ajouté au type Note (champ virtuel serveur) - callout colors PDF export: extraction fonction pure testable - admin/published: guard note.userId null - Cmd+S fonctionne en mode dialog (pas seulement fullPage) i18n: - 23 clés publish* traduites dans les 15 locales - Extension Web Clipper: 13 locales mise à jour Tests: - callout-colors.test.ts (6 tests) - note-visible-in-view.test.ts (5 tests) - entitlements.test.ts + byok-entitlements.test.ts: mock usageLog + unstubAllEnvs - 199/199 tests passent Tracker: user-stories.md sync avec sprint-status.yaml
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { describe, test, expect } from 'vitest'
|
|
import { getCalloutColors } from '../../lib/editor/callout-colors'
|
|
|
|
describe('getCalloutColors', () => {
|
|
test('returns correct colors for each known type', () => {
|
|
expect(getCalloutColors('info')).toEqual({ bg: '#eff6ff', border: '#93c5fd' })
|
|
expect(getCalloutColors('warning')).toEqual({ bg: '#fffbeb', border: '#fcd34d' })
|
|
expect(getCalloutColors('tip')).toEqual({ bg: '#faf5ff', border: '#c4b5fd' })
|
|
expect(getCalloutColors('success')).toEqual({ bg: '#f0fdf4', border: '#86efac' })
|
|
expect(getCalloutColors('danger')).toEqual({ bg: '#fef2f2', border: '#fca5a5' })
|
|
})
|
|
|
|
test('falls back to info for null', () => {
|
|
expect(getCalloutColors(null)).toEqual({ bg: '#eff6ff', border: '#93c5fd' })
|
|
})
|
|
|
|
test('falls back to info for undefined', () => {
|
|
expect(getCalloutColors(undefined)).toEqual({ bg: '#eff6ff', border: '#93c5fd' })
|
|
})
|
|
|
|
test('falls back to info for unknown type', () => {
|
|
expect(getCalloutColors('unknown')).toEqual({ bg: '#eff6ff', border: '#93c5fd' })
|
|
expect(getCalloutColors('')).toEqual({ bg: '#eff6ff', border: '#93c5fd' })
|
|
})
|
|
|
|
test('returned object always has bg and border as strings', () => {
|
|
const types = ['info', 'warning', 'tip', 'success', 'danger', null, undefined, 'unknown']
|
|
for (const t of types) {
|
|
const c = getCalloutColors(t)
|
|
expect(typeof c.bg).toBe('string')
|
|
expect(typeof c.border).toBe('string')
|
|
expect(c.bg.length).toBeGreaterThan(0)
|
|
expect(c.border.length).toBeGreaterThan(0)
|
|
}
|
|
})
|
|
|
|
test('returns consistent references for same input', () => {
|
|
const a = getCalloutColors('info')
|
|
const b = getCalloutColors('info')
|
|
expect(a).toEqual(b)
|
|
})
|
|
})
|