/* Misst die einzelnen Teile der Kopfleiste auf dem Handy -- damit die Reparatur an der richtigen Stelle ansetzt und nicht geraten wird. */ import { mkdtempSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; const ordner = mkdtempSync(join(tmpdir(), "ws-messen-")); process.env.WORKSPACE_DB = join(ordner, "pruef.sqlite"); process.env.PORT = "4179"; process.env.SITE_ACCESS_SECRET = "lokaler-test"; process.env.SITE_ACCESS_CODE_DOGI = "DOGI-TEST-1"; process.env.SITE_ACCESS_CODE_VANVAN = "VANVAN-TEST-1"; process.env.SITE_PUBLIC_LAUNCH_AT = "2020-01-01T00:00:00+01:00"; const express = (await import("express")).default; const ec = express.response.cookie; express.response.cookie = function (n, w, o) { return ec.call(this, n, w, { ...(o || {}), secure: false }); }; await import("./index.js"); await new Promise((r) => setTimeout(r, 700)); const BASIS = "http://127.0.0.1:4179"; setTimeout(() => { console.log("ABBRUCH"); process.exit(1); }, 120_000).unref?.(); await fetch(BASIS + "/workspace/api/anmelden", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ rolle: "admin", code: "x" }) }).catch(() => {}); const { DatabaseSync } = await import("node:sqlite"); const { scryptSync, randomBytes } = await import("node:crypto"); const d = new DatabaseSync(process.env.WORKSPACE_DB); const salt = randomBytes(16).toString("hex"); const hash = scryptSync("CODE-DOGI-0001", salt, 64, { N: 32768, r: 8, p: 1, maxmem: 96 * 1024 * 1024 }).toString("hex"); /* Bewusst ein langer Name -- kurze Namen wuerden den Fehler verstecken. */ d.prepare("INSERT INTO personen (name, rolle, code_hash, code_salt, code_n, aktiv, erstellt) VALUES (?,?,?,?,?,1,?)") .run("Filipe Fernandes Ribeiro", "admin", hash, salt, 32768, new Date().toISOString()); d.close(); const { chromium } = await import( "file:///C:/Users/qciga/Documents/Obelix/Analyse/node_modules/playwright/index.mjs"); const browser = await chromium.launch(); for (const breite of [320, 390, 430]) { const kontext = await browser.newContext({ viewport: { width: breite, height: 844 } }); const seite = await kontext.newPage(); await seite.goto(BASIS + "/workspace/", { waitUntil: "domcontentloaded" }); await seite.click('.rolle[data-rolle="admin"]'); await seite.fill("#code", "CODE-DOGI-0001"); await seite.click("button[type=submit]"); await seite.waitForURL("**/start.html", { timeout: 15000 }); await seite.goto(BASIS + "/workspace/uebersicht.html", { waitUntil: "networkidle" }); await seite.waitForTimeout(300); const r = await seite.evaluate(() => { const k = document.querySelector(".kopfleiste"); const teil = (e) => ({ was: (e.tagName + "." + String(e.className).split(" ")[0]).slice(0, 34), breite: Math.round(e.getBoundingClientRect().width), rechts: Math.round(e.getBoundingClientRect().right), }); return { fenster: window.innerWidth, ueber: document.documentElement.scrollWidth - document.documentElement.clientWidth, kinder: [...k.children].map(teil), rechtsKinder: [...(k.querySelector(".kopfleiste__rechts")?.children || [])].map(teil), abmeldenSichtbar: (() => { const a = document.querySelector(".abmelden")?.getBoundingClientRect(); return a ? a.right <= window.innerWidth : null; })(), }; }); console.log(`\n--- ${breite}px (Überstand ${r.ueber}px, Abmelden erreichbar: ${r.abmeldenSichtbar})`); for (const t of r.kinder) console.log(` ${t.was.padEnd(34)} b=${String(t.breite).padStart(4)} rechts=${t.rechts}`); console.log(" darin:"); for (const t of r.rechtsKinder) console.log(` ${t.was.padEnd(32)} b=${String(t.breite).padStart(4)} rechts=${t.rechts}`); await kontext.close(); } await browser.close(); try { rmSync(ordner, { recursive: true, force: true }); } catch {} process.exit(0);