Der Fix 0fa8fdb hat die zu hoch stehende Leiste am iPhone nicht
behoben. Damit wir nicht weiter raten: die Seite schickt am iPhone
Bildschirmwerte (Fenster, visualViewport, Bildschirm, Safe-Area,
vh-Einheiten, Lage der Leiste, Eingriffe von hoehe.js) an
/api/diag/hoehe, der Server schreibt sie als Zeile "[diag-hoehe]" ins
Log. Keine Inhalte, nur Pilot-Kunden (nicht die Mitarbeiter-Ansicht),
höchstens 80 Meldungen je Seite und 400 Zeilen je Kunde und Stunde.
Wird nach der Klärung wieder entfernt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
3.0 KiB
JavaScript
58 lines
3.0 KiB
JavaScript
import { test, after } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { startAppwriteMock } from './support/appwriteMock.js'
|
|
import { startFakeStripe } from './support/fakeStripe.js'
|
|
import { useTestEnv } from './support/testEnv.js'
|
|
|
|
// Vorübergehende Messung der iPhone-Höhe (routes/diagHoehe.js): nur Pilot-Kunden schreiben ins Log, alle bekommen 204
|
|
const aw = await startAppwriteMock({ schema: {} })
|
|
const st = await startFakeStripe()
|
|
useTestEnv({ appwriteUrl: aw.url, stripeUrl: st.url })
|
|
const { config } = await import('../server/config.js')
|
|
const { startTestApp, send } = await import('./support/testApp.js')
|
|
const { customerCookie, kundenansichtCookie } = await import('./support/fixtures.js')
|
|
const { default: diagHoeheRoutes, MAX_BYTES, MAX_JE_STUNDE } = await import('../server/routes/diagHoehe.js')
|
|
const app = await startTestApp({ '/api/diag/hoehe': diagHoeheRoutes })
|
|
after(() => Promise.all([app.close(), aw.close(), st.close()]))
|
|
|
|
const stelle = (mode, pilotEmails = []) => Object.assign(config.kundenansichtNeu, { mode, pilotEmails })
|
|
async function mitLog(fn) {
|
|
const zeilen = []
|
|
const alt = console.log
|
|
console.log = (...a) => { if (String(a[0]).startsWith('[diag-hoehe]')) zeilen.push(a.join(' ')); else alt(...a) }
|
|
try { await fn() } finally { console.log = alt }
|
|
return zeilen
|
|
}
|
|
const melde = (body, cookie) => send('POST', '/api/diag/hoehe', { body, cookie })
|
|
|
|
test('diag-hoehe: Pilot-Kunde schreibt eine Zeile, alle anderen nichts; Antwort immer 204', async () => {
|
|
stelle('pilot', ['k@example.invalid'])
|
|
const zeilen = await mitLog(async () => {
|
|
assert.equal((await melde({ art: 'start', ih: 873 }, customerCookie('c1'))).status, 204)
|
|
assert.equal((await melde({ art: 'ohne' })).status, 204)
|
|
assert.equal((await melde({ art: 'mitarbeiter' }, kundenansichtCookie())).status, 204)
|
|
stelle('pilot', ['jemand@example.invalid'])
|
|
assert.equal((await melde({ art: 'kein-pilot' }, customerCookie('c1'))).status, 204)
|
|
stelle('off')
|
|
assert.equal((await melde({ art: 'aus' }, customerCookie('c1'))).status, 204)
|
|
})
|
|
assert.deepEqual(zeilen, ['[diag-hoehe] c1 {"art":"start","ih":873}'])
|
|
})
|
|
|
|
test('diag-hoehe: zu große Meldungen und mehr als MAX_JE_STUNDE je Stunde landen nicht im Log', async () => {
|
|
stelle('on')
|
|
const zeilen = await mitLog(async () => {
|
|
assert.equal((await melde({ x: 'a'.repeat(MAX_BYTES) }, customerCookie('c1'))).status, 204)
|
|
for (let i = 0; i < MAX_JE_STUNDE + 3; i++) await melde({ i }, customerCookie('c1'))
|
|
})
|
|
assert.ok(zeilen.length <= MAX_JE_STUNDE && zeilen.length >= MAX_JE_STUNDE - 2, `Zeilen: ${zeilen.length}`)
|
|
assert.ok(zeilen.every((z) => z.length < MAX_BYTES))
|
|
stelle('off')
|
|
})
|
|
|
|
test('server/index.js: die Messung hängt hinter dem JSON-Parser unter /api/diag/hoehe', async () => {
|
|
const { readFileSync } = await import('node:fs')
|
|
const js = readFileSync(new URL('../server/index.js', import.meta.url), 'utf8')
|
|
assert.ok(js.indexOf("app.use('/api/diag/hoehe', diagHoeheRoutes)") > js.indexOf("app.use(express.json({ limit: '2mb'"))
|
|
})
|