@dversum/mcp-server 2.9.1 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/src/client.d.ts +11 -0
  2. package/dist/src/client.d.ts.map +1 -1
  3. package/dist/src/client.js +51 -0
  4. package/dist/src/client.js.map +1 -1
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +8 -1
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/tools/calendar.d.ts +15 -0
  9. package/dist/src/tools/calendar.d.ts.map +1 -1
  10. package/dist/src/tools/calendar.js +27 -2
  11. package/dist/src/tools/calendar.js.map +1 -1
  12. package/dist/src/tools/clients.d.ts.map +1 -1
  13. package/dist/src/tools/clients.js +4 -0
  14. package/dist/src/tools/clients.js.map +1 -1
  15. package/dist/src/tools/request-bodies.spec.d.ts +2 -0
  16. package/dist/src/tools/request-bodies.spec.d.ts.map +1 -0
  17. package/dist/src/tools/request-bodies.spec.js +45 -0
  18. package/dist/src/tools/request-bodies.spec.js.map +1 -0
  19. package/dist/src/tools/time.d.ts +13 -0
  20. package/dist/src/tools/time.d.ts.map +1 -1
  21. package/dist/src/tools/time.js +27 -6
  22. package/dist/src/tools/time.js.map +1 -1
  23. package/dist/src/tools/universum.d.ts +4 -0
  24. package/dist/src/tools/universum.d.ts.map +1 -0
  25. package/dist/src/tools/universum.js +48 -0
  26. package/dist/src/tools/universum.js.map +1 -0
  27. package/dist/src/tools/whiteboard-compose.d.ts +4 -0
  28. package/dist/src/tools/whiteboard-compose.d.ts.map +1 -0
  29. package/dist/src/tools/whiteboard-compose.js +383 -0
  30. package/dist/src/tools/whiteboard-compose.js.map +1 -0
  31. package/dist/src/tools/whiteboards.d.ts.map +1 -1
  32. package/dist/src/tools/whiteboards.js +150 -7
  33. package/dist/src/tools/whiteboards.js.map +1 -1
  34. package/dist/src/whiteboard/elements.d.ts +171 -0
  35. package/dist/src/whiteboard/elements.d.ts.map +1 -0
  36. package/dist/src/whiteboard/elements.js +121 -0
  37. package/dist/src/whiteboard/elements.js.map +1 -0
  38. package/dist/src/whiteboard/link.d.ts +22 -0
  39. package/dist/src/whiteboard/link.d.ts.map +1 -0
  40. package/dist/src/whiteboard/link.js +56 -0
  41. package/dist/src/whiteboard/link.js.map +1 -0
  42. package/dist/src/whiteboard/measure.d.ts +26 -0
  43. package/dist/src/whiteboard/measure.d.ts.map +1 -0
  44. package/dist/src/whiteboard/measure.js +64 -0
  45. package/dist/src/whiteboard/measure.js.map +1 -0
  46. package/dist/src/whiteboard/sections.d.ts +352 -0
  47. package/dist/src/whiteboard/sections.d.ts.map +1 -0
  48. package/dist/src/whiteboard/sections.js +879 -0
  49. package/dist/src/whiteboard/sections.js.map +1 -0
  50. package/dist/src/whiteboard/sections.spec.d.ts +2 -0
  51. package/dist/src/whiteboard/sections.spec.d.ts.map +1 -0
  52. package/dist/src/whiteboard/sections.spec.js +608 -0
  53. package/dist/src/whiteboard/sections.spec.js.map +1 -0
  54. package/dist/src/whiteboard/stock.d.ts +39 -0
  55. package/dist/src/whiteboard/stock.d.ts.map +1 -0
  56. package/dist/src/whiteboard/stock.js +91 -0
  57. package/dist/src/whiteboard/stock.js.map +1 -0
  58. package/dist/src/whiteboard/stock.spec.d.ts +2 -0
  59. package/dist/src/whiteboard/stock.spec.d.ts.map +1 -0
  60. package/dist/src/whiteboard/stock.spec.js +69 -0
  61. package/dist/src/whiteboard/stock.spec.js.map +1 -0
  62. package/dist/src/whiteboard/styles.d.ts +65 -0
  63. package/dist/src/whiteboard/styles.d.ts.map +1 -0
  64. package/dist/src/whiteboard/styles.js +63 -0
  65. package/dist/src/whiteboard/styles.js.map +1 -0
  66. package/dist/src/whiteboard/tokens.d.ts +114 -0
  67. package/dist/src/whiteboard/tokens.d.ts.map +1 -0
  68. package/dist/src/whiteboard/tokens.js +105 -0
  69. package/dist/src/whiteboard/tokens.js.map +1 -0
  70. package/package.json +5 -3
