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