5.2 KB171 lines
Blame
1import { renderGraph, verifyScreenshot } from '../../helpers/util.ts';
2describe('Configuration', () => {
3 describe('arrowMarkerAbsolute', () => {
4 it('should handle default value false of arrowMarkerAbsolute', () => {
5 renderGraph(
6 `graph TD
7 A[Christmas] -->|Get money| B(Go shopping)
8 B --> C{Let me think}
9 C -->|One| D[Laptop]
10 C -->|Two| E[iPhone]
11 C -->|Three| F[fa:fa-car Car]
12 `,
13 {}
14 );
15
16 // Check the marker-end property to make sure it is properly set to
17 // start with #
18 cy.get('.edgePaths').within(() => {
19 cy.get('path')
20 .first()
21 .should('have.attr', 'marker-end')
22 .should('exist')
23 .and('include', 'url(#');
24 });
25 });
26 it('should handle default value false of arrowMarkerAbsolute', () => {
27 renderGraph(
28 `graph TD
29 A[Christmas] -->|Get money| B(Go shopping)
30 B --> C{Let me think}
31 C -->|One| D[Laptop]
32 C -->|Two| E[iPhone]
33 C -->|Three| F[fa:fa-car Car]
34 `,
35 {}
36 );
37
38 // Check the marker-end property to make sure it is properly set to
39 // start with #
40 cy.get('.edgePaths').within(() => {
41 cy.get('path')
42 .first()
43 .should('have.attr', 'marker-end')
44 .should('exist')
45 .and('include', 'url(#');
46 });
47 });
48 it('should handle arrowMarkerAbsolute explicitly set to false', () => {
49 renderGraph(
50 `graph TD
51 A[Christmas] -->|Get money| B(Go shopping)
52 B --> C{Let me think}
53 C -->|One| D[Laptop]
54 C -->|Two| E[iPhone]
55 C -->|Three| F[fa:fa-car Car]
56 `,
57 {
58 arrowMarkerAbsolute: false,
59 }
60 );
61
62 // Check the marker-end property to make sure it is properly set to
63 // start with #
64 cy.get('.edgePaths').within(() => {
65 cy.get('path')
66 .first()
67 .should('have.attr', 'marker-end')
68 .should('exist')
69 .and('include', 'url(#');
70 });
71 });
72 // This has been broken for a long time, but something about the Cypress environment was
73 // rewriting the URL to be relative, causing the test to incorrectly pass.
74 it.skip('should handle arrowMarkerAbsolute explicitly set to "false" as false', () => {
75 renderGraph(
76 `graph TD
77 A[Christmas] -->|Get money| B(Go shopping)
78 B --> C{Let me think}
79 C -->|One| D[Laptop]
80 C -->|Two| E[iPhone]
81 C -->|Three| F[fa:fa-car Car]
82 `,
83 {
84 arrowMarkerAbsolute: 'false',
85 }
86 );
87
88 // Check the marker-end property to make sure it is properly set to
89 // start with #
90 cy.get('.edgePaths').within(() => {
91 cy.get('path')
92 .first()
93 .should('have.attr', 'marker-end')
94 .should('exist')
95 .and('include', 'url(#');
96 });
97 });
98 it('should handle arrowMarkerAbsolute set to true', () => {
99 renderGraph(
100 `flowchart TD
101 A[Christmas] -->|Get money| B(Go shopping)
102 B --> C{Let me think}
103 C -->|One| D[Laptop]
104 C -->|Two| E[iPhone]
105 C -->|Three| F[fa:fa-car Car]
106 `,
107 {
108 arrowMarkerAbsolute: true,
109 }
110 );
111
112 cy.get('.edgePaths').within(() => {
113 cy.get('path')
114 .first()
115 .should('have.attr', 'marker-end')
116 .and('include', 'url(http://localhost');
117 });
118 });
119 it('should not taint the initial configuration when using multiple directives', () => {
120 const url = '/regression/issue-1874.html';
121 cy.visit(url);
122 cy.window().should('have.property', 'rendered', true);
123 verifyScreenshot(
124 'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
125 );
126 });
127 });
128
129 describe('suppressErrorRendering', () => {
130 beforeEach(() => {
131 cy.on('uncaught:exception', (err, runnable) => {
132 return !err.message.includes('Parse error on line');
133 });
134 });
135
136 it('should not render error diagram if suppressErrorRendering is set', () => {
137 const url = '/suppressError.html?suppressErrorRendering=true';
138 cy.visit(url);
139 cy.window().should('have.property', 'rendered', true);
140 cy.get('#test')
141 .find('svg')
142 .should(($svg) => {
143 // all failing diagrams should not appear!
144 expect($svg).to.have.length(2);
145 // none of the diagrams should be error diagrams
146 expect($svg).to.not.contain('Syntax error');
147 });
148 verifyScreenshot(
149 'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set'
150 );
151 });
152
153 it('should render error diagram if suppressErrorRendering is not set', () => {
154 const url = '/suppressError.html';
155 cy.visit(url);
156 cy.window().should('have.property', 'rendered', true);
157 cy.get('#test')
158 .find('svg')
159 .should(($svg) => {
160 // all five diagrams should be rendered
161 expect($svg).to.have.length(5);
162 // some of the diagrams should be error diagrams
163 expect($svg).to.contain('Syntax error');
164 });
165 verifyScreenshot(
166 'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set'
167 );
168 });
169 });
170});
171