dorfteich/packages/plugins/section-styles-basic/manifest.test.ts
Claude Fable 5 e32f961047
All checks were successful
CI / Lint, typecheck, test (push) Successful in 2m54s
CI / Build container images (push) Has been skipped
CD / Build and push images (push) Successful in 3m9s
CD / Deploy to Test (push) Successful in 11s
CD / Smoke tests against Test (push) Successful in 1m9s
CD / Promote to Int (push) Successful in 10s
CI / Auth e2e pack (push) Successful in 3m57s
CI / Import/export fidelity gate (push) Successful in 43s
Complete section-style plugins: CSS gate, injection, picker, export (#75)
Second half of #75 on top of the section node (2e96173/784f21d):

- Install gate for section_style CSS (plugin-css.ts): every rule must be
  scoped under one of the plugin's own .dt-style-<pluginId>-<styleId>
  classes (enforced, not rewritten — grouping at-rules checked inside,
  @font-face/@keyframes exempt, statement at-rules rejected); positioning
  out of the content flow (anything but static/relative) is rejected as an
  overlay vector; "</style" is rejected as a breakout vector for inlined
  embedding. Hostile fixtures from the acceptance list are pinned in
  plugin-css.test.ts.
- Web: usePondPlugins loads the pond's active plugins once per visit;
  SectionStyleSheets links each active style plugin's immutable
  styles.css; SectionStyleMenu (toolbar) wraps/restyles/unwraps with a
  picker fed from the plugins' i18n titles. Sections show a faint dashed
  hint while editing so unstyled (plugin-disabled) sections stay findable.
- PDF export: PluginsService.sectionStyleCssForPond inlines the pond's
  active section-style CSS into the Gotenberg HTML, so styled sections
  survive the network-isolated render; covered in export.service.db.test.
- Reference plugin packages/plugins/section-styles-basic (callout, info,
  warning, colored-box; theme-neutral semi-transparent backgrounds), a
  workspace package whose tests validate it against the SDK schema and
  whose real files run through the api install gate.
- e2e section-styles.spec.ts: install → wrap → computed background in edit
  and read mode → unwrap → neutral fallback after disabling the plugin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
2026-07-11 11:43:36 +02:00

46 lines
1.7 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { validateManifest } from '@dorfteich/plugin-sdk';
import { describe, expect, it } from 'vitest';
/**
* Reference-plugin self-check (plugin-architecture.md: reference plugins
* "double as the plugin-SDK integration tests"): the shipped manifest must
* validate against the SDK schema, and the stylesheet must define every
* declared style under its own scope class. The full install gate (CSS
* sanitation and scope enforcement) additionally runs against this real
* package in `apps/api` (plugin-package.service.test.ts).
*/
const manifest: unknown = JSON.parse(readFileSync(join(__dirname, 'manifest.json'), 'utf8'));
const css = readFileSync(join(__dirname, 'styles.css'), 'utf8');
describe('section-styles-basic package', () => {
it('has a valid section_style manifest', () => {
const result = validateManifest(manifest);
expect(result.issues).toEqual([]);
expect(result.manifest?.kind).toBe('section_style');
expect(result.manifest?.extensionPoints.map((p) => p.id)).toEqual([
'callout',
'info',
'warning',
'colored-box',
]);
});
it('titles every style in German and English (ADR 0012)', () => {
const result = validateManifest(manifest);
for (const point of result.manifest?.extensionPoints ?? []) {
expect(point.title.de, point.id).toBeTruthy();
expect(point.title.en, point.id).toBeTruthy();
}
});
it('styles every declared styleId under its scope class', () => {
const result = validateManifest(manifest);
for (const point of result.manifest?.extensionPoints ?? []) {
expect(css).toContain(`.dt-style-section-styles-basic-${point.id}`);
}
});
});