Prüfung / Lint, Typen, Tests (push) Canceled after 0s
Prüfung / Images bauen (pdf) (push) Canceled after 0s
Prüfung / Images bauen (web) (push) Canceled after 0s
Prüfung / Images bauen (worker) (push) Canceled after 0s
Images / bauen (pdf, docker/pdf.Dockerfile) (push) Canceled after 0s
Images / bauen (web, docker/web.Dockerfile) (push) Canceled after 0s
Images / bauen (worker, docker/worker.Dockerfile) (push) Canceled after 0s
375 Vorkommen in 210 Dateien. Betrifft Kommentare, Oberflaechentexte und die README; an keiner Stelle Bedeutung, nur Zeichensetzung.
61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { readFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
const css = readFileSync(join(process.cwd(), 'app/globals.css'), 'utf8')
|
|
|
|
/**
|
|
* Das helle Thema ist verpflichtend, siehe docs/10-design-system.md. Diese
|
|
* Tests halten die zwei Eigenschaften fest, die es leicht verliert: dass es
|
|
* wirklich jede semantische Farbe tauscht, und dass eine Freigabestufe in
|
|
* beiden Themen dieselbe Farbe behält - sonst lernt man sie zweimal.
|
|
*/
|
|
describe('Helles Thema', () => {
|
|
const semantisch = [
|
|
'--color-surface',
|
|
'--color-panel',
|
|
'--color-raised',
|
|
'--color-line',
|
|
'--color-text',
|
|
'--color-text-dim',
|
|
'--color-accent',
|
|
]
|
|
|
|
function block(selektor: string): string {
|
|
const index = css.indexOf(selektor)
|
|
expect(index, `${selektor} fehlt`).toBeGreaterThan(-1)
|
|
return css.slice(index, css.indexOf('}', index))
|
|
}
|
|
|
|
it('tauscht jede semantische Farbe', () => {
|
|
const hell = block("[data-theme='light'] {")
|
|
for (const token of semantisch) {
|
|
expect(hell, `${token} fehlt im hellen Thema`).toContain(token)
|
|
}
|
|
})
|
|
|
|
it('folgt ohne Wahl dem System und bleibt sonst dunkel', () => {
|
|
// Der Auslieferungszustand ist dunkel: das helle Thema greift nur bei
|
|
// prefers-color-scheme: light oder ausdrücklicher Wahl.
|
|
expect(css).toContain('@media (prefers-color-scheme: light)')
|
|
expect(css).toContain(":root:not([data-theme='dark'])")
|
|
})
|
|
|
|
it('behält die Klassifizierungsfarben als eigenes System', () => {
|
|
// Die Farbtöne dürfen für hellen Grund nachgedunkelt werden, aber es muss
|
|
// sie geben - sonst verschwindet der Stempel auf hellem Papier.
|
|
const hell = css.slice(css.indexOf("[data-theme='light']"))
|
|
for (const stufe of [0, 1, 2, 3, 4, 5]) {
|
|
expect(hell).toContain(`--color-stamp-${stufe}`)
|
|
}
|
|
})
|
|
|
|
it('lässt die Grundpalette unangetastet', () => {
|
|
// `--ink-*` und `--paper*` sind die Rohfarben. Würde das helle Thema sie
|
|
// umdefinieren, hinge daran alles, was sie direkt benutzt.
|
|
const hell = block("[data-theme='light'] {")
|
|
expect(hell).not.toContain('--color-ink-')
|
|
expect(hell).not.toContain('--color-paper')
|
|
})
|
|
})
|