fix empty sequence panic
This commit is contained in:
parent
d0659439af
commit
80d59be429
10 changed files with 348 additions and 0 deletions
|
|
@ -32,6 +32,9 @@ func Layout(ctx context.Context, g *d2graph.Graph, layout func(ctx context.Conte
|
||||||
for len(queue) > 0 {
|
for len(queue) > 0 {
|
||||||
obj := queue[0]
|
obj := queue[0]
|
||||||
queue = queue[1:]
|
queue = queue[1:]
|
||||||
|
if len(obj.ChildrenArray) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if obj.Attributes.Shape.Value != d2target.ShapeSequenceDiagram {
|
if obj.Attributes.Shape.Value != d2target.ShapeSequenceDiagram {
|
||||||
queue = append(queue, obj.ChildrenArray...)
|
queue = append(queue, obj.ChildrenArray...)
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,20 @@ func testRegression(t *testing.T) {
|
||||||
ninety\nnine
|
ninety\nnine
|
||||||
eighty\reight
|
eighty\reight
|
||||||
seventy\r\nseven
|
seventy\r\nseven
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty_sequence",
|
||||||
|
script: `
|
||||||
|
A: hello {
|
||||||
|
shape: sequence_diagram
|
||||||
|
}
|
||||||
|
|
||||||
|
B: goodbye {
|
||||||
|
shape: sequence_diagram
|
||||||
|
}
|
||||||
|
|
||||||
|
A->B
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
e2etests/testdata/regression/dagre_id_with_newline/dagre/board.exp.json
generated
vendored
3
e2etests/testdata/regression/dagre_id_with_newline/dagre/board.exp.json
generated
vendored
|
|
@ -23,6 +23,7 @@
|
||||||
"link": "",
|
"link": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"iconPosition": "",
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"methods": null,
|
"methods": null,
|
||||||
"columns": null,
|
"columns": null,
|
||||||
|
|
@ -62,6 +63,7 @@
|
||||||
"link": "",
|
"link": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"iconPosition": "",
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"methods": null,
|
"methods": null,
|
||||||
"columns": null,
|
"columns": null,
|
||||||
|
|
@ -101,6 +103,7 @@
|
||||||
"link": "",
|
"link": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"iconPosition": "",
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"methods": null,
|
"methods": null,
|
||||||
"columns": null,
|
"columns": null,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ width="784" height="342" viewBox="-100 -100 784 342"><style type="text/css">
|
||||||
stroke-linecap: round;
|
stroke-linecap: round;
|
||||||
stroke-linejoin: round;
|
stroke-linejoin: round;
|
||||||
}
|
}
|
||||||
|
.blend {
|
||||||
|
mix-blend-mode: multiply;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
</style><g id=""ninety\nnine""><g class="shape" ><rect x="0" y="0" width="151" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="75.500000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="75.500000" dy="0.000000">ninety</tspan><tspan x="75.500000" dy="21.000000">nine</tspan></text></g><g id="eighty
eight"><g class="shape" ><rect x="211" y="8" width="151" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="286.500000" y="74.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">eighty
eight</text></g><g id=""seventy
\nseven""><g class="shape" ><rect x="422" y="0" width="162" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="503.000000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="503.000000" dy="0.000000">seventy
</tspan><tspan x="503.000000" dy="21.000000">seven</tspan></text></g><style type="text/css"><![CDATA[
|
</style><g id=""ninety\nnine""><g class="shape" ><rect x="0" y="0" width="151" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="75.500000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="75.500000" dy="0.000000">ninety</tspan><tspan x="75.500000" dy="21.000000">nine</tspan></text></g><g id="eighty
eight"><g class="shape" ><rect x="211" y="8" width="151" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="286.500000" y="74.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">eighty
eight</text></g><g id=""seventy
\nseven""><g class="shape" ><rect x="422" y="0" width="162" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="503.000000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="503.000000" dy="0.000000">seventy
</tspan><tspan x="503.000000" dy="21.000000">seven</tspan></text></g><style type="text/css"><![CDATA[
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 324 KiB |
3
e2etests/testdata/regression/dagre_id_with_newline/elk/board.exp.json
generated
vendored
3
e2etests/testdata/regression/dagre_id_with_newline/elk/board.exp.json
generated
vendored
|
|
@ -23,6 +23,7 @@
|
||||||
"link": "",
|
"link": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"iconPosition": "",
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"methods": null,
|
"methods": null,
|
||||||
"columns": null,
|
"columns": null,
|
||||||
|
|
@ -62,6 +63,7 @@
|
||||||
"link": "",
|
"link": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"iconPosition": "",
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"methods": null,
|
"methods": null,
|
||||||
"columns": null,
|
"columns": null,
|
||||||
|
|
@ -101,6 +103,7 @@
|
||||||
"link": "",
|
"link": "",
|
||||||
"icon": null,
|
"icon": null,
|
||||||
"iconPosition": "",
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
"fields": null,
|
"fields": null,
|
||||||
"methods": null,
|
"methods": null,
|
||||||
"columns": null,
|
"columns": null,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ width="704" height="342" viewBox="-88 -88 704 342"><style type="text/css">
|
||||||
stroke-linecap: round;
|
stroke-linecap: round;
|
||||||
stroke-linejoin: round;
|
stroke-linejoin: round;
|
||||||
}
|
}
|
||||||
|
.blend {
|
||||||
|
mix-blend-mode: multiply;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
</style><g id=""ninety\nnine""><g class="shape" ><rect x="194" y="12" width="151" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="269.500000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="269.500000" dy="0.000000">ninety</tspan><tspan x="269.500000" dy="21.000000">nine</tspan></text></g><g id="eighty
eight"><g class="shape" ><rect x="365" y="20" width="151" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="440.500000" y="86.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">eighty
eight</text></g><g id=""seventy
\nseven""><g class="shape" ><rect x="12" y="12" width="162" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="93.000000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="93.000000" dy="0.000000">seventy
</tspan><tspan x="93.000000" dy="21.000000">seven</tspan></text></g><style type="text/css"><![CDATA[
|
</style><g id=""ninety\nnine""><g class="shape" ><rect x="194" y="12" width="151" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="269.500000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="269.500000" dy="0.000000">ninety</tspan><tspan x="269.500000" dy="21.000000">nine</tspan></text></g><g id="eighty
eight"><g class="shape" ><rect x="365" y="20" width="151" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="440.500000" y="86.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">eighty
eight</text></g><g id=""seventy
\nseven""><g class="shape" ><rect x="12" y="12" width="162" height="142" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="93.000000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25"><tspan x="93.000000" dy="0.000000">seventy
</tspan><tspan x="93.000000" dy="21.000000">seven</tspan></text></g><style type="text/css"><![CDATA[
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 324 KiB |
135
e2etests/testdata/regression/empty_sequence/dagre/board.exp.json
generated
vendored
Normal file
135
e2etests/testdata/regression/empty_sequence/dagre/board.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"shapes": [
|
||||||
|
{
|
||||||
|
"id": "A",
|
||||||
|
"type": "sequence_diagram",
|
||||||
|
"pos": {
|
||||||
|
"x": 13,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"width": 140,
|
||||||
|
"height": 126,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 0,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#FFFFFF",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "hello",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": true,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 40,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "B",
|
||||||
|
"type": "sequence_diagram",
|
||||||
|
"pos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 226
|
||||||
|
},
|
||||||
|
"width": 166,
|
||||||
|
"height": 126,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 0,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#FFFFFF",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "goodbye",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": true,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 66,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": [
|
||||||
|
{
|
||||||
|
"id": "(A -> B)[0]",
|
||||||
|
"src": "A",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "B",
|
||||||
|
"dstArrow": "triangle",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 83,
|
||||||
|
"y": 126
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 83,
|
||||||
|
"y": 166
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 83,
|
||||||
|
"y": 186
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 83,
|
||||||
|
"y": 226
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isCurve": true,
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
e2etests/testdata/regression/empty_sequence/dagre/sketch.exp.svg
vendored
Normal file
28
e2etests/testdata/regression/empty_sequence/dagre/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 324 KiB |
126
e2etests/testdata/regression/empty_sequence/elk/board.exp.json
generated
vendored
Normal file
126
e2etests/testdata/regression/empty_sequence/elk/board.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"shapes": [
|
||||||
|
{
|
||||||
|
"id": "A",
|
||||||
|
"type": "sequence_diagram",
|
||||||
|
"pos": {
|
||||||
|
"x": 25,
|
||||||
|
"y": 12
|
||||||
|
},
|
||||||
|
"width": 140,
|
||||||
|
"height": 126,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 0,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#FFFFFF",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "hello",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": true,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 40,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "B",
|
||||||
|
"type": "sequence_diagram",
|
||||||
|
"pos": {
|
||||||
|
"x": 12,
|
||||||
|
"y": 238
|
||||||
|
},
|
||||||
|
"width": 166,
|
||||||
|
"height": 126,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 0,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#FFFFFF",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "goodbye",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": true,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 66,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": [
|
||||||
|
{
|
||||||
|
"id": "(A -> B)[0]",
|
||||||
|
"src": "A",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "B",
|
||||||
|
"dstArrow": "triangle",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 95,
|
||||||
|
"y": 138
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 95,
|
||||||
|
"y": 238
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
e2etests/testdata/regression/empty_sequence/elk/sketch.exp.svg
vendored
Normal file
28
e2etests/testdata/regression/empty_sequence/elk/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 324 KiB |
Loading…
Reference in a new issue