Skip to content

Commit e842cf5

Browse files
Merge pull request #18 from Mermaid-Chart/MC-2265/fix-failing-e2e-shapes-test
MC-2265: Fix all failing E2E tests in Mermaid Alana
2 parents 6db6bec + 35fea81 commit e842cf5

File tree

5 files changed

+57
-17
lines changed

5 files changed

+57
-17
lines changed

.changeset/fresh-bears-doubt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix: Intersection calculations for tilted cylinder/DAS when using handdrawn look. Some random seeds could cause the calculations to break.

cypress/integration/rendering/stateDiagram-v2.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ stateDiagram-v2
460460
[*] --> State1
461461
State1 --> [*]
462462
`,
463-
{ state: { useMaxWidth: true } }
463+
{ state: { useMaxWidth: true }, look: 'classic' }
464464
);
465465
cy.get('svg').should((svg) => {
466466
expect(svg).to.have.attr('width', '100%');
@@ -482,7 +482,7 @@ stateDiagram-v2
482482
[*] --> State1
483483
State1 --> [*]
484484
`,
485-
{ state: { useMaxWidth: false } }
485+
{ state: { useMaxWidth: false }, look: 'classic' }
486486
);
487487
cy.get('svg').should((svg) => {
488488
// const height = parseFloat(svg.attr('height'));

cypress/integration/rendering/stateDiagram.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ describe('State diagram', () => {
338338
[*] --> State1
339339
State1 --> [*]
340340
`,
341-
{ state: { useMaxWidth: true } }
341+
{ state: { useMaxWidth: true }, look: 'classic', theme: 'default' }
342342
);
343343
cy.get('svg').should((svg) => {
344344
expect(svg).to.have.attr('width', '100%');
@@ -361,7 +361,7 @@ describe('State diagram', () => {
361361
[*] --> State1
362362
State1 --> [*]
363363
`,
364-
{ state: { useMaxWidth: false } }
364+
{ state: { useMaxWidth: false }, look: 'classic', theme: 'default' }
365365
);
366366
cy.get('svg').should((svg) => {
367367
// const height = parseFloat(svg.attr('height'));

cypress/platform/knsv2.html

+47-12
Original file line numberDiff line numberDiff line change
@@ -91,70 +91,105 @@
9191

9292
<body>
9393
<pre id="diagram4" class="mermaid">
94+
---
95+
config:
96+
look: handDrawn
97+
theme: default
98+
---
99+
flowchart LR
100+
n00@{ shape: triangle, label: 'This is a label for triangle shape' }
101+
n11@{ shape: sloped-rectangle, label: 'This is a label for sloped-rectangle shape' }
102+
n22@{ shape: horizontal-cylinder, label: 'This is a label for horizontal-cylinder shape' }
103+
n33@{ shape: flipped-triangle, label: 'This is a label for flipped-triangle shape' }
104+
n44@{ shape: hourglass, label: 'This is a label for hourglass shape' }
105+
n00 --> n11
106+
n00 --> n22
107+
n00 --> n33
108+
n00 --> n44
109+
n11 --> n22
110+
n11 --> n33
111+
n11 --> n44
112+
n22 --> n33
113+
n22 --> n44
114+
n33 --> n44
115+
</pre>
116+
<pre id="diagram4" class="mermaid">
117+
---
118+
config:
119+
look: handDrawn
120+
theme: default
121+
---
122+
flowchart LR
123+
n22@{ shape: h-cyl }
124+
n00 --> n11
125+
n00 --> n22
126+
n11 --> n22
127+
</pre>
128+
<pre id="diagram4" class="mermaid2">
94129
flowchart LR
95130
nA[Default] --> A@{ icon: 'fa:bell', form: 'rounded' }
96131

97132
</pre>
98-
<pre id="diagram4" class="mermaid">
133+
<pre id="diagram4" class="mermaid2">
99134
flowchart LR
100135
nA[Style] --> A@{ icon: 'fa:bell', form: 'rounded' }
101136
style A fill:#f9f,stroke:#333,stroke-width:4px
102137
</pre>
103-
<pre id="diagram4" class="mermaid">
138+
<pre id="diagram4" class="mermaid2">
104139
flowchart LR
105140
nA[Class] --> A@{ icon: 'fa:bell', form: 'rounded' }
106141
A:::AClass
107142
classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
108143
</pre>
109-
<pre id="diagram4" class="mermaid">
144+
<pre id="diagram4" class="mermaid2">
110145
flowchart LR
111146
nA[Class] --> A@{ icon: 'logos:aws', form: 'rounded' }
112147

113148
</pre>
114-
<pre id="diagram4" class="mermaid">
149+
<pre id="diagram4" class="mermaid2">
115150
flowchart LR
116151
nA[Default] --> A@{ icon: 'fa:bell', form: 'square' }
117152

118153
</pre>
119-
<pre id="diagram4" class="mermaid">
154+
<pre id="diagram4" class="mermaid2">
120155
flowchart LR
121156
nA[Style] --> A@{ icon: 'fa:bell', form: 'square' }
122157
style A fill:#f9f,stroke:#333,stroke-width:4px
123158
</pre>
124-
<pre id="diagram4" class="mermaid">
159+
<pre id="diagram4" class="mermaid2">
125160
flowchart LR
126161
nA[Class] --> A@{ icon: 'fa:bell', form: 'square' }
127162
A:::AClass
128163
classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
129164
</pre>
130-
<pre id="diagram4" class="mermaid">
165+
<pre id="diagram4" class="mermaid2">
131166
flowchart LR
132167
nA[Class] --> A@{ icon: 'logos:aws', form: 'square' }
133168

134169
</pre>
135-
<pre id="diagram4" class="mermaid">
170+
<pre id="diagram4" class="mermaid2">
136171
flowchart LR
137172
nA[Default] --> A@{ icon: 'fa:bell', form: 'circle' }
138173

139174
</pre>
140-
<pre id="diagram4" class="mermaid">
175+
<pre id="diagram4" class="mermaid2">
141176
flowchart LR
142177
nA[Style] --> A@{ icon: 'fa:bell', form: 'circle' }
143178
style A fill:#f9f,stroke:#333,stroke-width:4px
144179
</pre>
145-
<pre id="diagram4" class="mermaid">
180+
<pre id="diagram4" class="mermaid2">
146181
flowchart LR
147182
nA[Class] --> A@{ icon: 'fa:bell', form: 'circle' }
148183
A:::AClass
149184
classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
150185
</pre>
151-
<pre id="diagram4" class="mermaid">
186+
<pre id="diagram4" class="mermaid2">
152187
flowchart LR
153188
nA[Class] --> A@{ icon: 'logos:aws', form: 'circle' }
154189
A:::AClass
155190
classDef AClass fill:#f9f,stroke:#333,stroke-width:4px
156191
</pre>
157-
<pre id="diagram4" class="mermaid">
192+
<pre id="diagram4" class="mermaid2">
158193
flowchart LR
159194
nA[Style] --> A@{ icon: 'logos:aws', form: 'circle' }
160195
style A fill:#f9f,stroke:#333,stroke-width:4px

packages/mermaid/src/rendering-util/rendering-elements/shapes/tiltedCylinder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export async function tiltedCylinder<T extends SVGGraphicsElement>(
141141
) {
142142
let x = rx * rx * (1 - (y * y) / (ry * ry));
143143
if (x != 0) {
144-
x = Math.sqrt(x);
144+
x = Math.sqrt(Math.abs(x));
145145
}
146146
x = rx - x;
147147
if (point.x - (node.x ?? 0) > 0) {

0 commit comments

Comments
 (0)