ktg-plugin-marketplace/plugins/linkedin-studio/render/__tests__/weasyprint-degradation.test.mjs
Kjell Tore Guttormsen b6bb61246b refactor(linkedin)!: rename plugin linkedin-thought-leadership → linkedin-studio (v3.0.0)
BREAKING CHANGE: the marketplace slug, the agent namespace
(linkedin-studio:<agent>), and the runtime state-file path
(~/.claude/linkedin-studio.local.md) all change. Reinstall required;
existing state migrated in place (post metrics, streak, history preserved).
The /linkedin:* commands are unchanged — the command namespace is set
per-command in frontmatter and was always independent of the plugin slug.
Functionality is byte-identical to v2.4.0; this release is pure identity.

- dir + manifests: plugins/linkedin-studio + plugin.json + root marketplace.json
- agent namespace updated in commands/newsletter.md (only functional invoker)
- state path updated in 4 hook scripts + topic-rotation prompt + state template
- catch-all skill dir renamed skills/linkedin-studio (5 functional skills unchanged)
- docs + version bump to 3.0.0 across README badge, CHANGELOG, root README/CLAUDE.md
- historical records (CHANGELOG past entries, docs/ build artifacts,
  config-audit v5.0.0 snapshots) intentionally retain the old slug

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 11:32:02 +02:00

36 lines
1.4 KiB
JavaScript

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);
});
});
}