feat(linkedin): migrate render scripts + fonts into plugin (S1)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-05-26 22:11:38 +02:00
commit 6eff5e8e21
14 changed files with 2134 additions and 0 deletions

View file

@ -0,0 +1,36 @@
import { describe, test } from 'node:test';
import assert from 'node:assert/strict';
import { resolveWeasyprint as resolvePdf } from '../build-pdf.mjs';
import { resolveWeasyprint as resolveCarousel } from '../build-carousel.mjs';
// S1 (correction #3): when weasyprint is not resolvable on PATH, the degradation
// helper must return a skip-signal (NOT throw) and emit an install hint, so the
// render scripts can skip the PDF step gracefully instead of crashing.
for (const [name, resolveWeasyprint] of [
['build-pdf', resolvePdf],
['build-carousel', resolveCarousel],
]) {
describe(`resolveWeasyprint — ${name}`, () => {
test('returns a skip-signal (not a throw) when weasyprint is absent', () => {
let result;
assert.doesNotThrow(() => {
result = resolveWeasyprint(() => false);
});
assert.equal(result.available, false);
});
test('emits an install hint when absent', () => {
const result = resolveWeasyprint(() => false);
assert.ok(typeof result.hint === 'string' && result.hint.length > 0);
assert.match(result.hint, /weasyprint/i);
assert.match(result.hint, /install/i);
});
test('reports available when the probe succeeds', () => {
const result = resolveWeasyprint(() => true);
assert.equal(result.available, true);
assert.equal(result.hint, undefined);
});
});
}