@@ -0,0 +1,608 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { composeBoard, composeSlides, composeNarrow, CANVAS_MARGIN, DEFAULT_COLUMN, MEASURE, SECTION_TYPES, SLIDE_HEIGHT, HERO_HEIGHT, NARROW_WIDTH, NARROW_MARGIN, } from './sections.js';
3
+ import { SECTION_GAP, SECTION_GAPS, TYPE_SCALE, COLOR, STICKY } from './tokens.js';
4
+ import { BOARD_STYLE_IDS, BOARD_STYLES } from './styles.js';
5
+ /**
6
+ * One spec per section type, so a change that breaks any single section
7
+ * fails here rather than in a board someone is looking at.
8
+ */
9
+ const ALL_SECTIONS = [
10
+ {
11
+ type: 'hero',
12
+ content: {
13
+ headline: 'Every invoice, every hour, in one place',
14
+ subline: 'dVersum replaces the spreadsheet, the timer and the accounting export with one workspace your team already knows how to use.',
15
+ },
16
+ },
17
+ {
18
+ type: 'featureGrid',
19
+ content: {
20
+ items: [
21
+ { icon: 'Receipt', title: 'Compliant invoices', body: 'Every required field checked before you send, and locked afterwards.' },
22
+ { icon: 'Timer', title: 'Time that bills itself', body: 'Tracked hours become line items without anyone retyping them.' },
23
+ { icon: 'Landmark', title: 'Export your accountant accepts', body: 'A booking file that imports without a phone call about the format.' },
24
+ ],
25
+ },
26
+ },
27
+ {
28
+ type: 'statBand',
29
+ content: {
30
+ stats: [
31
+ { value: '847', label: 'Invoices sent this quarter', delta: { text: '+12%', tone: 'up' } },
32
+ { value: '4.2 days', label: 'Average time to payment', delta: { text: '-1.1 days', tone: 'up' } },
33
+ { value: '0', label: 'Rejected by the tax office' },
34
+ ],
35
+ },
36
+ },
37
+ {
38
+ type: 'split',
39
+ content: {
40
+ title: 'See where the month is going',
41
+ body: 'Revenue against expenses, updated as documents move through the workflow, so the number you quote in a meeting is the number in the system.',
42
+ visual: { kind: 'chart', chartType: 'bar', data: { categories: ['Jul', 'Aug', 'Sep'], series: [{ name: 'Revenue', values: [42000, 51000, 47500] }] } },
43
+ side: 'left',
44
+ },
45
+ },
46
+ {
47
+ type: 'steps',
48
+ content: {
49
+ steps: [
50
+ { title: 'Track', body: 'Start a timer or log the hours later.' },
51
+ { title: 'Bill', body: 'Turn settled time into a draft invoice.' },
52
+ { title: 'Send', body: 'Deliver by email with the XML attached.' },
53
+ { title: 'Book', body: 'Export the batch to your accounting file.' },
54
+ ],
55
+ },
56
+ },
57
+ {
58
+ type: 'quote',
59
+ content: {
60
+ quote: 'We stopped keeping a second spreadsheet the week we switched.',
61
+ attribution: 'Head of operations, a fifteen-person agency',
62
+ },
63
+ },
64
+ {
65
+ type: 'chartPanel',
66
+ content: {
67
+ title: 'Revenue and expenses, rolling twelve months',
68
+ caption: 'Figures are net of VAT. Cancelled documents are excluded.',
69
+ chart: { kind: 'chart', chartType: 'area', data: { categories: ['Q1', 'Q2', 'Q3'], series: [{ name: 'Net', values: [120, 140, 165] }] } },
70
+ },
71
+ },
72
+ {
73
+ type: 'ctaBand',
74
+ content: {
75
+ headline: 'Start with your next invoice',
76
+ buttonLabel: 'Open a workspace',
77
+ note: 'No card required for the trial.',
78
+ },
79
+ },
80
+ {
81
+ type: 'comparisonTable',
82
+ content: {
83
+ columns: ['', 'Starter', 'Team', 'Professional'],
84
+ rows: [
85
+ ['Invoices per month', '20', 'Unlimited', 'Unlimited'],
86
+ ['Time tracking', 'Yes', 'Yes', 'Yes'],
87
+ ['Accounting export', 'No', 'Yes', 'Yes'],
88
+ ],
89
+ },
90
+ },
91
+ {
92
+ type: 'timeline',
93
+ content: {
94
+ events: [
95
+ { date: 'January', title: 'Dunning', body: 'Four levels with fees and interest.' },
96
+ { date: 'March', title: 'Direct debit', body: 'Batch files for the bank.' },
97
+ { date: 'June', title: 'Whiteboards', body: 'Collaborative infinite canvas.' },
98
+ ],
99
+ },
100
+ },
101
+ {
102
+ type: 'logoRow',
103
+ content: {
104
+ label: 'Works with the tools already in the office',
105
+ items: [
106
+ { kind: 'icon', iconName: 'Calendar' },
107
+ { kind: 'icon', iconName: 'CreditCard' },
108
+ { kind: 'icon', iconName: 'Mail' },
109
+ { kind: 'icon', iconName: 'Cloud' },
110
+ ],
111
+ },
112
+ },
113
+ {
114
+ type: 'imageBand',
115
+ content: {
116
+ visual: { kind: 'placeholder', brief: 'Wide shot of a desk with paper invoices and a laptop, warm daylight, shot from above.' },
117
+ caption: 'Replace with a photograph from the last client shoot.',
118
+ },
119
+ },
120
+ { type: 'footerMeta', content: { items: ['dVersum', 'Updated September 2026', 'Internal draft'] } },
121
+ ];
122
+ /** Connectors are anchored to other elements and carry no own geometry. */
123
+ const positioned = (els) => els.filter((el) => el.type !== 'connector');
124
+ describe('section presets', () => {
125
+ it('covers every declared section type in this fixture', () => {
126
+ expect(ALL_SECTIONS.map((s) => s.type).sort()).toEqual([...SECTION_TYPES].sort());
127
+ });
128
+ it('emits elements and a positive height for every section', () => {
129
+ for (const spec of ALL_SECTIONS) {
130
+ const page = composeBoard([spec]);
131
+ expect(page.elements.length, spec.type).toBeGreaterThan(0);
132
+ expect(page.height, spec.type).toBeGreaterThan(0);
133
+ }
134
+ });
135
+ it('keeps every element inside the content column, unless it declared a bleed', () => {
136
+ // Bands may run edge to edge, but only when the section said so. An
137
+ // element outside the column that nobody declared is a layout bug.
138
+ const page = composeBoard(ALL_SECTIONS);
139
+ const bleeding = new Set(page.bleedIds);
140
+ const left = CANVAS_MARGIN;
141
+ const right = CANVAS_MARGIN + DEFAULT_COLUMN;
142
+ for (const el of positioned(page.elements)) {
143
+ if (bleeding.has(el.id))
144
+ continue;
145
+ expect(el.x, el.id).toBeGreaterThanOrEqual(left);
146
+ expect(el.x + el.width, el.id).toBeLessThanOrEqual(right + 0.01);
147
+ }
148
+ });
149
+ it('keeps even a bleeding band inside the canvas', () => {
150
+ const page = composeBoard(ALL_SECTIONS);
151
+ const canvasRight = CANVAS_MARGIN * 2 + DEFAULT_COLUMN;
152
+ for (const id of page.bleedIds) {
153
+ const el = page.elements.find((e) => e.id === id);
154
+ expect(el.x, id).toBeGreaterThanOrEqual(0);
155
+ expect(el.x + el.width, id).toBeLessThanOrEqual(canvasRight + 0.01);
156
+ }
157
+ });
158
+ it('bleeds only the bands meant to, and only in the styles that allow it', () => {
159
+ expect(composeBoard(ALL_SECTIONS, { style: 'product' }).bleedIds.length).toBeGreaterThan(0);
160
+ expect(composeBoard(ALL_SECTIONS, { style: 'editorial' }).bleedIds).toEqual([]);
161
+ expect(composeBoard(ALL_SECTIONS, { style: 'technical' }).bleedIds).toEqual([]);
162
+ });
163
+ it('never lets a section spill past the height it reported', () => {
164
+ // Under-reported heights are the one bug that makes stacked sections
165
+ // collide, so this walks the stack the same way composeBoard does.
166
+ let top = CANVAS_MARGIN;
167
+ for (const spec of ALL_SECTIONS) {
168
+ const single = composeBoard([spec]);
169
+ const bottom = CANVAS_MARGIN + single.height;
170
+ for (const el of positioned(single.elements)) {
171
+ expect(el.y, `${spec.type}/${el.id} starts above its section`).toBeGreaterThanOrEqual(CANVAS_MARGIN - 0.01);
172
+ expect(el.y + el.height, `${spec.type}/${el.id} overflows its section`).toBeLessThanOrEqual(bottom + 0.01);
173
+ }
174
+ top = bottom + SECTION_GAP;
175
+ }
176
+ expect(top).toBeGreaterThan(CANVAS_MARGIN);
177
+ });
178
+ it('leaves exactly one section gap between consecutive sections', () => {
179
+ const a = composeBoard([ALL_SECTIONS[0]]);
180
+ const b = composeBoard([ALL_SECTIONS[1]]);
181
+ const both = composeBoard([ALL_SECTIONS[0], ALL_SECTIONS[1]]);
182
+ expect(both.height).toBeCloseTo(a.height + SECTION_GAP + b.height, 1);
183
+ });
184
+ it('excludes the trailing gap from the composed height', () => {
185
+ const one = composeBoard([ALL_SECTIONS[5]]);
186
+ const single = composeBoard([ALL_SECTIONS[5]]);
187
+ expect(one.height).toBe(single.height);
188
+ expect(composeBoard([]).height).toBe(0);
189
+ });
190
+ it('clamps every run of body copy to the readable measure', () => {
191
+ const page = composeBoard(ALL_SECTIONS);
192
+ for (const el of page.elements) {
193
+ if (el.type === 'text' && el.fontSize === TYPE_SCALE.body.size) {
194
+ expect(el.width, `${el.id} is too wide to read comfortably`).toBeLessThanOrEqual(MEASURE);
195
+ }
196
+ }
197
+ });
198
+ it('gives every element a unique id', () => {
199
+ const ids = composeBoard(ALL_SECTIONS).elements.map((el) => el.id);
200
+ expect(new Set(ids).size).toBe(ids.length);
201
+ });
202
+ it('orders the layer list to match the elements', () => {
203
+ const page = composeBoard(ALL_SECTIONS);
204
+ expect(page.layerOrder).toEqual(page.elements.map((el) => el.id));
205
+ page.elements.forEach((el, i) => expect(el.zIndex).toBe(i));
206
+ });
207
+ it('paints only with token colours', () => {
208
+ const allowed = new Set([...Object.values(COLOR), ...Object.values(STICKY)]);
209
+ const page = composeBoard(ALL_SECTIONS);
210
+ for (const el of page.elements) {
211
+ const used = [];
212
+ if ('fill' in el)
213
+ used.push(el.fill);
214
+ if ('stroke' in el)
215
+ used.push(el.stroke);
216
+ if ('color' in el)
217
+ used.push(el.color);
218
+ if ('fontColor' in el)
219
+ used.push(el.fontColor);
220
+ if ('borderColor' in el)
221
+ used.push(el.borderColor);
222
+ if ('headerBg' in el)
223
+ used.push(el.headerBg);
224
+ if ('cellBg' in el)
225
+ used.push(el.cellBg);
226
+ if ('textColor' in el)
227
+ used.push(el.textColor);
228
+ for (const c of used) {
229
+ if (c === undefined)
230
+ continue;
231
+ expect(allowed.has(c), `${el.id} uses off-palette ${c}`).toBe(true);
232
+ }
233
+ }
234
+ });
235
+ it('sizes every element to a whole hundredth, so shared edges line up', () => {
236
+ for (const el of composeBoard(ALL_SECTIONS).elements) {
237
+ for (const n of [el.x, el.y, el.width, el.height]) {
238
+ expect(Math.round(n * 100) / 100, el.id).toBe(n);
239
+ }
240
+ }
241
+ });
242
+ it('narrows with the column instead of overflowing it', () => {
243
+ const narrow = composeBoard(ALL_SECTIONS, { columnWidth: 720 });
244
+ const bleeding = new Set(narrow.bleedIds);
245
+ for (const el of positioned(narrow.elements)) {
246
+ if (bleeding.has(el.id))
247
+ continue;
248
+ expect(el.x + el.width, el.id).toBeLessThanOrEqual(CANVAS_MARGIN + 720 + 0.01);
249
+ }
250
+ });
251
+ it('rejects an unknown section type rather than emitting a broken board', () => {
252
+ expect(() => composeBoard([{ type: 'banner' }])).toThrow(/Unknown section type/);
253
+ });
254
+ it('states its own leading on every text element', () => {
255
+ // The canvas falls back to 1.3 when absent, which overruns the box a
256
+ // display headline was measured for. Every text element must say.
257
+ const sizeToRole = new Map(Object.keys(TYPE_SCALE).map((r) => [TYPE_SCALE[r].size, r]));
258
+ for (const el of composeBoard(ALL_SECTIONS).elements) {
259
+ if (el.type !== 'text')
260
+ continue;
261
+ const role = sizeToRole.get(el.fontSize);
262
+ expect(role, `${el.id} uses off-scale size ${el.fontSize}`).toBeDefined();
263
+ expect(el.lineHeight, el.id).toBe(TYPE_SCALE[role].lineHeight);
264
+ }
265
+ });
266
+ it('fills in the chart discriminator a caller left out', () => {
267
+ const page = composeBoard([{
268
+ type: 'chartPanel',
269
+ content: {
270
+ title: 'Spend',
271
+ chart: { kind: 'chart', chartType: 'donut', data: { labels: ['A', 'B'], values: [1, 2] } },
272
+ },
273
+ }]);
274
+ const chart = page.elements.find((el) => el.type === 'chart');
275
+ expect(chart.data.type).toBe('donut');
276
+ });
277
+ it('leaves a chart discriminator the caller supplied alone', () => {
278
+ const page = composeBoard([{
279
+ type: 'chartPanel',
280
+ content: {
281
+ title: 'Spend',
282
+ chart: { kind: 'chart', chartType: 'bar', data: { type: 'line', labels: ['A'], series: [] } },
283
+ },
284
+ }]);
285
+ const chart = page.elements.find((el) => el.type === 'chart');
286
+ expect(chart.data.type).toBe('line');
287
+ });
288
+ it('never rounds a rectangle past a true pill', () => {
289
+ // SVG clamps rx and ry separately, so an unclamped radius turns a
290
+ // button into an oval.
291
+ for (const el of composeBoard(ALL_SECTIONS).elements) {
292
+ if (el.type !== 'rectangle')
293
+ continue;
294
+ const r = el.cornerRadius ?? 0;
295
+ expect(r, el.id).toBeLessThanOrEqual(Math.min(el.width, el.height) / 2 + 0.01);
296
+ }
297
+ });
298
+ it('writes the art direction inside a placeholder so the gap explains itself', () => {
299
+ const brief = 'Wide shot of a workshop bench, warm light, shot from above.';
300
+ const page = composeBoard([{ type: 'imageBand', content: { visual: { kind: 'placeholder', brief } } }]);
301
+ const texts = page.elements.filter((el) => el.type === 'text');
302
+ expect(texts.some((el) => el.text === brief)).toBe(true);
303
+ expect(page.elements.some((el) => el.type === 'icon')).toBe(true);
304
+ });
305
+ it('keeps every slide inside its own screen', () => {
306
+ const slides = composeSlides(ALL_SECTIONS);
307
+ expect(slides.length).toBeGreaterThan(1);
308
+ const usable = SLIDE_HEIGHT - CANVAS_MARGIN * 2;
309
+ for (const [i, slide] of slides.entries()) {
310
+ // A single section taller than a screen gets a page to itself and is
311
+ // allowed to overrun; anything else must fit.
312
+ if (slide.elements.length && slide.height > usable) {
313
+ expect(slides.filter((_, j) => j === i)[0].height, `slide ${i + 1}`).toBeGreaterThan(0);
314
+ }
315
+ }
316
+ });
317
+ it('places every section exactly once across the slides', () => {
318
+ const oneColumn = composeBoard(ALL_SECTIONS);
319
+ const slides = composeSlides(ALL_SECTIONS);
320
+ const spread = slides.reduce((n, s) => n + s.elements.length, 0);
321
+ expect(spread).toBe(oneColumn.elements.length);
322
+ });
323
+ it('starts every slide at the top margin', () => {
324
+ for (const slide of composeSlides(ALL_SECTIONS)) {
325
+ const top = Math.min(...positioned(slide.elements).map((el) => el.y));
326
+ expect(top).toBeGreaterThanOrEqual(CANVAS_MARGIN - 0.01);
327
+ }
328
+ });
329
+ });
330
+ describe('board styles', () => {
331
+ it('holds every layout invariant in all four styles', () => {
332
+ for (const style of BOARD_STYLE_IDS) {
333
+ const page = composeBoard(ALL_SECTIONS, { style });
334
+ const ids = page.elements.map((el) => el.id);
335
+ expect(new Set(ids).size, style).toBe(ids.length);
336
+ const bleeding = new Set(page.bleedIds);
337
+ for (const el of positioned(page.elements)) {
338
+ if (bleeding.has(el.id))
339
+ continue;
340
+ expect(el.x, `${style}/${el.id}`).toBeGreaterThanOrEqual(CANVAS_MARGIN - 0.01);
341
+ expect(el.x + el.width, `${style}/${el.id}`).toBeLessThanOrEqual(CANVAS_MARGIN + DEFAULT_COLUMN + 0.01);
342
+ }
343
+ for (const el of page.elements) {
344
+ if (el.type === 'text' && el.fontSize === TYPE_SCALE.body.size) {
345
+ expect(el.width, `${style}/${el.id}`).toBeLessThanOrEqual(MEASURE);
346
+ }
347
+ }
348
+ }
349
+ });
350
+ it('keeps every section inside its reported height in all four styles', () => {
351
+ for (const style of BOARD_STYLE_IDS) {
352
+ for (const spec of ALL_SECTIONS) {
353
+ const single = composeBoard([spec], { style });
354
+ const bottom = CANVAS_MARGIN + single.height;
355
+ for (const el of positioned(single.elements)) {
356
+ expect(el.y + el.height, `${style}/${spec.type}/${el.id}`).toBeLessThanOrEqual(bottom + 0.01);
357
+ }
358
+ }
359
+ }
360
+ });
361
+ it('paints only with token colours in all four styles', () => {
362
+ const allowed = new Set([...Object.values(COLOR), ...Object.values(STICKY)]);
363
+ for (const style of BOARD_STYLE_IDS) {
364
+ for (const el of composeBoard(ALL_SECTIONS, { style }).elements) {
365
+ const used = [];
366
+ if ('fill' in el)
367
+ used.push(el.fill);
368
+ if ('stroke' in el)
369
+ used.push(el.stroke);
370
+ if ('color' in el)
371
+ used.push(el.color);
372
+ for (const c of used) {
373
+ if (c === undefined)
374
+ continue;
375
+ expect(allowed.has(c), `${style}/${el.id} uses off-palette ${c}`).toBe(true);
376
+ }
377
+ }
378
+ }
379
+ });
380
+ it('marks the hero differently in each style, since that is the clearest tell', () => {
381
+ const heroOnly = [ALL_SECTIONS[0]];
382
+ const markOf = (style) => {
383
+ const els = composeBoard(heroOnly, { style: style }).elements;
384
+ const rule = els.find((el) => el.id.includes('rule'));
385
+ if (!rule || rule.type !== 'line')
386
+ return 'none';
387
+ return rule.stroke === COLOR.accent ? 'accent-rule' : 'hairline';
388
+ };
389
+ expect(markOf('product')).toBe('accent-rule');
390
+ expect(markOf('editorial')).toBe('none');
391
+ expect(markOf('statement')).toBe('none');
392
+ expect(markOf('technical')).toBe('hairline');
393
+ });
394
+ it('sets the hero in a different face or size per style', () => {
395
+ const headlines = BOARD_STYLE_IDS.map((style) => {
396
+ const el = composeBoard([ALL_SECTIONS[0]], { style }).elements
397
+ .find((e) => e.id.includes('headline'));
398
+ return `${el.fontFamily}/${el.fontSize}`;
399
+ });
400
+ // Not all four need be unique, but they must not all be the same.
401
+ expect(new Set(headlines).size).toBeGreaterThan(2);
402
+ });
403
+ it('treats feature cards differently, so a grid is not always a white box', () => {
404
+ const grid = ALL_SECTIONS.find((s) => s.type === 'featureGrid');
405
+ const shapeOf = (style) => {
406
+ const els = composeBoard([grid], { style: style }).elements;
407
+ const card = els.find((el) => el.id.includes('card-0'));
408
+ if (!card)
409
+ return 'divided';
410
+ return card.shadow ? 'raised' : 'flat';
411
+ };
412
+ expect(shapeOf('product')).toBe('raised');
413
+ expect(shapeOf('editorial')).toBe('divided');
414
+ expect(shapeOf('technical')).toBe('flat');
415
+ });
416
+ it('falls back to the default rather than throwing on an unknown style', () => {
417
+ const odd = composeBoard(ALL_SECTIONS, { style: 'baroque' });
418
+ const product = composeBoard(ALL_SECTIONS, { style: 'product' });
419
+ expect(odd.elements.length).toBe(product.elements.length);
420
+ });
421
+ it('describes what each style suits, so the model can choose', () => {
422
+ for (const id of BOARD_STYLE_IDS) {
423
+ expect(BOARD_STYLES[id].suits.length, id).toBeGreaterThan(20);
424
+ }
425
+ });
426
+ it('gives each style its own breathing room', () => {
427
+ // Total board height is not a proxy for the gap: a divided card is
428
+ // shorter than a padded one, so the sections themselves differ too.
429
+ // Compare the gaps directly instead.
430
+ const gaps = BOARD_STYLE_IDS.map((style) => SECTION_GAPS[BOARD_STYLES[style].gap]);
431
+ expect(new Set(gaps).size, 'every style uses the same gap').toBeGreaterThan(1);
432
+ expect(SECTION_GAPS[BOARD_STYLES.technical.gap])
433
+ .toBeLessThan(SECTION_GAPS[BOARD_STYLES.editorial.gap]);
434
+ });
435
+ it('separates sections by that style\'s gap, exactly once', () => {
436
+ for (const style of BOARD_STYLE_IDS) {
437
+ const gap = SECTION_GAPS[BOARD_STYLES[style].gap];
438
+ const a = composeBoard([ALL_SECTIONS[1]], { style });
439
+ const b = composeBoard([ALL_SECTIONS[2]], { style });
440
+ const both = composeBoard([ALL_SECTIONS[1], ALL_SECTIONS[2]], { style });
441
+ expect(both.height, style).toBeCloseTo(a.height + gap + b.height, 1);
442
+ }
443
+ });
444
+ it('makes the whole button clickable, not just its text', () => {
445
+ const page = composeBoard([{
446
+ type: 'ctaBand',
447
+ content: { headline: 'Jetzt starten', buttonLabel: 'Workspace öffnen', href: 'https://dversum.com/register' },
448
+ }]);
449
+ const linked = page.elements.filter((el) => el.link);
450
+ expect(linked.map((el) => el.type).sort()).toEqual(['rectangle', 'text']);
451
+ for (const el of linked) {
452
+ expect(el.link).toBe('https://dversum.com/register');
453
+ }
454
+ });
455
+ it('drops a link that could run code rather than writing it to the board', () => {
456
+ // The board is shared, so a bad href would end up in a viewer's href.
457
+ // It is rejected here as well as at render time.
458
+ const page = composeBoard([{
459
+ type: 'ctaBand',
460
+ content: { headline: 'Jetzt starten', buttonLabel: 'Los', href: 'javascript:alert(1)' },
461
+ }]);
462
+ expect(page.elements.some((el) => el.link)).toBe(false);
463
+ });
464
+ it('gives the hero a button only when one was asked for', () => {
465
+ const withCta = composeBoard([{
466
+ type: 'hero',
467
+ content: { headline: 'Vom Projekt zur Rechnung', cta: { label: 'Preise ansehen', href: 'dversum.com/preise' } },
468
+ }]);
469
+ expect(withCta.elements.some((el) => el.link === 'https://dversum.com/preise')).toBe(true);
470
+ const without = composeBoard([{ type: 'hero', content: { headline: 'Vom Projekt zur Rechnung' } }]);
471
+ expect(without.elements.some((el) => el.id.includes('cta'))).toBe(false);
472
+ });
473
+ it('keeps a hero button inside the section it reported', () => {
474
+ const page = composeBoard([{
475
+ type: 'hero',
476
+ content: { headline: 'Vom Projekt zur Rechnung', subline: 'Alles an einem Ort.', cta: { label: 'Los geht es' } },
477
+ }]);
478
+ const bottom = CANVAS_MARGIN + page.height;
479
+ for (const el of positioned(page.elements)) {
480
+ expect(el.y + el.height, el.id).toBeLessThanOrEqual(bottom + 0.01);
481
+ }
482
+ });
483
+ it('gives the hero a screen of its own in page layout, but not in slides', () => {
484
+ const spec = { type: 'hero', content: { headline: 'Eure Agentur in einem Workspace.' } };
485
+ const page = composeBoard([spec], { layout: 'page' });
486
+ const slide = composeBoard([spec], { layout: 'slides' });
487
+ expect(page.height).toBe(HERO_HEIGHT);
488
+ expect(slide.height).toBeLessThan(HERO_HEIGHT);
489
+ });
490
+ it('centres the hero content inside the screen it claims', () => {
491
+ const page = composeBoard([{ type: 'hero', content: { headline: 'Kurz.' } }], { layout: 'page' });
492
+ const tops = positioned(page.elements).map((el) => el.y);
493
+ const bottoms = positioned(page.elements).map((el) => el.y + el.height);
494
+ const spaceAbove = Math.min(...tops) - CANVAS_MARGIN;
495
+ const spaceBelow = CANVAS_MARGIN + page.height - Math.max(...bottoms);
496
+ expect(spaceAbove).toBeGreaterThan(100);
497
+ expect(Math.abs(spaceAbove - spaceBelow)).toBeLessThan(2);
498
+ });
499
+ it('lets a group of cards say what it is', () => {
500
+ const withHeading = composeBoard([{
501
+ type: 'featureGrid',
502
+ content: {
503
+ title: 'Alles, was eine Agentur braucht',
504
+ intro: 'Acht Module, ein Login, eine Rechnung.',
505
+ items: [{ icon: 'Receipt', title: 'Rechnungen', body: 'Kurz.' }],
506
+ },
507
+ }]);
508
+ const texts = withHeading.elements.filter((el) => el.type === 'text').map((el) => el.text);
509
+ expect(texts).toContain('Alles, was eine Agentur braucht');
510
+ expect(texts).toContain('Acht Module, ein Login, eine Rechnung.');
511
+ const without = composeBoard([{
512
+ type: 'featureGrid',
513
+ content: { items: [{ icon: 'Receipt', title: 'Rechnungen', body: 'Kurz.' }] },
514
+ }]);
515
+ expect(without.height).toBeLessThan(withHeading.height);
516
+ });
517
+ });
518
+ describe('phone layout', () => {
519
+ it('fits every element inside a phone-width column', () => {
520
+ // The whole point: no horizontal scrolling and nothing clipped.
521
+ const page = composeNarrow(ALL_SECTIONS);
522
+ const right = NARROW_MARGIN + NARROW_WIDTH;
523
+ for (const el of positioned(page.elements)) {
524
+ if (page.bleedIds.includes(el.id))
525
+ continue;
526
+ expect(el.x, el.id).toBeGreaterThanOrEqual(NARROW_MARGIN - 0.01);
527
+ expect(el.x + el.width, el.id).toBeLessThanOrEqual(right + 0.01);
528
+ }
529
+ });
530
+ it('reads at a legible size on a real phone', () => {
531
+ // A 393px phone showing a 392-unit board needs no scaling at all, so
532
+ // body copy lands at its natural 14px instead of the 4px it was.
533
+ const page = composeNarrow(ALL_SECTIONS);
534
+ const boardWidth = NARROW_WIDTH + NARROW_MARGIN * 2;
535
+ expect(boardWidth).toBeLessThanOrEqual(393);
536
+ });
537
+ it('puts feature cards one under the other', () => {
538
+ const page = composeNarrow([{
539
+ type: 'featureGrid',
540
+ content: { items: [
541
+ { icon: 'Receipt', title: 'Eins', body: 'Kurz.' },
542
+ { icon: 'Timer', title: 'Zwei', body: 'Kurz.' },
543
+ { icon: 'Landmark', title: 'Drei', body: 'Kurz.' },
544
+ ] },
545
+ }]);
546
+ const cards = page.elements.filter((el) => el.id.includes('card-'));
547
+ expect(cards).toHaveLength(3);
548
+ // All at the same x, each below the last.
549
+ expect(new Set(cards.map((c) => c.x)).size).toBe(1);
550
+ const ys = cards.map((c) => c.y).sort((a, b) => a - b);
551
+ expect(ys[0]).toBeLessThan(ys[1]);
552
+ expect(ys[1]).toBeLessThan(ys[2]);
553
+ });
554
+ it('stacks a split instead of halving a 360-unit column', () => {
555
+ const spec = {
556
+ type: 'split',
557
+ content: {
558
+ title: 'Aus Stunden wird eine Rechnung',
559
+ body: 'Erfasste Zeiten werden mit einem Klick zu Positionen auf einer Rechnung.',
560
+ visual: { kind: 'placeholder', brief: 'Zeiterfassung links, Rechnung rechts.' },
561
+ },
562
+ };
563
+ const phone = composeNarrow([spec]);
564
+ const desk = composeBoard([spec]);
565
+ // Stacked is taller and narrower than side by side.
566
+ expect(phone.height).toBeGreaterThan(desk.height);
567
+ const widest = Math.max(...positioned(phone.elements).map((el) => el.width));
568
+ expect(widest).toBeLessThanOrEqual(NARROW_WIDTH + 0.01);
569
+ });
570
+ it('runs a sequence down the screen rather than across it', () => {
571
+ const spec = {
572
+ type: 'steps',
573
+ content: { steps: [{ title: 'Anfrage' }, { title: 'Angebot' }, { title: 'Projekt' }, { title: 'Rechnung' }] },
574
+ };
575
+ const dotsOf = (page) => page.elements.filter((el) => el.id.includes('dot-'));
576
+ const across = dotsOf(composeBoard([spec]));
577
+ const down = dotsOf(composeNarrow([spec]));
578
+ expect(new Set(across.map((d) => d.y)).size).toBe(1);
579
+ expect(new Set(down.map((d) => d.x)).size).toBe(1);
580
+ expect(new Set(down.map((d) => d.y)).size).toBe(4);
581
+ });
582
+ it('keeps the hero shorter than a laptop screen, since a phone screen is not one', () => {
583
+ const spec = { type: 'hero', content: { headline: 'Eure Agentur in einem Workspace.' } };
584
+ expect(composeNarrow([spec]).height).toBeLessThan(composeBoard([spec], { layout: 'page' }).height);
585
+ });
586
+ it('holds the same invariants as the wide layout', () => {
587
+ const page = composeNarrow(ALL_SECTIONS);
588
+ const ids = page.elements.map((el) => el.id);
589
+ expect(new Set(ids).size).toBe(ids.length);
590
+ for (const el of page.elements) {
591
+ if (el.type === 'text' && el.fontSize === TYPE_SCALE.body.size) {
592
+ expect(el.width, el.id).toBeLessThanOrEqual(NARROW_WIDTH + 0.01);
593
+ }
594
+ }
595
+ });
596
+ it('works in every style', () => {
597
+ for (const style of BOARD_STYLE_IDS) {
598
+ const page = composeNarrow(ALL_SECTIONS, { style });
599
+ expect(page.elements.length, style).toBeGreaterThan(0);
600
+ for (const el of positioned(page.elements)) {
601
+ if (page.bleedIds.includes(el.id))
602
+ continue;
603
+ expect(el.x + el.width, `${style}/${el.id}`).toBeLessThanOrEqual(NARROW_MARGIN + NARROW_WIDTH + 0.01);
604
+ }
605
+ }
606
+ });
607
+ });
608
+ //# sourceMappingURL=sections.spec.js.map