3D view: a "3D" menu beside Export switches the diagram to a three.js scene built from the live Archify SVG. Nodes become blocks topped with the node as Archify draws it, relationships become lit pipes along Archify's routes, and the canvas, frames, lanes and legend form the floor. Clicks and hover go to the SVG nodes, so focus, the Semantic Passport and the intent trace work as in 2D; Archify's own animations (trace, node pulse, passport/path/lens flows) are mirrored live. The menu also offers flat or stacked levels, reset view and a top view; Export gains "3D view" (PNG). Trackpad scrolling pans, pinch and the mouse wheel zoom, and the zoom buttons work beyond the 2D limits. The scene draws only when something moves. New setting archify.defaultView. Source: src/ is split by job (commands, views, webview, archify, sources, language, util, viewer3d); behaviour unchanged.
65 lines
2.7 KiB
TypeScript
65 lines
2.7 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { test } from 'node:test';
|
|
import { parse } from 'yaml';
|
|
import { validate } from '../src/archify/cli';
|
|
import { diagramFromTemplate, diagramName, invalidNameReason, TEMPLATES, titleFromName } from '../src/language/templates';
|
|
import { readDiagramSource } from '../src/sources/detect';
|
|
|
|
const root = path.resolve(__dirname, '..', '..');
|
|
const templates = path.join(root, 'templates');
|
|
const runtime = {
|
|
cliPath: path.join(root, 'vendor', 'archify', 'bin', 'archify.mjs'),
|
|
nodePath: process.execPath,
|
|
runAsNode: false,
|
|
workDir: fs.mkdtempSync(path.join(os.tmpdir(), 'archify-ext-test-')),
|
|
};
|
|
|
|
test('every template file is listed and every listed template exists', () => {
|
|
const files = fs.readdirSync(templates).filter((file) => file.endsWith('.archify')).sort();
|
|
assert.deepEqual(TEMPLATES.map((item) => item.file).sort(), files);
|
|
});
|
|
|
|
for (const item of TEMPLATES) {
|
|
test(`template ${item.file} is a valid ${item.type} diagram`, async () => {
|
|
const text = diagramFromTemplate(fs.readFileSync(path.join(templates, item.file), 'utf8'), item.defaultName);
|
|
const source = readDiagramSource(text, `${item.defaultName}.archify`);
|
|
assert.ok(source);
|
|
assert.equal(source.type, item.type);
|
|
assert.equal(source.format, 'yaml');
|
|
const result = await validate(runtime, source.type, source.json);
|
|
assert.deepEqual(
|
|
result.diagnostics.filter((d) => d.severity === 'error').map((d) => `${d.code}: ${d.message}`),
|
|
[],
|
|
);
|
|
assert.ok(result.ok);
|
|
});
|
|
}
|
|
|
|
test('diagramFromTemplate sets title and output and keeps comments and flow lists', () => {
|
|
const text = diagramFromTemplate('# keep me\nschema_version: 1\nmeta:\n title: Old\n output: old.html\npos: [1, 2]\n', 'sales-report');
|
|
assert.match(text, /^# keep me/);
|
|
assert.match(text, /pos: \[1, 2\]/);
|
|
assert.deepEqual(parse(text).meta, { title: 'Sales report', output: 'sales-report.html' });
|
|
});
|
|
|
|
test('diagramFromTemplate adds meta when the template has none', () => {
|
|
assert.deepEqual(parse(diagramFromTemplate('diagram_type: workflow\n', 'plan')).meta, { title: 'Plan', output: 'plan.html' });
|
|
});
|
|
|
|
test('diagram names', () => {
|
|
assert.equal(diagramName(' web.archify '), 'web');
|
|
assert.equal(diagramName('web.ARCHIFY'), 'web');
|
|
assert.equal(invalidNameReason('web'), undefined);
|
|
assert.equal(invalidNameReason('my plan 2026'), undefined);
|
|
assert.ok(invalidNameReason(''));
|
|
assert.ok(invalidNameReason('.archify'));
|
|
assert.ok(invalidNameReason('..'));
|
|
assert.ok(invalidNameReason('a/b'));
|
|
assert.ok(invalidNameReason('a:b'));
|
|
assert.equal(titleFromName('sales-report_v2'), 'Sales report v2');
|
|
assert.equal(titleFromName('plan'), 'Plan');
|
|
});
|