From 389f4cb9d330226c04086464124cd2079a57f83a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 13:21:29 -0800 Subject: [PATCH 1/3] failing test --- d2compiler/compile_test.go | 27 + e2etests/regression_test.go | 14 + .../dagre/board.exp.json | 368 +++++++++++ .../dagre/sketch.exp.svg | 52 ++ .../elk/board.exp.json | 368 +++++++++++ .../elk/sketch.exp.svg | 52 ++ .../TestCompile/sequence-timestamp.exp.json | 608 ++++++++++++++++++ 7 files changed, 1489 insertions(+) create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json create mode 100644 e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg create mode 100644 testdata/d2compiler/TestCompile/sequence-timestamp.exp.json diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 3b6f2ac6a..8a8bb33c3 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1774,6 +1774,33 @@ dst.id <-> src.dst_id assert.String(t, "sequence_diagram", g.Objects[0].Attributes.Shape.Value) }, }, + { + name: "sequence-timestamp", + + text: `shape: sequence_diagram +a +b + +"04:20,11:20": { + "loop through each table": { + a."start_time = datetime.datetime.now" + a -> b + } +} +`, + assertions: func(t *testing.T, g *d2graph.Graph) { + tassert.Equal(t, 1, len(g.Edges)) + tassert.Equal(t, 5, len(g.Objects)) + tassert.Equal(t, "a", g.Objects[0].ID) + tassert.Equal(t, "b", g.Objects[1].ID) + tassert.Equal(t, `"04:20,11:20"`, g.Objects[2].ID) + tassert.Equal(t, `loop through each table`, g.Objects[3].ID) + tassert.Equal(t, 1, len(g.Objects[0].ChildrenArray)) + tassert.Equal(t, 0, len(g.Objects[1].ChildrenArray)) + tassert.Equal(t, 1, len(g.Objects[2].ChildrenArray)) + tassert.True(t, g.Edges[0].ContainedBy(g.Objects[3])) + }, + }, { name: "root_sequence", diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 17a7e6e18..8b977c988 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -515,6 +515,20 @@ s: { s.n -> y.r: {style.stroke-width: 8; style.stroke: red} y.r -> a.g.i: 1\n2\n3\n4 +`, + }, + { + name: "sequence-note-escape-group", + script: `shape: sequence_diagram +a +b + +"04:20,11:20": { + "loop through each table": { + a."start_time = datetime.datetime.now" + a -> b + } +} `, }, } diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json new file mode 100644 index 000000000..4d4584b8a --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json @@ -0,0 +1,368 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "rectangle", + "pos": { + "x": 12, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 7, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "rectangle", + "pos": { + "x": 197, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\"", + "type": "rectangle", + "pos": { + "x": 337, + "y": 52 + }, + "width": 121, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "04:20,11:20", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\".loop through each table", + "type": "rectangle", + "pos": { + "x": 391, + "y": 9223372036854775807 + }, + "width": 12, + "height": 30, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 160, + "labelHeight": 21, + "zIndex": 2, + "level": 2 + }, + { + "id": "a.\"start_time = datetime.datetime.now\"", + "type": "page", + "pos": { + "x": -82, + "y": 188 + }, + "width": 289, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "start_time = datetime.datetime.now", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 244, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 5, + "level": 2 + } + ], + "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": 62, + "y": 324 + }, + { + "x": 247, + "y": 324 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(a -- )[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "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": 62, + "y": 118 + }, + { + "x": 62, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "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": 247, + "y": 118 + }, + { + "x": 247, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(\"04:20,11:20\" -- )[0]", + "src": "\"04:20,11:20\"", + "srcArrow": "none", + "srcLabel": "", + "dst": "\"04:20,11:20\"-lifeline-end-548673492", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "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": 397.5, + "y": 118 + }, + { + "x": 397.5, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg new file mode 100644 index 000000000..ce6398a9f --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg @@ -0,0 +1,52 @@ + +ab04:20,11:20 start_time = datetime.datetime.now + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json b/e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json new file mode 100644 index 000000000..4d4584b8a --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/elk/board.exp.json @@ -0,0 +1,368 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "rectangle", + "pos": { + "x": 12, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 7, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "rectangle", + "pos": { + "x": 197, + "y": 52 + }, + "width": 100, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\"", + "type": "rectangle", + "pos": { + "x": 337, + "y": 52 + }, + "width": 121, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "04:20,11:20", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "\"04:20,11:20\".loop through each table", + "type": "rectangle", + "pos": { + "x": 391, + "y": 9223372036854775807 + }, + "width": 12, + "height": 30, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 160, + "labelHeight": 21, + "zIndex": 2, + "level": 2 + }, + { + "id": "a.\"start_time = datetime.datetime.now\"", + "type": "page", + "pos": { + "x": -82, + "y": 188 + }, + "width": 289, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "start_time = datetime.datetime.now", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 244, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 5, + "level": 2 + } + ], + "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": 62, + "y": 324 + }, + { + "x": 247, + "y": 324 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(a -- )[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "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": 62, + "y": 118 + }, + { + "x": 62, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "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": 247, + "y": 118 + }, + { + "x": 247, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(\"04:20,11:20\" -- )[0]", + "src": "\"04:20,11:20\"", + "srcArrow": "none", + "srcLabel": "", + "dst": "\"04:20,11:20\"-lifeline-end-548673492", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "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": 397.5, + "y": 118 + }, + { + "x": 397.5, + "y": 394 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg new file mode 100644 index 000000000..ce6398a9f --- /dev/null +++ b/e2etests/testdata/regression/sequence-note-escape-group/elk/sketch.exp.svg @@ -0,0 +1,52 @@ + +ab04:20,11:20 start_time = datetime.datetime.now + + + \ No newline at end of file diff --git a/testdata/d2compiler/TestCompile/sequence-timestamp.exp.json b/testdata/d2compiler/TestCompile/sequence-timestamp.exp.json new file mode 100644 index 000000000..c41a4f00b --- /dev/null +++ b/testdata/d2compiler/TestCompile/sequence-timestamp.exp.json @@ -0,0 +1,608 @@ +{ + "graph": { + "name": "", + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-10:0:137", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-0:23:23", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-0:5:5", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:0:0-0:5:5", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,0:7:7-0:23:23", + "value": [ + { + "string": "sequence_diagram", + "raw_string": "sequence_diagram" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-9:1:136", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "value": [ + { + "string": "04:20,11:20", + "raw_string": "04:20,11:20" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:15:44-9:0:135", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-8:3:134", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "value": [ + { + "string": "loop through each table", + "raw_string": "loop through each table" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:29:75-8:2:133", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:5:82", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:6:83-6:42:119", + "value": [ + { + "string": "start_time = datetime.datetime.now", + "raw_string": "start_time = datetime.datetime.now" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:10:130", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:10:130", + "src": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:6:126", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:5:125", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:8:128-7:10:130", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:9:129-7:10:130", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "sequence_diagram" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "minWidth": 0, + "minHeight": 0, + "label_dimensions": { + "width": 0, + "height": 0 + }, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "a", + "id_val": "a", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,1:0:24-1:1:25", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:5:82", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:6:83-6:42:119", + "value": [ + { + "string": "start_time = datetime.datetime.now", + "raw_string": "start_time = datetime.datetime.now" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:6:126", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:4:124-7:5:125", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "a" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "b", + "id_val": "b", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,2:0:26-2:1:27", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:8:128-7:10:130", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,7:9:129-7:10:130", + "value": [ + { + "string": "b", + "raw_string": "b" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "b" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "\"04:20,11:20\"", + "id_val": "04:20,11:20", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,4:0:29-4:13:42", + "value": [ + { + "string": "04:20,11:20", + "raw_string": "04:20,11:20" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "04:20,11:20" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "loop through each table", + "id_val": "loop through each table", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "path": [ + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,5:2:48-5:27:73", + "value": [ + { + "string": "loop through each table", + "raw_string": "loop through each table" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "loop through each table" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + }, + { + "id": "\"start_time = datetime.datetime.now\"", + "id_val": "start_time = datetime.datetime.now", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:42:119", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:4:81-6:5:82", + "value": [ + { + "string": "a", + "raw_string": "a" + } + ] + } + }, + { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/sequence-timestamp.d2,6:6:83-6:42:119", + "value": [ + { + "string": "start_time = datetime.datetime.now", + "raw_string": "start_time = datetime.datetime.now" + } + ] + } + } + ] + }, + "key_path_index": 1, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "start_time = datetime.datetime.now" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": null +} From f0eba7dda775d3756d910d2ad01a1a76c8b99bc7 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 22 Feb 2023 16:07:24 -0800 Subject: [PATCH 2/3] d2compiler: Fix sequence-timestamp test --- d2compiler/compile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 3d4a55a7f..8cc6452a7 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -427,7 +427,7 @@ func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { edge.Attributes.Label.MapKey = e.LastPrimaryKey() for _, er := range e.References { scopeObjIDA := d2ir.IDA(er.Context.ScopeMap) - scopeObj, _ := edge.Src.Graph.Root.HasChildIDVal(d2graphIDA(scopeObjIDA)) + scopeObj, _ := edge.Src.Graph.Root.HasChildIDVal(scopeObjIDA) edge.References = append(edge.References, d2graph.EdgeReference{ Edge: er.Context.Edge, MapKey: er.Context.Key, From a733c6ec2fc2b687ca98255bb7effb4ad608d65d Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 22 Feb 2023 16:22:28 -0800 Subject: [PATCH 3/3] regen test --- .../dagre/board.exp.json | 146 +++++++----------- .../dagre/sketch.exp.svg | 9 +- .../elk/board.exp.json | 146 +++++++----------- .../elk/sketch.exp.svg | 9 +- 4 files changed, 120 insertions(+), 190 deletions(-) diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json index 4d4584b8a..1bb1391e5 100644 --- a/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/board.exp.json @@ -88,52 +88,11 @@ "id": "\"04:20,11:20\"", "type": "rectangle", "pos": { - "x": 337, - "y": 52 + "x": -134, + "y": 161 }, - "width": 121, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "04:20,11:20", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 76, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "\"04:20,11:20\".loop through each table", - "type": "rectangle", - "pos": { - "x": 391, - "y": 9223372036854775807 - }, - "width": 12, - "height": 30, + "width": 433, + "height": 248, "opacity": 1, "strokeDash": 0, "strokeWidth": 0, @@ -152,7 +111,49 @@ "fields": null, "methods": null, "columns": null, - "label": "", + "label": "04:20,11:20", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelFill": "#DEE1EB", + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, + "level": 1 + }, + { + "id": "\"04:20,11:20\".loop through each table", + "type": "rectangle", + "pos": { + "x": -122, + "y": 202 + }, + "width": 409, + "height": 195, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": true, + "fields": null, + "methods": null, + "columns": null, + "label": "loop through each table", "fontSize": 16, "fontFamily": "DEFAULT", "language": "", @@ -162,7 +163,9 @@ "underline": false, "labelWidth": 160, "labelHeight": 21, - "zIndex": 2, + "labelFill": "#DEE1EB", + "labelPosition": "INSIDE_TOP_LEFT", + "zIndex": 3, "level": 2 }, { @@ -170,7 +173,7 @@ "type": "page", "pos": { "x": -82, - "y": 188 + "y": 246 }, "width": 289, "height": 66, @@ -235,11 +238,11 @@ "route": [ { "x": 62, - "y": 324 + "y": 382 }, { "x": 247, - "y": 324 + "y": 382 } ], "animated": false, @@ -278,7 +281,7 @@ }, { "x": 62, - "y": 394 + "y": 452 } ], "animated": false, @@ -317,46 +320,7 @@ }, { "x": 247, - "y": 394 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 - }, - { - "id": "(\"04:20,11:20\" -- )[0]", - "src": "\"04:20,11:20\"", - "srcArrow": "none", - "srcLabel": "", - "dst": "\"04:20,11:20\"-lifeline-end-548673492", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "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": 397.5, - "y": 118 - }, - { - "x": 397.5, - "y": 394 + "y": 452 } ], "animated": false, diff --git a/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg index ce6398a9f..a8fe48516 100644 --- a/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/sequence-note-escape-group/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="744" height="544" viewBox="-184 -50 744 544">