diff --git a/cypress/integration/rendering/erDiagram.spec.js b/cypress/integration/rendering/erDiagram.spec.js index df1fac0cd..faa511626 100644 --- a/cypress/integration/rendering/erDiagram.spec.js +++ b/cypress/integration/rendering/erDiagram.spec.js @@ -10,7 +10,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render an ER diagram with a recursive relationship', () => { @@ -23,7 +22,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render an ER diagram with multiple relationships between the same two entities', () => { @@ -35,7 +33,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render a cyclical ER diagram', () => { @@ -48,7 +45,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render a not-so-simple ER diagram', () => { @@ -66,7 +62,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render multiple ER diagrams', () => { @@ -85,7 +80,6 @@ describe('Entity Relationship Diagram', () => { ], { logLevel: 1 } ); - cy.get('svg'); }); it('should render an ER diagram with blank or empty labels', () => { @@ -98,7 +92,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render an ER diagrams when useMaxWidth is true (default)', () => { @@ -151,7 +144,6 @@ describe('Entity Relationship Diagram', () => { `, { er: { useMaxWidth: false } } ); - cy.get('svg'); }); it('should render entities with and without attributes', () => { @@ -164,7 +156,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities with generic and array attributes', () => { @@ -179,7 +170,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities with length in attributes type', () => { @@ -193,7 +183,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities and attributes with big and small entity names', () => { @@ -209,7 +198,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities with keys', () => { @@ -228,7 +216,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities with comments', () => { @@ -247,7 +234,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities with keys and comments', () => { @@ -267,7 +253,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('should render entities with aliases', () => { @@ -285,7 +270,6 @@ describe('Entity Relationship Diagram', () => { `, { logLevel: 1 } ); - cy.get('svg'); }); it('1433: should render a simple ER diagram with a title', () => { diff --git a/cypress/integration/rendering/errorDiagram.spec.js b/cypress/integration/rendering/errorDiagram.spec.js new file mode 100644 index 000000000..e837565d3 --- /dev/null +++ b/cypress/integration/rendering/errorDiagram.spec.js @@ -0,0 +1,45 @@ +import { imgSnapshotTest } from '../../helpers/util'; + +describe('Error Diagrams', () => { + beforeEach(() => { + cy.on('uncaught:exception', (err) => { + expect(err.message).to.include('Parse error'); + // return false to prevent the error from + // failing this test + return false; + }); + }); + + it('should render a simple ER diagram', () => { + imgSnapshotTest( + ` + error + `, + { logLevel: 1 } + ); + }); + + it('should render error diagram for actual errors', () => { + imgSnapshotTest( + ` + flowchart TD + A[Christmas] --|Get money| B(Go shopping) + `, + { logLevel: 1 } + ); + }); + + it('should render error for wrong ER diagram', () => { + imgSnapshotTest( + ` + erDiagram + ATLAS-ORGANIZATION ||--|{ ATLAS-PROJECTS : "has many" + ATLAS-PROJECTS ||--|{ MONGODB-CLUSTERS : "has many" + ATLAS-PROJECTS ||--|{ ATLAS-TEAMS : "has many" + MONGODB-CLUSTERS ||..|{ + ATLAS-TEAMS ||..|{ + `, + { logLevel: 1 } + ); + }); +}); diff --git a/cypress/integration/rendering/flowchart-elk.spec.js b/cypress/integration/rendering/flowchart-elk.spec.js index 414037651..68d8b3ce5 100644 --- a/cypress/integration/rendering/flowchart-elk.spec.js +++ b/cypress/integration/rendering/flowchart-elk.spec.js @@ -684,4 +684,149 @@ A --> B { titleTopMargin: 0 } ); }); + describe('Markdown strings flowchart-elk (#4220)', () => { + describe('html labels', () => { + it('With styling and classes', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart-elk LR + A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass + id1(Start)-->id2(Stop) + style id1 fill:#f9f,stroke:#333,stroke-width:4px + style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5 + classDef someclass fill:#f96 +`, + { titleTopMargin: 0 } + ); + }); + it('With formatting in a node', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart-elk LR + a{"\`The **cat** in the hat\`"} -- 1o --> b + a -- 2o --> c + a -- 3o --> d + g --2i--> a + d --1i--> a + h --3i -->a + b --> d(The dog in the hog) + c --> d +`, + { titleTopMargin: 0 } + ); + }); + it('New line in node and formatted edge label', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart-elk LR +b("\`The dog in **the** hog.(1) +NL\`") --"\`1o **bold**\`"--> c +`, + { titleTopMargin: 0 } + ); + }); + it('Wrapping long text with a new line', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart-elk LR +b(\`The dog in **the** hog.(1).. a a a a *very long text* about it +Word! + +Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`) --> c + +`, + { titleTopMargin: 0 } + ); + }); + it('Sub graphs and markdown strings', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart-elk LR +subgraph "One" + a("\`The **cat** + in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}} +end +subgraph "\`**Two**\`" + c("\`The **cat** + in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog") +end + +`, + { titleTopMargin: 0 } + ); + }); + }); + + describe('svg text labels', () => { + it('With styling and classes', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart-elk LR + A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass + id1(Start)-->id2(Stop) + style id1 fill:#f9f,stroke:#333,stroke-width:4px + style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5 + classDef someclass fill:#f96 +`, + { titleTopMargin: 0 } + ); + }); + it('With formatting in a node', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart-elk LR + a{"\`The **cat** in the hat\`"} -- 1o --> b + a -- 2o --> c + a -- 3o --> d + g --2i--> a + d --1i--> a + h --3i -->a + b --> d(The dog in the hog) + c --> d +`, + { titleTopMargin: 0 } + ); + }); + it('New line in node and formatted edge label', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart-elk LR +b("\`The dog in **the** hog.(1) +NL\`") --"\`1o **bold**\`"--> c +`, + { titleTopMargin: 0 } + ); + }); + it('Wrapping long text with a new line', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart-elk LR +b("\`The dog in **the** hog.(1).. a a a a *very long text* about it +Word! + +Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c + +`, + { titleTopMargin: 0 } + ); + }); + it('Sub graphs and markdown strings', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart-elk LR +subgraph "One" + a("\`The **cat** + in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}} +end +subgraph "\`**Two**\`" + c("\`The **cat** + in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog") +end + +`, + { titleTopMargin: 0 } + ); + }); + }); + }); }); diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index abdb22265..4513cc87d 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -685,4 +685,149 @@ A ~~~ B { titleTopMargin: 0 } ); }); + describe('Markdown strings flowchart (#4220)', () => { + describe('html labels', () => { + it('With styling and classes', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart LR + A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass + id1(Start)-->id2(Stop) + style id1 fill:#f9f,stroke:#333,stroke-width:4px + style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5 + classDef someclass fill:#f96 +`, + { titleTopMargin: 0 } + ); + }); + it('With formatting in a node', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart LR + a{"\`The **cat** in the hat\`"} -- 1o --> b + a -- 2o --> c + a -- 3o --> d + g --2i--> a + d --1i--> a + h --3i -->a + b --> d(The dog in the hog) + c --> d +`, + { titleTopMargin: 0 } + ); + }); + it('New line in node and formatted edge label', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart LR +b("\`The dog in **the** hog.(1) +NL\`") --"\`1o **bold**\`"--> c +`, + { titleTopMargin: 0 } + ); + }); + it('Wrapping long text with a new line', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart LR +b("\`The dog in **the** hog.(1).. a a a a *very long text* about it +Word! + +Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c + +`, + { titleTopMargin: 0 } + ); + }); + it('Sub graphs and markdown strings', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": true}} }%% +flowchart LR +subgraph "One" + a("\`The **cat** + in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}} +end +subgraph "\`**Two**\`" + c("\`The **cat** + in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog") +end + +`, + { titleTopMargin: 0 } + ); + }); + }); + + describe('svg text labels', () => { + it('With styling and classes', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR + A:::someclass --> B["\`The **cat** in the hat\`"]:::someclass + id1(Start)-->id2(Stop) + style id1 fill:#f9f,stroke:#333,stroke-width:4px + style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5 + classDef someclass fill:#f96 +`, + { titleTopMargin: 0 } + ); + }); + it('With formatting in a node', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR + a{"\`The **cat** in the hat\`"} -- 1o --> b + a -- 2o --> c + a -- 3o --> d + g --2i--> a + d --1i--> a + h --3i -->a + b --> d(The dog in the hog) + c --> d +`, + { titleTopMargin: 0 } + ); + }); + it('New line in node and formatted edge label', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR +b("\`The dog in **the** hog.(1) +NL\`") --"\`1o **bold**\`"--> c +`, + { titleTopMargin: 0 } + ); + }); + it('Wrapping long text with a new line', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR +b("\`The dog in **the** hog.(1).. a a a a *very long text* about it +Word! + +Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c + +`, + { titleTopMargin: 0 } + ); + }); + it('Sub graphs and markdown strings', () => { + imgSnapshotTest( + `%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR +subgraph "One" + a("\`The **cat** + in the hat\`") -- "1o" --> b{{"\`The **dog** in the hog\`"}} +end +subgraph "\`**Two**\`" + c("\`The **cat** + in the hat\`") -- "\`1o **ipa**\`" --> d("The dog in the hog") +end + +`, + { titleTopMargin: 0 } + ); + }); + }); + }); }); diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index c0156eee3..cb65f73b0 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -133,6 +133,24 @@ describe('Gantt diagram', () => { ); }); + it('should default to showing today marker', () => { + // This test only works if the environment thinks today is 1010-10-10 + imgSnapshotTest( + ` + gantt + title Show today marker (vertical line should be visible) + dateFormat YYYY-MM-DD + axisFormat %d + %% Should default to being on + %% todayMarker on + section Section1 + Yesterday: 1010-10-09, 1d + Today: 1010-10-10, 1d + `, + {} + ); + }); + it('should hide today marker', () => { imgSnapshotTest( ` @@ -142,7 +160,8 @@ describe('Gantt diagram', () => { axisFormat %d todayMarker off section Section1 - Today: 1, -1h + Yesterday: 1010-10-09, 1d + Today: 1010-10-10, 1d `, {} ); @@ -157,7 +176,8 @@ describe('Gantt diagram', () => { axisFormat %d todayMarker stroke-width:5px,stroke:#00f,opacity:0.5 section Section1 - Today: 1, -1h + Yesterday: 1010-10-09, 1d + Today: 1010-10-10, 1d `, {} ); @@ -435,4 +455,39 @@ describe('Gantt diagram', () => { { gantt: { topAxis: true } } ); }); + + it('should render when compact is true', () => { + imgSnapshotTest( + ` + --- + displayMode: compact + --- + gantt + title GANTT compact + dateFormat HH:mm:ss + axisFormat %Hh%M + + section DB Clean + Clean: 12:00:00, 10m + Clean: 12:30:00, 12m + Clean: 13:00:00, 8m + Clean: 13:30:00, 9m + Clean: 14:00:00, 13m + Clean: 14:30:00, 10m + Clean: 15:00:00, 11m + + section Sessions + A: 12:00:00, 63m + B: 12:30:00, 12m + C: 13:05:00, 12m + D: 13:06:00, 33m + E: 13:15:00, 55m + F: 13:20:00, 12m + G: 13:32:00, 18m + H: 13:50:00, 20m + I: 14:10:00, 10m + `, + {} + ); + }); }); diff --git a/cypress/integration/rendering/mindmap.spec.ts b/cypress/integration/rendering/mindmap.spec.ts index 4663f6225..94b3f9ca0 100644 --- a/cypress/integration/rendering/mindmap.spec.ts +++ b/cypress/integration/rendering/mindmap.spec.ts @@ -223,5 +223,18 @@ mindmap shouldHaveRoot ); }); + describe('Markdown strings mindmaps (#4220)', () => { + it('Formatted label with linebreak and a wrapping label and emojis', () => { + imgSnapshotTest( + `mindmap + id1[\`**Start** with + a second line 😎\`] + id2[\`The dog in **the** hog... a *very long text* about it +Word!\`] +`, + { titleTopMargin: 0 } + ); + }); + }); /* The end */ }); diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index fccd65004..08a4c0e68 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -51,27 +51,48 @@ font-family: monospace; font-size: 72px; } + /* tspan { + font-size: 6px !important; + } */
-%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% -graph BT -a{The cat in the hat} -- 1o --> b -a -- 2o --> c -a -- 3o --> d -g --2i--> a -d --1i--> a -h --3i -->a -b --> d(The dog in the hog) -c --> d -+ %%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart-elk LR +b(`The dog in **the** hog(2)... a a a a *very long text* about it +Word! +Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. `) +
-flowchart-elk TB - a --> b - a --> c - b --> d - c --> d +flowchart-elk LR +b("The dog in the hog... a very+
long text about it
Word!") +
+flowchart-elk LR +b("The dog in the hog... a very+ > +
long text about it
Word!") +
+mindmap + id1[`**Start2** + second line 😎 with long text that is wrapping to the next line`] + id2[`Child **with bold** text`] + id3[`Children of which some + is using *italic type of* text`] + id4[Child] + id5[`Child + Row + and another + `] ++
+mindmap + id1["`**Start** with + a second line 😎`"] + id2["`The dog in **the** hog... a *very long text* about it +Word!`"]
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% @@ -272,12 +293,14 @@ mindmap mermaid.initialize({ theme: 'forest', startOnLoad: true, - logLevel: 5, + logLevel: 0, flowchart: { // defaultRenderer: 'elk', useMaxWidth: false, - htmlLabels: true, + htmlLabels: false, + // htmlLabels: true, }, + // htmlLabels: true, gantt: { useMaxWidth: false, }, diff --git a/cypress/platform/viewer.js b/cypress/platform/viewer.js index 2e1093519..99533192d 100644 --- a/cypress/platform/viewer.js +++ b/cypress/platform/viewer.js @@ -47,7 +47,6 @@ const contentLoaded = async function () { await mermaid2.registerExternalDiagrams([externalExample]); mermaid2.initialize(graphObj.mermaid); await mermaid2.run(); - markRendered(); } }; @@ -123,7 +122,6 @@ const contentLoadedApi = async function () { bindFunctions(div); } } - markRendered(); }; if (typeof document !== 'undefined') { @@ -135,10 +133,10 @@ if (typeof document !== 'undefined') { function () { if (this.location.href.match('xss.html')) { this.console.log('Using api'); - void contentLoadedApi(); + void contentLoadedApi().finally(markRendered); } else { this.console.log('Not using api'); - void contentLoaded(); + void contentLoaded().finally(markRendered); } }, false diff --git a/demos/error.html b/demos/error.html new file mode 100644 index 000000000..2d6d1b01f --- /dev/null +++ b/demos/error.html @@ -0,0 +1,38 @@ + + + + + +Error | Mermaid Quick Test Page + + + + ++ erDiagram + ATLAS-ORGANIZATION ||--|{ ATLAS-PROJECTS : "has many" + ATLAS-PROJECTS ||--|{ MONGODB-CLUSTERS : "has many" + ATLAS-PROJECTS ||--|{ ATLAS-TEAMS : "has many" +++ erDiagram + ATLAS-ORGANIZATION ||--|{ ATLAS-PROJECTS : "has many" + ATLAS-PROJECTS ||--|{ MONGODB-CLUSTERS : "has many" + ATLAS-PROJECTS ||--|{ ATLAS-TEAMS : "has many" + MONGODB-CLUSTERS ||..|{ + ATLAS-TEAMS ||..|{ ++
++ flowchart TD + A[Christmas] -->|Get money| B(Go shopping) +++ flowchart TD + A[Christmas] --|Get money| B(Go shopping) ++ + + diff --git a/demos/gantt.html b/demos/gantt.html index 613dc8694..88f52ef5c 100644 --- a/demos/gantt.html +++ b/demos/gantt.html @@ -78,7 +78,7 @@ axisFormat %d/%m todayMarker off section Section1 - Today: 1, -01:00, 5min + Today: 1, 08-08-09-01:00, 5min
+ --- + displayMode: compact + --- + gantt + title GANTT compact + dateFormat HH:mm:ss + axisFormat %Hh%M + + section DB Clean + Clean: 12:00:00, 10m + Clean: 12:30:00, 12m + Clean: 13:00:00, 8m + Clean: 13:30:00, 9m + Clean: 14:00:00, 13m + Clean: 14:30:00, 10m + Clean: 15:00:00, 11m + + section Sessions + A: 12:00:00, 63m + B: 12:30:00, 12m + C: 13:05:00, 12m + D: 13:06:00, 33m + E: 13:15:00, 55m + F: 13:20:00, 12m + G: 13:32:00, 18m + H: 13:50:00, 20m + I: 14:10:00, 10m ++