visualisierung

This commit is contained in:
marco committed 2026-10-26 07:34:23 +01:00
1 parent d0655f3638
commit 367c93c93e
84 files changed
+2265 -148

No files matched your search

@@ -0,0 +1,38 @@
import { describe, expect, it } from '@jest/globals';
import { createXamlFiles } from './procon-xaml-export';
import type { ProConViewElement } from '../../_schemas/anlagen/procon-view-aggregate';
describe('XAML-Dateiexport', () => {
const element: ProConViewElement = {
key: 'main', name: '', darstellung: 'xaml', typ: 'main',
width: 40, height: 40, posX: 0, posY: 0, zIndex: 0, show: true,
varianten: [
{ zustand: 'active', xaml: '<Viewbox>ä</Viewbox>', xamlBase64: '' },
{ zustand: 'inactive', xamlBase64: Buffer.from('<Viewbox/>').toString('base64') },
{ zustand: 'error', xamlBase64: '' },
],
};
const aggregates = [{ componentId: 'c1', viewName: 'SF1_Band', elemente: [element] }];
const dto = { anlageId: 'a1', auswahl: [{ componentId: 'c1', elementKeys: ['main'] }] };
it('erstellt Dateien für die Auswahl und dekodiert ältere Base64-Daten', () => {
expect(createXamlFiles(aggregates, dto)).toEqual({
files: [
{ name: 'SF1_Band_main_active.xaml', data: '<Viewbox>ä</Viewbox>' },
{ name: 'SF1_Band_main_inactive.xaml', data: '<Viewbox/>' },
], skipped: 1,
});
expect(createXamlFiles(aggregates, { ...dto, auswahl: [{ componentId: 'c1', elementKeys: [] }] }).files).toEqual([]);
});
it('verhindert Pfade außerhalb des Exportordners und leere View-Namen', () => {
for (const viewName of ['../fremd', 'C:\\fremd', '', 'Datei.']) {
expect(() => createXamlFiles([{ ...aggregates[0], viewName }], dto)).toThrow('Dateinamenbestandteile');
}
});
it('verhindert doppelte Dateinamen und unbekannte Auswahlen', () => {
expect(() => createXamlFiles(aggregates, { ...dto, auswahl: [...dto.auswahl, ...dto.auswahl] })).toThrow('Doppelter');
expect(() => createXamlFiles(aggregates, { ...dto, auswahl: [{ componentId: 'fremd', elementKeys: ['main'] }] })).toThrow('dieser Anlage');
});
});