Files
Webklar-Kundenbereich/test/knZoomAusgleich.test.js
T
ClaudeandClaude Opus 5.5 ff8adadf00 Kundenansicht neu: vorübergehende iPhone-Messung wieder entfernt
Die Messung aus cca29a4 hat beide Ursachen gezeigt (Chat kürzer als der
Bildschirm, verkleinerte Seite mit Hineinzoomen beim Tippen). Nach
1a09beb zeigt sie am iPhone: Maßstab bleibt beim Tippen 0,85, Fenster
1002 px, Leiste unten. diag-hoehe.js, routes/diagHoehe.js, die Zeile in
server/index.js und test/diagHoehe.test.js sind raus; server/index.js
ist wieder wie vor der Messung.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 11:33:16 +00:00

47 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { ausgleichFaktor, beobachteZoom } from '../public/neu/zoom-ausgleich.js'
import { lies } from './support/knHuelle.js'
test('ausgleichFaktor: 85 % (iPhone 2026-10-29) ergibt 16 px × 1,188 ≈ 16,2 pt auf dem Bildschirm; 100 %, hineingezoomt und Unsinn ergeben 1', () => {
const f = ausgleichFaktor(0.8506)
assert.equal(f, 1.188)
assert.ok(16 * f * 0.8506 >= 16)
assert.equal(ausgleichFaktor(0.5), 2.02)
for (const s of [1, 0.99, 1.5, 0, -1, NaN, undefined]) assert.equal(ausgleichFaktor(s), 1)
})
function aufbau(scale) {
const hoerer = []
const vv = { scale, addEventListener: (t, fn) => hoerer.push(fn), removeEventListener: (t, fn) => hoerer.splice(hoerer.indexOf(fn), 1), feuere: () => hoerer.forEach((fn) => fn()) }
const klassen = new Set(); const stil = {}
const doc = {
activeElement: null,
documentElement: {
classList: { add: (k) => klassen.add(k), remove: (k) => klassen.delete(k) },
style: { setProperty: (k, v) => { stil[k] = v }, removeProperty: (k) => { delete stil[k] } },
},
}
return { vv, doc, klassen, stil, hoerer, win: { visualViewport: vv } }
}
test('beobachteZoom: setzt Klasse und Faktor bei 85 %, nimmt sie bei 100 % weg, ändert nichts während ein Textfeld den Fokus hat', () => {
const t = aufbau(0.8506)
const feld = { feld: true }
const z = beobachteZoom({ win: t.win, doc: t.doc, istTextfeld: (el) => el?.feld === true })
assert.deepEqual([[...t.klassen], t.stil, z.faktor()], [['kn-zoom-ausgleich'], { '--kn-zoom-ausgleich': '1.188' }, 1.188])
t.doc.activeElement = feld; t.vv.scale = 1; t.vv.feuere() // iOS zoomt beim Tippen: nichts umstellen
assert.equal(z.faktor(), 1.188)
t.doc.activeElement = null; t.vv.feuere()
assert.deepEqual([[...t.klassen], t.stil, z.faktor()], [[], {}, 1])
z.beende(); assert.equal(t.hoerer.length, 0)
const ohne = beobachteZoom({ win: {}, doc: t.doc }); assert.equal(ohne.faktor(), 1); ohne.beende()
})
test('huelle.css und huelle.js: Ausgleich nur über die Klasse an <html>, für alle Textfelder der Kundenansicht, nur auf iOS verdrahtet', () => {
const css = lies('huelle.css')
assert.match(css, /\.kn-zoom-ausgleich \.kn :is\(input:not\(\[type="checkbox"\]\)[^{]*, textarea, select\) \{ font-size: calc\(16px \* var\(--kn-zoom-ausgleich, 1\)\) !important; \}/)
const js = lies('huelle.js')
assert.match(js, /if \(istIos\(\)\) beobachteZoom\(\{ win, doc, istTextfeld \}\)/)
})