Terminplaner: Einbau-Skript – Nachbesserungen
429 ohne Schleife (Meldung und Erneut-versuchen-Knopf, Formulare bleiben stehen), Schriftfarbe auf der Betriebsfarbe mit mindestens 4,5 : 1, AGB-Link aus der oeffentlichen Konfiguration (betrieb.agbUrl), Haken starten bei geaenderter Auswahl ohne Haken, Fehler ohne Feld nicht verschluckt, Konfiguration fail closed, ladeNeu fuer Neuladen und neu_laden, Tastatur und Fokus (Modifikatoren, Monatspfeile, Belehrungstext), Aufraeumen. UI-Testserver: Timer, offene Verbindungen, Hinweis auf sessionCookie. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5fef7e47f0
commit
4465ac7b94
9 files changed
+501
-88
No files matched your search
@@ -80,6 +80,62 @@ test('Stile stehen einmal in <style id="wkt-style">, alle Klassen beginnen mit w
|
||||
assert.equal([...QUELLE.matchAll(/getElementById\(STYLE_ID\)/g)].length, 1)
|
||||
})
|
||||
|
||||
test('Ausweichtext wird nie verbraucht (nur Kopien zurueck auf die Seite), Link auf die AGB nur als https-Link', () => {
|
||||
assert.ok(!/appendChild\(ausweich\)/.test(OHNE_KOMMENTARE), 'der Ausweichtext darf nur als cloneNode(true) zurueckgesetzt werden')
|
||||
assert.ok(OHNE_KOMMENTARE.includes('ausweich.cloneNode(true)'))
|
||||
assert.ok(QUELLE.includes('agbUrl') && QUELLE.includes('AGB des Betriebs'))
|
||||
assert.match(OHNE_KOMMENTARE, /httpsUrl\(c\.betrieb\.agbUrl\)/)
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------- Textfarbe auf der Betriebsfarbe (Kontrast)
|
||||
|
||||
/** Die reinen Farbfunktionen des Skripts (zwischen den Marken @farben-anfang und @farben-ende) einzeln ausfuehren. */
|
||||
function farbFunktionen() {
|
||||
const m = /\/\/ @farben-anfang[^\n]*\n([\s\S]*?)\/\/ @farben-ende/.exec(QUELLE)
|
||||
assert.ok(m, 'Marken @farben-anfang/@farben-ende fehlen')
|
||||
return vm.runInNewContext(`${m[1]}; ({ luminanz, kontrast, textFarbeAuf })`, {})
|
||||
}
|
||||
|
||||
// Unabhaengige Gegenrechnung (WCAG 2.1: relative Leuchtdichte und Kontrastverhaeltnis)
|
||||
function wcagKontrast(hexA, hexB) {
|
||||
const l = (hex) => {
|
||||
const [r, g, b] = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4))
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||
}
|
||||
const [x, y] = [l(hexA), l(hexB)]
|
||||
return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05)
|
||||
}
|
||||
|
||||
test('Textfarbe auf der Betriebsfarbe erreicht mindestens 4,5 : 1 (auch fuer mittlere Toene)', () => {
|
||||
const { textFarbeAuf } = farbFunktionen()
|
||||
// Mitteltoene, bei denen Weiss allein nur 2,5 bis 3,6 : 1 haette
|
||||
for (const farbe of ['#ea580c', '#16a34a', '#0ea5e9', '#14b8a6', '#ec4899']) {
|
||||
const text = textFarbeAuf(farbe)
|
||||
assert.ok(wcagKontrast(farbe, text) >= 4.5, `${farbe}: ${text} nur ${wcagKontrast(farbe, text).toFixed(2)} : 1`)
|
||||
assert.ok(wcagKontrast(farbe, text) >= wcagKontrast(farbe, '#ffffff') - 1e-9, `${farbe}: Weiss waere besser gewesen`)
|
||||
}
|
||||
// dunkle und helle Farben behalten Weiss bzw. das dunkle Grau
|
||||
assert.equal(textFarbeAuf('#0f766e'), '#ffffff')
|
||||
assert.equal(textFarbeAuf('#1d4ed8'), '#ffffff')
|
||||
assert.equal(textFarbeAuf('#fde68a'), '#111827')
|
||||
assert.equal(textFarbeAuf('#ffffff'), '#111827')
|
||||
assert.equal(textFarbeAuf('#000000'), '#ffffff')
|
||||
})
|
||||
|
||||
test('Textfarbe: kein Farbton faellt unter 4,5 : 1 (alle Grautoene und ein Raster ueber den Farbraum)', () => {
|
||||
const { textFarbeAuf, luminanz, kontrast } = farbFunktionen()
|
||||
const hex = (r, g, b) => `#${[r, g, b].map((c) => c.toString(16).padStart(2, '0')).join('')}`
|
||||
const proben = []
|
||||
for (let g = 0; g < 256; g += 1) proben.push(hex(g, g, g))
|
||||
for (let r = 0; r < 256; r += 15) for (let g = 0; g < 256; g += 15) for (let b = 0; b < 256; b += 15) proben.push(hex(r, g, b))
|
||||
for (const farbe of proben) {
|
||||
const text = textFarbeAuf(farbe)
|
||||
assert.ok(['#ffffff', '#111827', '#000000'].includes(text), `${farbe}: unerwartete Textfarbe ${text}`)
|
||||
assert.ok(wcagKontrast(farbe, text) >= 4.5, `${farbe}: ${text} nur ${wcagKontrast(farbe, text).toFixed(2)} : 1`)
|
||||
assert.ok(Math.abs(kontrast(luminanz(farbe), luminanz(text)) - wcagKontrast(farbe, text)) < 1e-9, `${farbe}: Skript und Gegenrechnung weichen ab`)
|
||||
}
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------- Demo und Einbauanleitung
|
||||
|
||||
test('Demo-Seite: noindex, Ausweichtext, Skript per defer, beide Modi', () => {
|
||||
|
||||
Reference in new issue
Block a user