Runner: Analyse-Einsetzen ignoriert Kommentare/Skripte (Fix Runde 1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
18d37d1e01
commit
9fa05e23d1
4 files changed
+79
-16
No files matched your search
@@ -185,3 +185,40 @@ test('leere Adresse: keine leere Zeile, kein Platzhalterrest', async () => {
|
||||
assert.ok(p.includes('Muster GmbH<br>E-Mail:'));
|
||||
assert.ok(!p.includes('{{') && !p.includes('<br><br>'));
|
||||
});
|
||||
|
||||
test('Marker in script-String, Kommentar, template: Tag landet an der echten Stelle', async () => {
|
||||
const d = dir();
|
||||
put(d, 'a.html', '<head><script>var t="</head>";</script></head><body></body>');
|
||||
put(d, 'b.html', '<!-- </head> --><head></head>');
|
||||
put(d, 'c.html', '<template><body></template><p>x</p>');
|
||||
put(d, 'd.html', '<style>/* </head> */</style><head></head>');
|
||||
await injectAnalytics(d, A(), { baseUrl: BASE });
|
||||
assert.equal(get(d, 'a.html'), `<head><script>var t="</head>";</script>${TAG}</head><body></body>`);
|
||||
assert.equal(get(d, 'b.html'), `<!-- </head> --><head>${TAG}</head>`);
|
||||
assert.equal(get(d, 'c.html'), `${TAG}<template><body></template><p>x</p>`);
|
||||
assert.equal(get(d, 'd.html'), `<style>/* </head> */</style><head>${TAG}</head>`);
|
||||
});
|
||||
|
||||
test('alter Tag im Kommentar wird nicht ersetzt; echter wird genau einmal eingesetzt', async () => {
|
||||
const d = dir();
|
||||
const old = '<script data-wk-analytics src="https://alt/w.js"></script>';
|
||||
put(d, 'a.html', `<head><!-- ${old} --></head>`);
|
||||
await injectAnalytics(d, A(), { baseUrl: BASE });
|
||||
assert.equal(get(d, 'a.html'), `<head><!-- ${old} -->${TAG}</head>`);
|
||||
});
|
||||
|
||||
test('5-MB-Grenze: genau 5 MB wird bearbeitet', async () => {
|
||||
const d = dir();
|
||||
const b = Buffer.alloc(5 * 1024 * 1024, 0x20); b.write('<head></head>', 0);
|
||||
writeFileSync(join(d, 'g.html'), b);
|
||||
await injectAnalytics(d, A(), { baseUrl: BASE });
|
||||
assert.ok(get(d, 'g.html').includes('data-wk-analytics'));
|
||||
});
|
||||
|
||||
test('validateJob: Adresse nur Leerraum ⇒ leer, sonst getrimmt', () => {
|
||||
const base = { sub: 'demo', repo: 'JUSN/demo', sha: 'abcdef1', branch: 'main' };
|
||||
const r = validateJob({ ...base, analytics: A({ privacy: { company: 'F', email: 'e@x.de', address: ' ' } }) });
|
||||
assert.equal(r.job.analytics.privacy.address, '');
|
||||
const r2 = validateJob({ ...base, analytics: A({ privacy: { company: 'F', email: 'e@x.de', address: ' Weg 1 ' } }) });
|
||||
assert.equal(r2.job.analytics.privacy.address, 'Weg 1');
|
||||
});
|
||||
Reference in new issue
Block a user