Analyse: Oberfläche in eigenes Modul analyse.js, gemeinsame Helfer in fn-util.js
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
97bff91a99
commit
9d1691cf6b
9 files changed
+426
-409
No files matched your search
@@ -54,8 +54,11 @@ test('Portal: Analyse-Ansicht ist verdrahtet', () => {
|
||||
assert.match(app, /APP_PARENT = \{ news: 'funktionen', analyse: 'funktionen'/)
|
||||
assert.match(html, /id="view-analyse"/)
|
||||
assert.match(html, /id="analyse-body"/)
|
||||
assert.match(app, /analyse: \(\) => import\('\/analyse\.js'\)/)
|
||||
const an = readFileSync(new URL('../public/analyse.js', import.meta.url), 'utf8')
|
||||
assert.doesNotMatch(an, /\bconfirm\(/)
|
||||
const fn = readFileSync(new URL('../public/funktionen.js', import.meta.url), 'utf8')
|
||||
assert.doesNotMatch(fn.slice(fn.indexOf('Analyse ---')), /\bconfirm\(/)
|
||||
assert.doesNotMatch(fn, /function renderAnalyseStats|function renderAnalyseHeat/)
|
||||
})
|
||||
|
||||
test('Portal-Vorschau: Banner-Text ist der des Clients', () => {
|
||||
|
||||
@@ -25,7 +25,7 @@ test('Entwurfsseite ohne Fassung ist nicht mehr als Datei vorhanden', () => {
|
||||
})
|
||||
|
||||
test('Portal: keine alten Formulierungen, AVV-Adresse kommt aus a.legal', () => {
|
||||
const fn = readFileSync(root('public/funktionen.js'), 'utf8')
|
||||
const fn = readFileSync(root('public/analyse.js'), 'utf8')
|
||||
for (const old of ['anonym', 'Cookie-Einstellungen', 'Die bisherigen Daten bleiben noch 60 Tage erhalten', 'Verarbeitung der Analysedaten gemäß Auftragsverarbeitungsvertrag', "AVV_URL = '/rechtliches/avv-website-analyse.html'"]) {
|
||||
assert.ok(!fn.includes(old), old)
|
||||
}
|
||||
|
||||
@@ -5,15 +5,17 @@ import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
// public/funktionen.js wirklich laden (die absoluten Importe /analyse-view.js und /geraete.js werden auf die Dateien umgeleitet)
|
||||
// public/funktionen.js wirklich laden (die absoluten Importe /fn-util.js und /analyse-view.js werden auf die Dateien umgeleitet);
|
||||
// analyse.js importiert relativ und wird direkt geladen
|
||||
const dir = mkdtempSync(join(tmpdir(), 'fn-tiles-'))
|
||||
const fileUrl = (name) => pathToFileURL(new URL(`../public/${name}`, import.meta.url).pathname).href
|
||||
const src = readFileSync(new URL('../public/funktionen.js', import.meta.url), 'utf8')
|
||||
.replace("'/fn-util.js'", `'${fileUrl('fn-util.js')}'`)
|
||||
.replace("'/analyse-view.js'", `'${fileUrl('analyse-view.js')}'`)
|
||||
.replace("'/geraete.js'", `'${fileUrl('geraete.js')}'`)
|
||||
const file = join(dir, 'funktionen.mjs')
|
||||
writeFileSync(file, src)
|
||||
const { initFunktionen, initAnalyse, renderAnalyseOff } = await import(pathToFileURL(file).href)
|
||||
const { initFunktionen } = await import(pathToFileURL(file).href)
|
||||
const { initAnalyse, renderAnalyseOff } = await import(fileUrl('analyse.js'))
|
||||
|
||||
const news = { state: 'off' }
|
||||
const project = (id, analyse) => ({ projectId: id, projectName: `P ${id}`, liveUrl: '', features: { news }, analyse })
|
||||
|
||||
@@ -264,9 +264,9 @@ test('Portal: Ansicht #termine ist verdrahtet, funktionen.js lädt keine Terminp
|
||||
assert.match(html, /<section class="kb-view" id="view-termine">[\s\S]*<h1>Terminplaner<\/h1>[\s\S]*<div id="termine-body">/)
|
||||
assert.match(html, /<link rel="stylesheet" href="\/termine\.css">/)
|
||||
// R4: funktionen.js lädt keine Terminplaner-Module (die Kachel steht inline); seine absoluten Importe biegt
|
||||
// test/funktionenTiles.test.js um – genau diese beiden (/geraete.js kam mit der Heatmap im Gerätrahmen auf main)
|
||||
// test/funktionenTiles.test.js um – genau diese beiden (die Analyse-Oberfläche liegt in analyse.js, mit relativen Importen)
|
||||
const fn = lies('public/funktionen.js')
|
||||
assert.deepEqual(fn.match(/from '\/[^']+'/g), ["from '/analyse-view.js'", "from '/geraete.js'"])
|
||||
assert.deepEqual(fn.match(/from '\/[^']+'/g), ["from '/fn-util.js'", "from '/analyse-view.js'"])
|
||||
assert.doesNotMatch(fn, /from '\/termine/)
|
||||
assert.doesNotMatch(fn, /import\s*\(/, 'auch kein dynamischer Import')
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user