Drop generated cards; registry descriptions become Elements tooltips
- resolveRefs no longer adds cards to a diagram; it returns node id → description, which the page sets as the tooltip of the matching row in Archify's Elements panel - hand-written cards pass through unchanged; docs and changelog
This commit is contained in:
+5
-17
@@ -3,8 +3,6 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { test } from 'node:test';
|
||||
import {
|
||||
cardsFromElements,
|
||||
dotForType,
|
||||
groupOf,
|
||||
hasDiagramBody,
|
||||
isMainFile,
|
||||
@@ -83,22 +81,12 @@ test('resolve: refs become full components, links and usage are collected', () =
|
||||
assert.deepEqual([...r.used].sort(), ['api', 'cache', 'customer', 'db', 'queue', 'web', 'worker']);
|
||||
assert.equal(r.refs.get(2)?.id, 'api');
|
||||
assert.ok(!('model' in r.diagram));
|
||||
// Cards from the registry descriptions, in drawing order, one per element.
|
||||
const cards = r.diagram.cards as { dot: string; title: string; items: string[] }[];
|
||||
assert.equal(cards.length, 7);
|
||||
assert.deepEqual(cards[0], { dot: 'slate', title: 'Customer', items: ['Buys products; signs in with email or a social account.'] });
|
||||
assert.equal(cards.find((c) => c.title === 'API')?.dot, 'emerald');
|
||||
});
|
||||
|
||||
test('resolve: own cards win, no cards without refs or descriptions', () => {
|
||||
const registry = registryOfModel();
|
||||
// Descriptions travel with the node ids, for the Elements panel; nothing is added to the diagram itself.
|
||||
assert.ok(!('cards' in r.diagram));
|
||||
assert.equal(r.descriptions.get('customer'), 'Buys products; signs in with email or a social account.');
|
||||
assert.equal(r.descriptions.size, 7);
|
||||
const own = resolveRefs({ components: [{ ref: 'api', pos: [0, 0] }], cards: [{ dot: 'rose', title: 'Mine', items: ['kept'] }] }, { registry, fileName: 'x.archify' });
|
||||
assert.deepEqual(own.diagram.cards, [{ dot: 'rose', title: 'Mine', items: ['kept'] }]);
|
||||
const inline = resolveRefs({ components: [{ id: 'a', type: 'backend', label: 'A', pos: [0, 0] }] }, { registry, fileName: 'x.archify' });
|
||||
assert.ok(!('cards' in inline.diagram));
|
||||
assert.equal(cardsFromElements([{ id: 'x', type: 'cloud', label: 'X', file: 'r', line: 0 }]).length, 0);
|
||||
assert.equal(dotForType('messagebus'), 'orange');
|
||||
assert.equal(dotForType(undefined), 'slate');
|
||||
assert.deepEqual(own.diagram.cards, [{ dot: 'rose', title: 'Mine', items: ['kept'] }], 'hand-written cards pass through');
|
||||
});
|
||||
|
||||
test('resolve: overrides, second id for the same element, inline elements and links', () => {
|
||||
|
||||
Reference in New Issue
Block a user