Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { describe, it, expect } from 'vitest';
import {
overflowSeverity,
panelLetteringMetrics,
analyzeComicLettering,
} from './letteringDensity';
// Mirror of server/lib/editorial/letteringDensity.js — the server test is the
// authoritative contract; this covers the client copy used by the comic-script
// stage's inline warnings so a drift in the mirror is caught here too.
const balloon = (character, n) => ({ character, line: Array.from({ length: n }, (_, i) => `w${i}`).join(' ') });
describe('letteringDensity (client mirror)', () => {
it('overflowSeverity scales by overflow ratio', () => {
expect(overflowSeverity(26, 25)).toBe('low');
expect(overflowSeverity(35, 25)).toBe('medium');
expect(overflowSeverity(50, 25)).toBe('high');
});
it('panelLetteringMetrics counts dialogue + caption + SFX and balloons', () => {
const m = panelLetteringMetrics({
dialogue: [balloon('A', 4), balloon('B', 2)],
caption: 'Box one.\nBox two.',
sfx: 'BOOM',
});
expect(m.totalWords).toBe(6 + 4 + 1);
expect(m.balloonCount).toBe(4); // 2 dialogue + 2 caption boxes
});
it('analyzeComicLettering flags an over-stuffed balloon', () => {
const v = analyzeComicLettering([{ panels: [{ dialogue: [balloon('NARRATOR', 60)] }] }]);
const balloonV = v.find((x) => x.kind === 'balloon-words');
expect(balloonV.count).toBe(60);
expect(balloonV.severity).toBe('high');
expect(balloonV.pageNumber).toBe(1);
expect(balloonV.panelNumber).toBe(1);
});
it('returns nothing for a clean page', () => {
expect(analyzeComicLettering([{ panels: [{ dialogue: [balloon('A', 8)], caption: 'A beat.' }] }])).toEqual([]);
});
});
// @vitest-environment node