1 package e2etests
2
3 import (
4 "testing"
5 )
6
7 func testRegression(t *testing.T) {
8 tcs := []testCase{
9 {
10
11 name: "hex-fill",
12 script: `x: {
13 style.fill: "#0D32B2"
14 }
15 `,
16 },
17 {
18 name: "dagre_special_ids",
19 script: `
20 ninety\nnine
21 eighty\reight
22 seventy\r\nseven
23 a\\yode -> there
24 a\\"ode -> there
25 a\\node -> there
26 `,
27 },
28 {
29 name: "empty_sequence",
30 script: `
31 A: hello {
32 shape: sequence_diagram
33 }
34
35 B: goodbye {
36 shape: sequence_diagram
37 }
38
39 A->B`,
40 },
41 {
42 name: "undeclared_nested_sequence",
43 script: `shape: sequence_diagram
44 group.nested: {
45 a -> b
46 }
47 `,
48 expErr: "no actors declared in sequence diagram",
49 },
50 {
51 name: "class_font_style_sequence",
52 script: `shape: sequence_diagram
53 a: {
54 shape: class
55 style: {
56 font-color: red
57 }
58 }
59 `,
60 },
61 {
62 name: "nested_steps",
63 script: `a: {
64 a: {
65 shape: step
66 }
67 b: {
68 shape: step
69 }
70 a -> b
71 }
72
73 c: {
74 shape: step
75 }
76 d: {
77 shape: step
78 }
79 c -> d
80 `,
81 },
82 {
83 name: "sequence_diagram_span_cover",
84 script: `shape: sequence_diagram
85 b.1 -> b.1
86 b.1 -> b.1`,
87 }, {
88 name: "sequence_diagram_no_message",
89 script: `shape: sequence_diagram
90 a: A
91 b: B`,
92 },
93 {
94 name: "root-container",
95 script: `main: {
96 x -> y
97 y <- z
98 }
99
100 root: {
101 x -> y
102 y <- z
103 }`,
104 },
105 {
106 name: "sequence_diagram_name_crash",
107 script: `foo: {
108 shape: sequence_diagram
109 a -> b
110 }
111 foobar: {
112 shape: sequence_diagram
113 c -> d
114 }
115 foo -> foobar`,
116 },
117 {
118 name: "sql_table_overflow",
119 script: `
120 table: sql_table_overflow {
121 shape: sql_table
122 short: loooooooooooooooooooong
123 loooooooooooooooooooong: short
124 }
125 table_constrained: sql_table_constrained_overflow {
126 shape: sql_table
127 short: loooooooooooooooooooong {
128 constraint: unique
129 }
130 loooooooooooooooooooong: short {
131 constraint: foreign_key
132 }
133 }
134 `,
135 },
136 {
137 name: "elk_alignment",
138 script: `
139 direction: down
140
141 build_workflow: lambda-build.yaml {
142
143 push: Push to main branch {
144 style.font-size: 25
145 }
146
147 GHA: GitHub Actions {
148 style.font-size: 25
149 }
150
151 S3.style.font-size: 25
152 Terraform.style.font-size: 25
153 AWS.style.font-size: 25
154
155 push -> GHA: Triggers {
156 style.font-size: 20
157 }
158
159 GHA -> S3: Builds zip and pushes it {
160 style.font-size: 20
161 }
162
163 S3 <-> Terraform: Pulls zip to deploy {
164 style.font-size: 20
165 }
166
167 Terraform -> AWS: Changes live lambdas {
168 style.font-size: 20
169 }
170 }
171
172 deploy_workflow: lambda-deploy.yaml {
173
174 manual: Manual Trigger {
175 style.font-size: 25
176 }
177
178 GHA: GitHub Actions {
179 style.font-size: 25
180 }
181
182 AWS.style.font-size: 25
183
184 Manual -> GHA: Launches {
185 style.font-size: 20
186 }
187
188 GHA -> AWS: Builds zip\npushes them to S3.\n\nDeploys lambdas\nusing Terraform {
189 style.font-size: 20
190 }
191 }
192
193 apollo_workflow: apollo-deploy.yaml {
194
195 apollo: Apollo Repo {
196 style.font-size: 25
197 }
198
199 GHA: GitHub Actions {
200 style.font-size: 25
201 }
202
203 AWS.style.font-size: 25
204
205 apollo -> GHA: Triggered manually/push to master test test test test test test test {
206 style.font-size: 20
207 }
208
209 GHA -> AWS: test {
210 style.font-size: 20
211 }
212 }
213 `,
214 },
215 {
216 name: "dagre_edge_label_spacing",
217 script: `direction: right
218
219 build_workflow: lambda-build.yaml {
220
221 push: Push to main branch {
222 style.font-size: 25
223 }
224 GHA: GitHub Actions {
225 style.font-size: 25
226 }
227 S3.style.font-size: 25
228 Terraform.style.font-size: 25
229 AWS.style.font-size: 25
230
231 push -> GHA: Triggers
232 GHA -> S3: Builds zip & pushes it
233 S3 <-> Terraform: Pulls zip to deploy
234 Terraform -> AWS: Changes the live lambdas
235 }
236 `,
237 },
238 {
239 name: "query_param_escape",
240 script: `my network: {
241 icon: https://icons.terrastruct.com/infra/019-network.svg?fuga=1&hoge
242 }
243 `,
244 },
245 {
246 name: "elk_order",
247 script: `queue: {
248 shape: queue
249 label: ''
250
251 M0
252 M1
253 M2
254 M3
255 M4
256 M5
257 M6
258 }
259
260 m0_desc: |md
261 Oldest message
262 |
263 m0_desc -> queue.M0
264
265 m2_desc: |md
266 Offset
267 |
268 m2_desc -> queue.M2
269
270 m5_desc: |md
271 Last message
272 |
273 m5_desc -> queue.M5
274
275 m6_desc: |md
276 Next message will be\
277 inserted here
278 |
279 m6_desc -> queue.M6
280 `,
281 },
282 {
283 name: "unnamed_class_table_code",
284 script: `
285
286 class2 -> users -> code
287
288 class2: "" {
289 shape: class
290 -num: int
291 -timeout: int
292 -pid
293
294 +getStatus(): Enum
295 +getJobs(): "Job[]"
296 +setTimeout(seconds int)
297 }
298
299 users: "" {
300 shape: sql_table
301 id: int
302 name: string
303 email: string
304 password: string
305 last_login: datetime
306 }
307
308 code: |go
309 a := 5
310 b := a + 7
311 fmt.Printf("%d", b)
312 |
313 `,
314 },
315 {
316 name: "elk_img_empty_label_panic",
317 script: `
318 img: {
319 label: ""
320 shape: image
321 icon: https://icons.terrastruct.com/infra/019-network.svg
322 }
323 ico: {
324 label: ""
325 icon: https://icons.terrastruct.com/infra/019-network.svg
326 }
327 `,
328 },
329 {
330 name: "only_header_class_table",
331 script: `
332
333 class2: RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBuffer {
334 shape: class
335 }
336
337 table: RefreshAuthorizationPolicyCache {
338 shape: sql_table
339 }
340
341 table with short col: RefreshAuthorizationPolicyCache {
342 shape: sql_table
343 ok
344 }
345
346 class2 -> table -> table with short col
347 `,
348 },
349 {
350 name: "overlapping-edge-label",
351 script: `k8s: Kubernetes
352 k8s.m1: k8s-master1
353 k8s.m2: k8s-master2
354 k8s.m3: k8s-master3
355 k8s.w1: k8s-worker1
356 k8s.w2: k8s-worker2
357 k8s.w3: k8s-worker3
358
359 osvc: opensvc
360 osvc.vm1: VM1
361 osvc.vm2: VM2
362
363 k8s -> osvc: keycloak
364 k8s -> osvc: heptapod
365 k8s -> osvc: harbor
366 k8s -> osvc: vault
367 `,
368 },
369 {
370 name: "no-lexer",
371 script: `x: |d2
372 x -> y
373 |
374 `,
375 },
376 {
377 name: "dagre_broken_arrowhead",
378 script: `
379 a.b -> a.c: "line 1\nline 2\nline 3\nline 4" {
380 style: {
381 font-color: red
382 stroke: red
383 }
384 target-arrowhead: {
385 shape: diamond
386 }
387 }
388 a.1 -> a.c
389 a.2 <-> a.c
390 a.c {
391 style.stroke: white
392 d
393 }
394 `,
395 },
396 {
397 name: "code_leading_trailing_newlines",
398 script: `
399 hello world: |python
400
401
402 # 2 leading, 2 trailing
403 def hello():
404
405 print "world"
406
407
408 |
409
410 no trailing: |python
411
412
413 # 2 leading
414 def hello():
415
416 print "world"
417 |
418
419 no leading: |python
420 # 2 trailing
421 def hello():
422
423 print "world"
424
425
426 |
427 `,
428 },
429 {
430 name: "code_leading_newlines",
431 script: `
432 5 leading: |python
433
434
435
436
437
438 def hello():
439
440 print "world"
441 |
442 8 total: |python
443 # 1 leading
444 # 2 leading
445 # 3 leading
446 # 4 leading
447 # 5 leading
448 def hello():
449
450 print "world"
451 |
452 1 leading: |python
453
454 def hello():
455
456 print "world"
457 |
458 4 total: |python
459 # 1 leading
460 def hello():
461
462 print "world"
463 |
464 2 leading: |python
465
466
467 def hello():
468
469 print "world"
470 |
471 5 total: |python
472 # 1 leading
473 # 2 leading
474 def hello():
475
476 print "world"
477 |
478 `,
479 },
480 {
481 name: "code_trailing_newlines",
482 script: `
483 5 trailing: |python
484 def hello():
485
486 print "world"
487
488
489
490
491
492 |
493 8 total: |python
494 def hello():
495
496 print "world"
497 # 1 trailing
498 # 2 trailing
499 # 3 trailing
500 # 4 trailing
501 # 5 trailing
502 |
503 1 trailing: |python
504 def hello():
505
506 print "world"
507
508 |
509 4 total: |python
510 def hello():
511
512 print "world"
513 # 1 trailing
514 |
515 2 trailing: |python
516 def hello():
517
518 print "world"
519
520
521 |
522 5 total: |python
523 def hello():
524
525 print "world"
526 # 1 trailing
527 # 2 trailing
528 |
529 `,
530 },
531 {
532 name: "md_h1_li_li",
533 script: mdTestScript(`
534 # hey
535 - they
536 1. they
537 `),
538 },
539 {
540 name: "elk_loop_panic",
541 script: `x: {
542 a
543 b
544 }
545
546 x.a -> x.a
547 `,
548 },
549 {
550 name: "opacity-on-label",
551 script: `x.style.opacity: 0.4
552 y: |md
553 linux: because a PC is a terrible thing to waste
554 | {
555 style.opacity: 0.4
556 }
557 x -> a: {
558 label: You don't have to know how the computer works,\njust how to work the computer.
559 style.opacity: 0.4
560 }
561 `,
562 },
563 {
564 name: "sequence_diagram_self_edge_group_overlap",
565 script: `
566 shape: sequence_diagram
567 a: A
568 b: B
569 c: C
570 group 1: {
571 a -> a
572 }
573 group 2: {
574 a -> b
575 }
576 group 3: {
577 a -> a.a
578 }
579 group 4: {
580 a.a -> b
581 }
582 group 5: {
583 b -> b
584 b -> b
585 }
586 group 6: {
587 b -> a
588 }
589 group 7: {
590 a -> a
591 }
592 group 8: {
593 a -> a
594 }
595 a -> a
596 group 9: {
597 a -> a
598 }
599 a -> a
600
601 b -> c
602 group 10: {
603 c -> c
604 }
605 b -> c
606 group 11: {
607 c -> c
608 }
609 b -> c
610
611 `,
612 },
613 {
614 name: "empty_class_height",
615 script: `
616 class1: class with rows {
617 shape: class
618 -num: int
619 -timeout: int
620 }
621
622 class2: class without rows {
623 shape: class
624 }
625 `,
626 },
627 {
628 name: "just-width",
629 script: `x: "teamwork: having someone to blame" {
630 width: 100
631 }
632 `,
633 },
634 {
635 name: "sequence-panic",
636 script: `
637 shape: sequence_diagram
638
639 a
640
641 group: {
642 inner_group: {
643 a -> b
644 }
645 }
646 `,
647 expErr: "could not find center of b. Is it declared as an actor?",
648 },
649 {
650 name: "ampersand-escape",
651 script: `hy: &∈ {
652 tooltip: beans & rice
653 }
654 `,
655 },
656 {
657 name: "dagre-disconnect",
658 script: `a: {
659 k.t -> f.i
660 f.g -> _.s.n
661 }
662 k
663 k.s <-> u.o
664 h.m.s -> a.f.g
665
666 a.f.j -> u.s.j
667 u: {
668 c -> _.s.z.c
669 }
670
671 s: {
672 n: {
673 style.stroke: red
674 f
675 }
676 }
677
678 s.n -> y.r: {style.stroke-width: 8; style.stroke: red}
679 y.r -> a.g.i: 1\n2\n3\n4
680 `,
681 },
682 {
683 name: "sequence-note-escape-group",
684 script: `shape: sequence_diagram
685 a
686 b
687
688 "04:20,11:20": {
689 "loop through each table": {
690 a."start_time = datetime.datetime.now"
691 a -> b
692 }
693 }
694 `,
695 },
696 loadFromFile(t, "unconnected"),
697 {
698 name: "straight_hierarchy_container_direction_right",
699 script: `
700 direction: right
701 a
702 c
703 b
704
705 l1: {
706 b
707 a
708 c
709 }
710
711 b -> l1.b
712 a -> l1.a
713 c -> l1.c
714
715 l2c1: {
716 a
717 }
718 l1.a -> l2c1.a
719
720 l2c3: {
721 c
722 }
723 l1.c -> l2c3.c
724
725 l2c2: {
726 b
727 }
728 l1.b -> l2c2.b
729
730 l3c1: {
731 a
732 b
733 }
734 l2c1.a -> l3c1.a
735 l2c2.b -> l3c1.b
736
737 l3c2: {
738 c
739 }
740 l2c3.c -> l3c2.c
741
742 l4: {
743 c1: {
744 a
745 }
746 c2: {
747 b
748 }
749 c3: {
750 c
751 }
752 }
753 l3c1.a -> l4.c1.a
754 l3c1.b -> l4.c2.b
755 l3c2.c -> l4.c3.c`,
756 },
757 {
758 name: "link_with_ampersand",
759 script: `a.link: https://calendar.google.com/calendar/u/0/r?tab=mc&pli=1`,
760 },
761 {
762 name: "bold_edge_label",
763 script: `
764 direction: right
765 x -> y: sync
766 y -> z: sync {
767 style.bold: true
768 }
769 `,
770 },
771 {
772 name: "grid_in_constant_near",
773 script: `
774 a
775 b
776 c
777 x: {
778 near: top-right
779 grid-columns: 1
780 y
781 z
782 }
783 `,
784 },
785 {
786 name: "md_font_weight",
787 script: `
788 explanation: |md
789 # I can do headers
790
791 - lists
792 - lists
793
794 And other normal markdown stuff
795 |
796 `,
797 },
798 {
799 name: "grid_panic",
800 script: `
801 2 rows 1 obj: {
802 grid-rows: 2
803
804 one
805 }
806 3 rows 2 obj: {
807 grid-rows: 3
808
809 one
810 two
811 }
812 4 columns 2 obj: {
813 grid-columns: 4
814
815 one
816 two
817 }
818 `,
819 },
820 {
821 name: "long_arrowhead_label",
822 script: `
823 a -> b: {
824 target-arrowhead: "a to b with unexpectedly long target arrowhead label"
825 }
826 `,
827 },
828 {
829 name: "arrowhead_sizes_with_labels",
830 script: `
831 triangle: {
832 a <-> b: {
833 source-arrowhead: 1
834 target-arrowhead: 1
835 }
836 c <-> d: {
837 source-arrowhead: 1
838 target-arrowhead: 1
839 style.stroke-width: 8
840 }
841 }
842 none: {
843 a -- b: {
844 source-arrowhead: 1
845 target-arrowhead: 1
846 }
847 c -- d: {
848 source-arrowhead: 1
849 target-arrowhead: 1
850 style.stroke-width: 8
851 }
852 }
853 arrow: {
854 a <-> b: {
855 source-arrowhead: 1 {
856 shape: arrow
857 }
858 target-arrowhead: 1 {
859 shape: arrow
860 }
861 }
862 c <-> d: {
863 source-arrowhead: 1 {
864 shape: arrow
865 }
866 target-arrowhead: 1 {
867 shape: arrow
868 }
869 style.stroke-width: 8
870 }
871 }
872 diamond: {
873 a <-> b: {
874 source-arrowhead: 1 {
875 shape: diamond
876 }
877 target-arrowhead: 1 {
878 shape: diamond
879 }
880 }
881 c <-> d: {
882 source-arrowhead: 1 {
883 shape: diamond
884 }
885 target-arrowhead: 1 {
886 shape: diamond
887 }
888 style.stroke-width: 8
889 }
890 }
891 filled diamond: {
892 a <-> b: {
893 source-arrowhead: 1 {
894 shape: diamond
895 style.filled: true
896 }
897 target-arrowhead: 1 {
898 shape: diamond
899 style.filled: true
900 }
901 }
902 c <-> d: {
903 source-arrowhead: 1 {
904 shape: diamond
905 style.filled: true
906 }
907 target-arrowhead: 1 {
908 shape: diamond
909 style.filled: true
910 }
911 style.stroke-width: 8
912 }
913 }
914 circle: {
915 a <-> b: {
916 source-arrowhead: 1 {
917 shape: circle
918 }
919 target-arrowhead: 1 {
920 shape: circle
921 }
922 }
923 c <-> d: {
924 source-arrowhead: 1 {
925 shape: circle
926 }
927 target-arrowhead: 1 {
928 shape: circle
929 }
930 style.stroke-width: 8
931 }
932 }
933 filled circle: {
934 a <-> b: {
935 source-arrowhead: 1 {
936 shape: circle
937 style.filled: true
938 }
939 target-arrowhead: 1 {
940 shape: circle
941 style.filled: true
942 }
943 }
944 c <-> d: {
945 source-arrowhead: 1 {
946 shape: circle
947 style.filled: true
948 }
949 target-arrowhead: 1 {
950 shape: circle
951 style.filled: true
952 }
953 style.stroke-width: 8
954 }
955 }
956 cf one: {
957 a <-> b: {
958 source-arrowhead: 1 {
959 shape: cf-one
960 }
961 target-arrowhead: 1 {
962 shape: cf-one
963 }
964 }
965 c <-> d: {
966 source-arrowhead: 1 {
967 shape: cf-one
968 }
969 target-arrowhead: 1 {
970 shape: cf-one
971 }
972 style.stroke-width: 8
973 }
974 }
975 cf one required: {
976 a <-> b: {
977 source-arrowhead: 1 {
978 shape: cf-one-required
979 }
980 target-arrowhead: 1 {
981 shape: cf-one-required
982 }
983 }
984 c <-> d: {
985 source-arrowhead: 1 {
986 shape: cf-one-required
987 }
988 target-arrowhead: 1 {
989 shape: cf-one-required
990 }
991 style.stroke-width: 8
992 }
993 }
994 cf many: {
995 a <-> b: {
996 source-arrowhead: 1 {
997 shape: cf-many
998 }
999 target-arrowhead: 1 {
1000 shape: cf-many
1001 }
1002 }
1003 c <-> d: {
1004 source-arrowhead: 1 {
1005 shape: cf-many
1006 }
1007 target-arrowhead: 1 {
1008 shape: cf-many
1009 }
1010 style.stroke-width: 8
1011 }
1012 }
1013 cf many required: {
1014 a <-> b: {
1015 source-arrowhead: 1 {
1016 shape: cf-many-required
1017 }
1018 target-arrowhead: 1 {
1019 shape: cf-many-required
1020 }
1021 }
1022 c <-> d: {
1023 source-arrowhead: 1 {
1024 shape: cf-many-required
1025 }
1026 target-arrowhead: 1 {
1027 shape: cf-many-required
1028 }
1029 style.stroke-width: 8
1030 }
1031 }
1032 `,
1033 },
1034 {
1035 name: "dagre_child_id_id",
1036 script: `direction:right; id -> x.id -> y.z.id`,
1037 },
1038 loadFromFile(t, "slow_grid"),
1039 loadFromFile(t, "grid_oom"),
1040 loadFromFile(t, "cylinder_grid_label"),
1041 loadFromFile(t, "grid_with_latex"),
1042 loadFromFile(t, "icons_on_top"),
1043 loadFromFile(t, "dagre_disconnected_edge"),
1044 loadFromFile(t, "outside_grid_label_position"),
1045 loadFromFile(t, "arrowhead_font_color"),
1046 loadFromFile(t, "multiple_constant_nears"),
1047 loadFromFile(t, "empty_nested_grid"),
1048 loadFromFile(t, "code_font_size"),
1049 loadFromFile(t, "disclaimer"),
1050 loadFromFile(t, "grid_rows_gap_bug"),
1051 loadFromFile(t, "grid_image_label_position"),
1052 loadFromFile(t, "glob_dimensions"),
1053 loadFromFile(t, "shaped_grid_positioning"),
1054 loadFromFile(t, "cloud_shaped_grid"),
1055 loadFromFileWithOptions(t, "nested_layout_bug", testCase{testSerialization: true}),
1056 loadFromFile(t, "disconnect_direction_right"),
1057 }
1058
1059 runa(t, tcs)
1060 }
1061
View as plain text