forked from mermaid-js/mermaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchitecture.spec.ts
More file actions
368 lines (320 loc) · 12.6 KB
/
architecture.spec.ts
File metadata and controls
368 lines (320 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
import { imgSnapshotTest, urlSnapshotTest } from '../../../helpers/util.ts';
describe('architecture diagram', () => {
it('should render a simple architecture diagram with groups', () => {
imgSnapshotTest(
`architecture-beta
group api(cloud)[API]
service db(database)[Database] in api
service disk1(disk)[Storage] in api
service disk2(disk)[Storage] in api
service server(server)[Server] in api
service gateway(internet)[Gateway]
db:L -- R:server
disk1:T -- B:server
disk2:T -- B:db
server:T -- B:gateway
`
);
});
it('should render a simple architecture diagram with titleAndAccessibilities', () => {
imgSnapshotTest(
`architecture-beta
title Simple Architecture Diagram
accTitle: Accessibility Title
accDescr: Accessibility Description
group api(cloud)[API]
service db(database)[Database] in api
service disk1(disk)[Storage] in api
service disk2(disk)[Storage] in api
service server(server)[Server] in api
db:L -- R:server
disk1:T -- B:server
disk2:T -- B:db
`
);
});
it('should render an architecture diagram with groups within groups', () => {
imgSnapshotTest(
`architecture-beta
group api[API]
group public[Public API] in api
group private[Private API] in api
service serv1(server)[Server] in public
service serv2(server)[Server] in private
service db(database)[Database] in private
service gateway(internet)[Gateway] in api
serv1:B -- T:serv2
serv2:L -- R:db
serv1:L -- R:gateway
`
);
});
it('should render an architecture diagram with the fallback icon', () => {
imgSnapshotTest(
`architecture-beta
service unknown(iconnamedoesntexist)[Unknown Icon]
`
);
});
it('should render an architecture diagram with split directioning', () => {
imgSnapshotTest(
`architecture-beta
service db(database)[Database]
service s3(disk)[Storage]
service serv1(server)[Server 1]
service serv2(server)[Server 2]
service disk(disk)[Disk]
db:L -- R:s3
serv1:L -- T:s3
serv2:L -- B:s3
serv1:T -- B:disk
`
);
});
it('should render an architecture diagram with directional arrows', () => {
imgSnapshotTest(
`architecture-beta
service servC(server)[Server 1]
service servL(server)[Server 2]
service servR(server)[Server 3]
service servT(server)[Server 4]
service servB(server)[Server 5]
servC:L --> R:servL
servC:R --> L:servR
servC:T --> B:servT
servC:B --> T:servB
servL:T --> L:servT
servL:B --> L:servB
servR:T --> R:servT
servR:B --> R:servB
`
);
});
it('should render an architecture diagram with group edges', () => {
imgSnapshotTest(
`architecture-beta
group left_group(cloud)[Left]
group right_group(cloud)[Right]
group top_group(cloud)[Top]
group bottom_group(cloud)[Bottom]
group center_group(cloud)[Center]
service left_disk(disk)[Disk] in left_group
service right_disk(disk)[Disk] in right_group
service top_disk(disk)[Disk] in top_group
service bottom_disk(disk)[Disk] in bottom_group
service center_disk(disk)[Disk] in center_group
left_disk{group}:R --> L:center_disk{group}
right_disk{group}:L --> R:center_disk{group}
top_disk{group}:B --> T:center_disk{group}
bottom_disk{group}:T --> B:center_disk{group}
`
);
});
it('should render an architecture diagram with edge labels', () => {
imgSnapshotTest(
`architecture-beta
service servC(server)[Server 1]
service servL(server)[Server 2]
service servR(server)[Server 3]
service servT(server)[Server 4]
service servB(server)[Server 5]
servC:L -[Label]- R:servL
servC:R -[Label]- L:servR
servC:T -[Label]- B:servT
servC:B -[Label]- T:servB
servL:T -[Label]- L:servT
servL:B -[Label]- L:servB
servR:T -[Label]- R:servT
servR:B -[Label]- R:servB
`
);
});
it('should render an architecture diagram with simple junction edges', () => {
imgSnapshotTest(
`architecture-beta
service left_disk(disk)[Disk]
service top_disk(disk)[Disk]
service bottom_disk(disk)[Disk]
service top_gateway(internet)[Gateway]
service bottom_gateway(internet)[Gateway]
junction juncC
junction juncR
left_disk:R -- L:juncC
top_disk:B -- T:juncC
bottom_disk:T -- B:juncC
juncC:R -- L:juncR
top_gateway:B -- T:juncR
bottom_gateway:T -- B:juncR
`
);
});
it('should render an architecture diagram with complex junction edges', () => {
imgSnapshotTest(
`architecture-beta
group left
group right
service left_disk(disk)[Disk] in left
service top_disk(disk)[Disk] in left
service bottom_disk(disk)[Disk] in left
service top_gateway(internet)[Gateway] in right
service bottom_gateway(internet)[Gateway] in right
junction juncC in left
junction juncR in right
left_disk:R -- L:juncC
top_disk:B -- T:juncC
bottom_disk:T -- B:juncC
top_gateway:B --> T:juncR
bottom_gateway:T --> B:juncR
juncC{group}:R --> L:juncR{group}
`
);
});
it('should render an architecture diagram with a reasonable height', () => {
imgSnapshotTest(
`architecture-beta
group federated(cloud)[Federated Environment]
service server1(server)[System] in federated
service edge(server)[Edge Device] in federated
server1:R -- L:edge
group on_prem(cloud)[Hub]
service firewall(server)[Firewall Device] in on_prem
service server(server)[Server] in on_prem
firewall:R -- L:server
service db1(database)[db1] in on_prem
service db2(database)[db2] in on_prem
service db3(database)[db3] in on_prem
service db4(database)[db4] in on_prem
service db5(database)[db5] in on_prem
service db6(database)[db6] in on_prem
junction mid in on_prem
server:B -- T:mid
junction 1Leftofmid in on_prem
1Leftofmid:R -- L:mid
1Leftofmid:B -- T:db1
junction 2Leftofmid in on_prem
2Leftofmid:R -- L:1Leftofmid
2Leftofmid:B -- T:db2
junction 3Leftofmid in on_prem
3Leftofmid:R -- L:2Leftofmid
3Leftofmid:B -- T:db3
junction 1RightOfMid in on_prem
mid:R -- L:1RightOfMid
1RightOfMid:B -- T:db4
junction 2RightOfMid in on_prem
1RightOfMid:R -- L:2RightOfMid
2RightOfMid:B -- T:db5
junction 3RightOfMid in on_prem
2RightOfMid:R -- L:3RightOfMid
3RightOfMid:B -- T:db6
edge:R -- L:firewall
`
);
});
it('should render a deterministic layout for a complex deeply-nested diagram', () => {
imgSnapshotTest(
`architecture-beta
group sub1(cloud)[Subscription A]
group vnet1(cloud)[VNet A] in sub1
service vm1(server)[VM] in vnet1
group sub2(cloud)[Subscription B]
group shared(cloud)[Shared] in sub2
service reg(database)[Registry] in shared
group env(cloud)[Environment] in sub2
group vnet(cloud)[VNet] in env
group snet1(cloud)[App Subnet] in vnet
service nsg(server)[NSG] in snet1
service asp(server)[App Plan] in snet1
service web(server)[Web App] in snet1
group snet2(cloud)[PE Subnet] in vnet
service pe1(server)[PE Blob] in snet2
service pe2(server)[PE Bus] in snet2
service storage(disk)[Storage] in env
service container(disk)[Container] in env
service bus(server)[Service Bus] in env
service dns(server)[DNS Zone] in env
service client(internet)[Client]
reg:B --> T:web
nsg:R --> L:asp
asp:R --> L:web
web:R --> L:pe1
pe1:R --> L:storage
storage:B --> T:container
web:B --> T:pe2
pe2:R --> L:bus
vm1:R --> L:pe2
`,
{ architecture: { randomize: false } }
);
});
it('should render edges at correct length', () => {
imgSnapshotTest(`
architecture-beta
service cell[Table Cell]
service colspan[colspan]
service rowspan[rowspan]
cell:R --> L:colspan
cell:B --> T:rowspan
`);
});
it('should render with randomize: true without errors', () => {
imgSnapshotTest(
`architecture-beta
group sub1(cloud)[Subscription A]
group vnet1(cloud)[VNet A] in sub1
service vm1(server)[VM] in vnet1
group sub2(cloud)[Subscription B]
group shared(cloud)[Shared] in sub2
service reg(database)[Registry] in shared
group env(cloud)[Environment] in sub2
group vnet(cloud)[VNet] in env
group snet1(cloud)[App Subnet] in vnet
service nsg(server)[NSG] in snet1
service asp(server)[App Plan] in snet1
service web(server)[Web App] in snet1
group snet2(cloud)[PE Subnet] in vnet
service pe1(server)[PE Blob] in snet2
service pe2(server)[PE Bus] in snet2
service storage(disk)[Storage] in env
service container(disk)[Container] in env
service bus(server)[Service Bus] in env
service dns(server)[DNS Zone] in env
service client(internet)[Client]
reg:B --> T:web
nsg:R --> L:asp
asp:R --> L:web
web:R --> L:pe1
pe1:R --> L:storage
storage:B --> T:container
web:B --> T:pe2
pe2:R --> L:bus
vm1:R --> L:pe2
`,
{ architecture: { randomize: true }, screenshot: false }
);
});
});
describe('architecture - fcose layout knobs', () => {
// A linear chain demonstrates `idealEdgeLengthMultiplier` cleanly: bumping the multiplier
// visibly stretches the gap between successive nodes. The 3-DB → MCP repro for #6120 is
// not used here because that case is rooted in the BFS spatial-map collapsing siblings to
// the same coordinate before fcose runs, which the knobs in this PR cannot escape; the
// declarative `align row|column` directive (separate PR) is the actual fix for that.
const chain = `architecture-beta
service a(server)[A]
service b(server)[B]
service c(server)[C]
a:R --> L:b
b:R --> L:c
`;
it('should render with default fcose knobs', () => {
imgSnapshotTest(chain);
});
it('should render with an increased idealEdgeLengthMultiplier', () => {
imgSnapshotTest(chain, { architecture: { idealEdgeLengthMultiplier: 3 } });
});
});
describe('architecture - external', () => {
it('should allow adding external icons', () => {
urlSnapshotTest('/architecture-external.html');
});
});