From 2a9e56439ea07419d59ffe3fe9e7a57921bb063d Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 4 Oct 2022 16:37:37 +0800 Subject: [PATCH 01/11] fix(tests): Interaction test - Security loose. --- cypress/integration/other/interaction.spec.js | 206 ++++++------------ cypress/platform/click_security_loose.html | 26 +-- 2 files changed, 77 insertions(+), 155 deletions(-) diff --git a/cypress/integration/other/interaction.spec.js b/cypress/integration/other/interaction.spec.js index b253d0389b..76c63c4ad3 100644 --- a/cypress/integration/other/interaction.spec.js +++ b/cypress/integration/other/interaction.spec.js @@ -1,266 +1,188 @@ describe('Interaction', () => { - describe('Interaction - security level loose', () => { - it('Graph: should handle a click on a node with a bound function', () => { + describe('Security level loose', () => { + beforeEach(() => { const url = 'http://localhost:9000/click_security_loose.html'; cy.viewport(1440, 1024); cy.visit(url); - cy.get('body').find('g#flowchart-Function-4').click(); + }); + it('Graph: should handle a click on a node with a bound function', () => { + cy.contains('FunctionTest1').parents('.node').click(); cy.get('.created-by-click').should('have.text', 'Clicked By Flow'); }); - it('Graph: should handle a click on a node with a bound function with args', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('g#flowchart-FunctionArg-28').click(); + it('Graph: should handle a click on a node with a bound function with args', () => { + cy.contains('FunctionArgTest2').parents('.node').click(); cy.get('.created-by-click-2').should('have.text', 'Clicked By Flow: ARGUMENT'); }); - it('Flowchart: should handle a click on a node with a bound function where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('g[id="flowchart-FunctionArg-34"]').click(); + it('Flowchart: should handle a click on a node with a bound function where the node starts with a number', () => { + cy.contains('2FunctionArg').parents('.node').click(); cy.get('.created-by-click-2').should('have.text', 'Clicked By Flow: ARGUMENT'); }); - it('Graph: should handle a click on a node with a bound url', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('#flowchart-URL-5').click(); - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + it('Graph: should handle a click on a node with a bound url', () => { + // When there is a URL, cy.contains selects the a tag instead of the span. The .node is a child of a, so we have to use find instead of parent. + cy.contains('URLTest1').find('.node').click(); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); - it('Graph: should handle a click on a node with a bound url where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('g[id="flowchart-2URL-11"]').click(); - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + it('Graph: should handle a click on a node with a bound url where the node starts with a number', () => { + cy.contains('2URL').find('.node').click(); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); it('Flowchart-v2: should handle a click on a node with a bound function', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('g#flowchart-Function-16').click(); - + cy.contains('FunctionTest2').parents('.node').click(); cy.get('.created-by-click').should('have.text', 'Clicked By Flow'); }); - it('Flowchart-v2: should handle a click on a node with a bound function where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('g[id="flowchart-1Function-22"]').click(); + it('Flowchart-v2: should handle a click on a node with a bound function where the node starts with a number', () => { + cy.contains('10Function').parents('.node').click(); cy.get('.created-by-click').should('have.text', 'Clicked By Flow'); }); - it('Flowchart-v2: should handle a click on a node with a bound url', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('#flowchart-URL-17').click(); - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + it('Flowchart-v2: should handle a click on a node with a bound url', () => { + cy.contains('URLTest2').find('.node').click(); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); - it('Flowchart-v2: should handle a click on a node with a bound url where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); - cy.get('body').find('g[id="flowchart-2URL-23"]').click(); - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + it('Flowchart-v2: should handle a click on a node with a bound url where the node starts with a number', () => { + // cy.contains('').click(); + cy.contains('20URL').find('.node').click(); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); it('should handle a click on a task with a bound URL clicking on the rect', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('rect#cl1').click({ force: true }); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); + it('should handle a click on a task with a bound URL clicking on the text', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('text#cl1-text').click({ force: true }); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); + it('should handle a click on a task with a bound function without args', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('rect#cl2').click({ force: true }); - cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant cl2'); }); + it('should handle a click on a task with a bound function with args', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('rect#cl3').click({ force: true }); - cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant test1 test2 test3'); }); it('should handle a click on a task with a bound function without args', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('text#cl2-text').click({ force: true }); - cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant cl2'); }); + it('should handle a click on a task with a bound function with args ', () => { - const url = 'http://localhost:9000/click_security_loose.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('text#cl3-text').click({ force: true }); - cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant test1 test2 test3'); }); }); describe('Interaction - security level tight', () => { - it('should handle a click on a node without a bound function', () => { + beforeEach(() => { const url = 'http://localhost:9000/click_security_strict.html'; cy.viewport(1440, 1024); cy.visit(url); + }); + it('should handle a click on a node without a bound function', () => { cy.get('body').find('g#flowchart-Function-4').click(); - cy.get('.created-by-click').should('not.exist'); - // cy.get('.created-by-click').should('not.have.text', 'Clicked By Flow'); }); + it('should handle a click on a node with a bound function where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('g[id="flowchart-1Function-10"]').click(); - - // cy.get('.created-by-click').should('not.have.text', 'Clicked By Flow'); cy.get('.created-by-click').should('not.exist'); }); + it('should handle a click on a node with a bound url', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('g#flowchart-URL-5').click(); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); + it('should handle a click on a node with a bound url where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('g[id="flowchart-2URL-11"]').click(); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); it('should handle a click on a task with a bound URL clicking on the rect', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('rect#cl1').click({ force: true }); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); + it('should handle a click on a task with a bound URL clicking on the text', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('text#cl1-text').click({ force: true }); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); + it('should handle a click on a task with a bound function', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('rect#cl2').click({ force: true }); - - // cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant cl2'); cy.get('.created-by-gant-click').should('not.exist'); }); + it('should handle a click on a task with a bound function', () => { - const url = 'http://localhost:9000/click_security_strict.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('text#cl2-text').click({ force: true }); - - // cy.get('.created-by-gant-click').should('not.have.text', 'Clicked By Gant cl2'); cy.get('.created-by-gant-click').should('not.exist'); }); }); describe('Interaction - security level other, missspelling', () => { - it('should handle a click on a node with a bound function', () => { + beforeEach(() => { const url = 'http://localhost:9000/click_security_other.html'; cy.viewport(1440, 1024); cy.visit(url); - cy.get('body').find('g#flowchart-Function-4').click(); + }); - // cy.get('.created-by-click').should('not.have.text', 'Clicked By Flow'); + it('should handle a click on a node with a bound function', () => { + cy.get('body').find('g#flowchart-Function-4').click(); cy.get('.created-by-click').should('not.exist'); }); + it('should handle a click on a node with a bound function where the node starts with a number', () => { - const url = 'http://localhost:9000/click_security_other.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('g[id="flowchart-1Function-10"]').click(); - cy.get('.created-by-click').should('not.exist'); cy.get('.created-by-click').should('not.exist'); }); + it('should handle a click on a node with a bound url', () => { - const url = 'http://localhost:9000/click_security_other.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('g#flowchart-URL-5').click(); - - cy.location().should((location) => { - expect(location.href).to.eq('http://localhost:9000/webpackUsage.html'); + cy.location().should(({ href }) => { + expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); it('should handle a click on a task with a bound function', () => { - const url = 'http://localhost:9000/click_security_other.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('rect#cl2').click({ force: true }); - cy.get('.created-by-gant-click').should('not.exist'); }); + it('should handle a click on a task with a bound function', () => { - const url = 'http://localhost:9000/click_security_other.html'; - cy.viewport(1440, 1024); - cy.visit(url); cy.get('body').find('text#cl2-text').click({ force: true }); - cy.get('.created-by-gant-click').should('not.exist'); }); }); diff --git a/cypress/platform/click_security_loose.html b/cypress/platform/click_security_loose.html index 6c77e90af0..ed9fcaaa80 100644 --- a/cypress/platform/click_security_loose.html +++ b/cypress/platform/click_security_loose.html @@ -15,9 +15,9 @@
     graph TB
-      Function-->URL
-      click Function clickByFlow "Add a div"
-      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+      FunctionTest1-->URLTest1
+      click FunctionTest1 clickByFlow "Add a div"
+      click URLTest1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
   graph TB
@@ -27,15 +27,15 @@
       
     flowchart TB
-      Function-->URL
-      click Function clickByFlow "Add a div"
-      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
+      FunctionTest2-->URLTest2
+      click FunctionTest2 clickByFlow "Add a div"
+      click URLTest2 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
       
   flowchart TB
-    1Function--->2URL
-    click 1Function clickByFlow "Add a div"
-    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
+    10Function--->20URL
+    click 10Function clickByFlow "Add a div"
+    click 20URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
       
@@ -97,14 +97,14 @@
     
       graph TB
-        FunctionArg-->URL
-        click FunctionArg call clickByFlowArg(ARGUMENT) "Add a div"
+        FunctionArgTest2-->URL
+        click FunctionArgTest2 call clickByFlowArg(ARGUMENT) "Add a div"
         click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
       flowchart TB
-        FunctionArg-->URL
-        click FunctionArg call clickByFlowArg(ARGUMENT) "Add a div"
+        2FunctionArg-->URL
+        click 2FunctionArg call clickByFlowArg(ARGUMENT) "Add a div"
         click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
From 750f647b0d535826ebadd1e216a035c1e112e97e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 4 Oct 2022 16:55:46 +0800 Subject: [PATCH 02/11] fix(tests): Interaction - Security strict, other --- cypress/integration/other/interaction.spec.js | 15 +++++++-------- cypress/platform/click_security_other.html | 6 +++--- cypress/platform/click_security_strict.html | 6 +++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cypress/integration/other/interaction.spec.js b/cypress/integration/other/interaction.spec.js index 76c63c4ad3..f4f80f82a9 100644 --- a/cypress/integration/other/interaction.spec.js +++ b/cypress/integration/other/interaction.spec.js @@ -103,24 +103,24 @@ describe('Interaction', () => { cy.visit(url); }); it('should handle a click on a node without a bound function', () => { - cy.get('body').find('g#flowchart-Function-4').click(); + cy.contains('Function1').parents('.node').click(); cy.get('.created-by-click').should('not.exist'); }); it('should handle a click on a node with a bound function where the node starts with a number', () => { - cy.get('body').find('g[id="flowchart-1Function-10"]').click(); + cy.contains('1Function').parents('.node').click(); cy.get('.created-by-click').should('not.exist'); }); it('should handle a click on a node with a bound url', () => { - cy.get('body').find('g#flowchart-URL-5').click(); + cy.contains('URL1').find('.node').click(); cy.location().should(({ href }) => { expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); }); it('should handle a click on a node with a bound url where the node starts with a number', () => { - cy.get('body').find('g[id="flowchart-2URL-11"]').click(); + cy.contains('2URL').find('.node').click(); cy.location().should(({ href }) => { expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); @@ -159,18 +159,17 @@ describe('Interaction', () => { }); it('should handle a click on a node with a bound function', () => { - cy.get('body').find('g#flowchart-Function-4').click(); + cy.contains('Function1').parents('.node').click(); cy.get('.created-by-click').should('not.exist'); }); it('should handle a click on a node with a bound function where the node starts with a number', () => { - cy.get('body').find('g[id="flowchart-1Function-10"]').click(); - cy.get('.created-by-click').should('not.exist'); + cy.contains('1Function').parents('.node').click(); cy.get('.created-by-click').should('not.exist'); }); it('should handle a click on a node with a bound url', () => { - cy.get('body').find('g#flowchart-URL-5').click(); + cy.contains('URL1').find('.node').click(); cy.location().should(({ href }) => { expect(href).to.eq('http://localhost:9000/webpackUsage.html'); }); diff --git a/cypress/platform/click_security_other.html b/cypress/platform/click_security_other.html index 20bfd52933..348c8b9aa5 100644 --- a/cypress/platform/click_security_other.html +++ b/cypress/platform/click_security_other.html @@ -9,9 +9,9 @@
     graph TB
-      Function-->URL
-      click Function clickByFlow "Add a div"
-      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+      Function1-->URL1
+      click Function1 clickByFlow "Add a div"
+      click URL1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
     
   graph TB
diff --git a/cypress/platform/click_security_strict.html b/cypress/platform/click_security_strict.html
index 00c6d9c6a6..64fb2e9c67 100644
--- a/cypress/platform/click_security_strict.html
+++ b/cypress/platform/click_security_strict.html
@@ -9,9 +9,9 @@
   
     
     graph TB
-      Function-->URL
-      click Function clickByFlow "Add a div"
-      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+      Function1-->URL1
+      click Function1 clickByFlow "Add a div"
+      click URL1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
     
   graph TB

From d3a81f025a038cdf5e6565e34514d06ec482fe5a Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Tue, 4 Oct 2022 16:59:05 +0800
Subject: [PATCH 03/11] chore(tests): Interaction - cleanup

---
 cypress/integration/other/interaction.spec.js | 37 ++++++++-----------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/cypress/integration/other/interaction.spec.js b/cypress/integration/other/interaction.spec.js
index f4f80f82a9..63234d1473 100644
--- a/cypress/integration/other/interaction.spec.js
+++ b/cypress/integration/other/interaction.spec.js
@@ -1,9 +1,7 @@
 describe('Interaction', () => {
   describe('Security level loose', () => {
     beforeEach(() => {
-      const url = 'http://localhost:9000/click_security_loose.html';
-      cy.viewport(1440, 1024);
-      cy.visit(url);
+      cy.visit('http://localhost:9000/click_security_loose.html');
     });
 
     it('Graph: should handle a click on a node with a bound function', () => {
@@ -54,7 +52,6 @@ describe('Interaction', () => {
     });
 
     it('Flowchart-v2: should handle a click on a node with a bound url where the node starts with a number', () => {
-      // cy.contains('').click();
       cy.contains('20URL').find('.node').click();
       cy.location().should(({ href }) => {
         expect(href).to.eq('http://localhost:9000/webpackUsage.html');
@@ -62,45 +59,43 @@ describe('Interaction', () => {
     });
 
     it('should handle a click on a task with a bound URL clicking on the rect', () => {
-      cy.get('body').find('rect#cl1').click({ force: true });
+      cy.get('rect#cl1').click({ force: true });
       cy.location().should(({ href }) => {
         expect(href).to.eq('http://localhost:9000/webpackUsage.html');
       });
     });
 
     it('should handle a click on a task with a bound URL clicking on the text', () => {
-      cy.get('body').find('text#cl1-text').click({ force: true });
+      cy.get('text#cl1-text').click({ force: true });
       cy.location().should(({ href }) => {
         expect(href).to.eq('http://localhost:9000/webpackUsage.html');
       });
     });
 
     it('should handle a click on a task with a bound function without args', () => {
-      cy.get('body').find('rect#cl2').click({ force: true });
+      cy.get('rect#cl2').click({ force: true });
       cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant cl2');
     });
 
     it('should handle a click on a task with a bound function with args', () => {
-      cy.get('body').find('rect#cl3').click({ force: true });
+      cy.get('rect#cl3').click({ force: true });
       cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant test1 test2 test3');
     });
 
     it('should handle a click on a task with a bound function without args', () => {
-      cy.get('body').find('text#cl2-text').click({ force: true });
+      cy.get('text#cl2-text').click({ force: true });
       cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant cl2');
     });
 
     it('should handle a click on a task with a bound function with args ', () => {
-      cy.get('body').find('text#cl3-text').click({ force: true });
+      cy.get('text#cl3-text').click({ force: true });
       cy.get('.created-by-gant-click').should('have.text', 'Clicked By Gant test1 test2 test3');
     });
   });
 
   describe('Interaction - security level tight', () => {
     beforeEach(() => {
-      const url = 'http://localhost:9000/click_security_strict.html';
-      cy.viewport(1440, 1024);
-      cy.visit(url);
+      cy.visit('http://localhost:9000/click_security_strict.html');
     });
     it('should handle a click on a node without a bound function', () => {
       cy.contains('Function1').parents('.node').click();
@@ -127,35 +122,33 @@ describe('Interaction', () => {
     });
 
     it('should handle a click on a task with a bound URL clicking on the rect', () => {
-      cy.get('body').find('rect#cl1').click({ force: true });
+      cy.get('rect#cl1').click({ force: true });
       cy.location().should(({ href }) => {
         expect(href).to.eq('http://localhost:9000/webpackUsage.html');
       });
     });
 
     it('should handle a click on a task with a bound URL clicking on the text', () => {
-      cy.get('body').find('text#cl1-text').click({ force: true });
+      cy.get('text#cl1-text').click({ force: true });
       cy.location().should(({ href }) => {
         expect(href).to.eq('http://localhost:9000/webpackUsage.html');
       });
     });
 
     it('should handle a click on a task with a bound function', () => {
-      cy.get('body').find('rect#cl2').click({ force: true });
+      cy.get('rect#cl2').click({ force: true });
       cy.get('.created-by-gant-click').should('not.exist');
     });
 
     it('should handle a click on a task with a bound function', () => {
-      cy.get('body').find('text#cl2-text').click({ force: true });
+      cy.get('text#cl2-text').click({ force: true });
       cy.get('.created-by-gant-click').should('not.exist');
     });
   });
 
   describe('Interaction - security level other, missspelling', () => {
     beforeEach(() => {
-      const url = 'http://localhost:9000/click_security_other.html';
-      cy.viewport(1440, 1024);
-      cy.visit(url);
+      cy.visit('http://localhost:9000/click_security_other.html');
     });
 
     it('should handle a click on a node with a bound function', () => {
@@ -176,12 +169,12 @@ describe('Interaction', () => {
     });
 
     it('should handle a click on a task with a bound function', () => {
-      cy.get('body').find('rect#cl2').click({ force: true });
+      cy.get('rect#cl2').click({ force: true });
       cy.get('.created-by-gant-click').should('not.exist');
     });
 
     it('should handle a click on a task with a bound function', () => {
-      cy.get('body').find('text#cl2-text').click({ force: true });
+      cy.get('text#cl2-text').click({ force: true });
       cy.get('.created-by-gant-click').should('not.exist');
     });
   });

From a017ffc3c947084d2977a12aa75c831574ed19b9 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Wed, 5 Oct 2022 14:08:53 +0800
Subject: [PATCH 04/11] fix(test): Rerender

---
 cypress/platform/rerender.html | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/cypress/platform/rerender.html b/cypress/platform/rerender.html
index 9b6cb130eb..61c6891f76 100644
--- a/cypress/platform/rerender.html
+++ b/cypress/platform/rerender.html
@@ -17,11 +17,12 @@
       rerender('XMas');
 
       function rerender(text) {
-        var graphText = `graph TD
+        const graphText = `graph TD
         A[${text}] -->|Get money| B(Go shopping)`;
-        var graph = mermaid.mermaidAPI.render('id', graphText);
-        console.log('\x1b[35m%s\x1b[0m', '>> graph', graph);
-        document.getElementById('graph').innerHTML = graph;
+        mermaid.mermaidAPI.render('id', graphText).then((svg) => {
+          console.log('\x1b[35m%s\x1b[0m', '>> graph', svg);
+          document.getElementById('graph').innerHTML = svg;
+        });
       }
     
     

From 74bd576ebc02a3c7c6a4d436458464f42d9186ca Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Wed, 5 Oct 2022 14:52:04 +0800
Subject: [PATCH 05/11] fix(mermaid): Add await to render in init.

---
 cypress/platform/click_security_loose.html | 20 ++++++++++----------
 packages/mermaid/src/mermaid.ts            |  8 ++++----
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/cypress/platform/click_security_loose.html b/cypress/platform/click_security_loose.html
index ed9fcaaa80..625d340529 100644
--- a/cypress/platform/click_security_loose.html
+++ b/cypress/platform/click_security_loose.html
@@ -13,39 +13,39 @@
   
   
     
-
+      
     graph TB
       FunctionTest1-->URLTest1
       click FunctionTest1 clickByFlow "Add a div"
       click URLTest1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
-
+      
   graph TB
     1Function--->2URL
     click 1Function clickByFlow "Add a div"
     click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
-
+      
     flowchart TB
       FunctionTest2-->URLTest2
       click FunctionTest2 clickByFlow "Add a div"
       click URLTest2 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
       
-
+      
   flowchart TB
     10Function--->20URL
     click 10Function clickByFlow "Add a div"
     click 20URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
       
-
+      
   classDiagram
     class ShapeLink
     link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
     class ShapeCallback
     callback ShapeCallback "clickByClass" "This is a tooltip for a callback"
       
-
+      
   classDiagram-v2
     class ShapeLink2
     link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
@@ -95,20 +95,20 @@
     Add another diagram to demo page    : 48h
     
-
+      
       graph TB
         FunctionArgTest2-->URL
         click FunctionArgTest2 call clickByFlowArg(ARGUMENT) "Add a div"
         click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
-
+      
       flowchart TB
         2FunctionArg-->URL
         click 2FunctionArg call clickByFlowArg(ARGUMENT) "Add a div"
         click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
       
-
+      
       classDiagram
       class ShapeLink
       link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
@@ -116,7 +116,7 @@
       click ShapeCallback call clickByClass(123) "This is a tooltip for a callback"
       
-
+      
       classDiagram-v2
         class ShapeLink2
         link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
diff --git a/packages/mermaid/src/mermaid.ts b/packages/mermaid/src/mermaid.ts
index 6a709dd32c..391af32835 100644
--- a/packages/mermaid/src/mermaid.ts
+++ b/packages/mermaid/src/mermaid.ts
@@ -45,7 +45,7 @@ import { isDetailedError } from './utils';
  * @param nodes
  * @param callback
  */
-const init = function (
+const init = async function (
   config?: MermaidConfig,
   // eslint-disable-next-line no-undef
   nodes?: string | HTMLElement | NodeListOf,
@@ -69,7 +69,7 @@ const init = function (
   }
 };
 
-const initThrowsErrors = function (
+const initThrowsErrors = async function (
   config?: MermaidConfig,
   // eslint-disable-next-line no-undef
   nodes?: string | HTMLElement | NodeListOf,
@@ -108,7 +108,7 @@ const initThrowsErrors = function (
   // generate the id of the diagram
   const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
 
-  let txt;
+  let txt: string;
   const errors = [];
 
   // element is the current div with mermaid class
@@ -136,7 +136,7 @@ const initThrowsErrors = function (
       log.debug('Detected early reinit: ', init);
     }
     try {
-      mermaidAPI.render(
+      await mermaidAPI.render(
         id,
         txt,
         (svgCode: string, bindFunctions?: (el: Element) => void) => {

From f9753fc62171e4bf73963e824f0c265962bb3baa Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Wed, 5 Oct 2022 16:04:26 +0800
Subject: [PATCH 06/11] chore: Update test URL

---
 cypress/integration/other/interaction.spec.js | 22 +++++++++----------
 cypress/platform/click_security_loose.html    | 22 +++++++++----------
 cypress/platform/click_security_other.html    |  6 ++---
 cypress/platform/click_security_sandbox.html  | 22 +++++++++----------
 cypress/platform/click_security_strict.html   |  6 ++---
 cypress/platform/empty.html                   | 10 +++++++++
 6 files changed, 49 insertions(+), 39 deletions(-)
 create mode 100644 cypress/platform/empty.html

diff --git a/cypress/integration/other/interaction.spec.js b/cypress/integration/other/interaction.spec.js
index 63234d1473..857141b5bf 100644
--- a/cypress/integration/other/interaction.spec.js
+++ b/cypress/integration/other/interaction.spec.js
@@ -23,14 +23,14 @@ describe('Interaction', () => {
       // When there is a URL, cy.contains selects the a tag instead of the span. The .node is a child of a, so we have to use find instead of parent.
       cy.contains('URLTest1').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('Graph: should handle a click on a node with a bound url where the node starts with a number', () => {
       cy.contains('2URL').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
@@ -47,28 +47,28 @@ describe('Interaction', () => {
     it('Flowchart-v2: should handle a click on a node with a bound url', () => {
       cy.contains('URLTest2').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('Flowchart-v2: should handle a click on a node with a bound url where the node starts with a number', () => {
       cy.contains('20URL').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('should handle a click on a task with a bound URL clicking on the rect', () => {
       cy.get('rect#cl1').click({ force: true });
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('should handle a click on a task with a bound URL clicking on the text', () => {
       cy.get('text#cl1-text').click({ force: true });
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
@@ -110,28 +110,28 @@ describe('Interaction', () => {
     it('should handle a click on a node with a bound url', () => {
       cy.contains('URL1').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('should handle a click on a node with a bound url where the node starts with a number', () => {
       cy.contains('2URL').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('should handle a click on a task with a bound URL clicking on the rect', () => {
       cy.get('rect#cl1').click({ force: true });
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
     it('should handle a click on a task with a bound URL clicking on the text', () => {
       cy.get('text#cl1-text').click({ force: true });
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
@@ -164,7 +164,7 @@ describe('Interaction', () => {
     it('should handle a click on a node with a bound url', () => {
       cy.contains('URL1').find('.node').click();
       cy.location().should(({ href }) => {
-        expect(href).to.eq('http://localhost:9000/webpackUsage.html');
+        expect(href).to.eq('http://localhost:9000/empty.html');
       });
     });
 
diff --git a/cypress/platform/click_security_loose.html b/cypress/platform/click_security_loose.html
index 625d340529..459c14e851 100644
--- a/cypress/platform/click_security_loose.html
+++ b/cypress/platform/click_security_loose.html
@@ -17,38 +17,38 @@
     graph TB
       FunctionTest1-->URLTest1
       click FunctionTest1 clickByFlow "Add a div"
-      click URLTest1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+      click URLTest1 "http://localhost:9000/empty.html" "Visit mermaid docs"
       
   graph TB
     1Function--->2URL
     click 1Function clickByFlow "Add a div"
-    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+    click 2URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       
     flowchart TB
       FunctionTest2-->URLTest2
       click FunctionTest2 clickByFlow "Add a div"
-      click URLTest2 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
+      click URLTest2 "http://localhost:9000/empty.html" "Visit mermaid docs" _self
       
   flowchart TB
     10Function--->20URL
     click 10Function clickByFlow "Add a div"
-    click 20URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
+    click 20URL "http://localhost:9000/empty.html" "Visit mermaid docs" _self
       
   classDiagram
     class ShapeLink
-    link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+    link ShapeLink "http://localhost:9000/empty.html" "This is a tooltip for a link"
     class ShapeCallback
     callback ShapeCallback "clickByClass" "This is a tooltip for a callback"
       
   classDiagram-v2
     class ShapeLink2
-    link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+    link ShapeLink2 "http://localhost:9000/empty.html" "This is a tooltip for a link"
     class ShapeCallback2
     callback ShapeCallback2 "clickByClass" "This is a tooltip for a callback"
       
@@ -85,7 +85,7 @@ Calling a Callback (look at the console log) :cl2, after cl1, 3d Calling a Callback with args :cl3, after cl1, 3d - click cl1 href "http://localhost:9000/webpackUsage.html" + click cl1 href "http://localhost:9000/empty.html" click cl2 call clickByGantt() click cl3 call clickByGantt("test1", test2, test3) @@ -99,19 +99,19 @@ graph TB FunctionArgTest2-->URL click FunctionArgTest2 call clickByFlowArg(ARGUMENT) "Add a div" - click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" + click URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       flowchart TB
         2FunctionArg-->URL
         click 2FunctionArg call clickByFlowArg(ARGUMENT) "Add a div"
-        click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+        click URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       
       classDiagram
       class ShapeLink
-      link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+      link ShapeLink "http://localhost:9000/empty.html" "This is a tooltip for a link"
       class ShapeCallback
       click ShapeCallback call clickByClass(123) "This is a tooltip for a callback"
       
@@ -119,7 +119,7 @@
       classDiagram-v2
         class ShapeLink2
-        link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+        link ShapeLink2 "http://localhost:9000/empty.html" "This is a tooltip for a link"
         class ShapeCallback2
         click ShapeCallback2 call clickByClass(123) "This is a tooltip for a callback"
       
diff --git a/cypress/platform/click_security_other.html b/cypress/platform/click_security_other.html index 348c8b9aa5..5338cac067 100644 --- a/cypress/platform/click_security_other.html +++ b/cypress/platform/click_security_other.html @@ -11,13 +11,13 @@ graph TB Function1-->URL1 click Function1 clickByFlow "Add a div" - click URL1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" + click URL1 "http://localhost:9000/empty.html" "Visit mermaid docs"
   graph TB
     1Function-->2URL
     click 1Function clickByFlow "Add a div"
-    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+    click 2URL "http://localhost:9000/empty.html" "Visit mermaid docs"
     
@@ -50,7 +50,7 @@
     Visit mermaidjs               :active, cl1, 2014-01-07,2014-01-10
     Calling a Callback (look at the console log) :cl2, after cl1, 3d
 
-    click cl1 href "http://localhost:9000/webpackUsage.html"
+    click cl1 href "http://localhost:9000/empty.html"
     click cl2 call clickByGantt("test", test, test)
 
     section Last section
diff --git a/cypress/platform/click_security_sandbox.html b/cypress/platform/click_security_sandbox.html
index 94229500c4..49c5d71c06 100644
--- a/cypress/platform/click_security_sandbox.html
+++ b/cypress/platform/click_security_sandbox.html
@@ -17,38 +17,38 @@
     graph TB
       Function-->URL
       click Function clickByFlow "Add a div"
-      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+      click URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       
   graph TB
     1Function--->2URL
     click 1Function clickByFlow "Add a div"
-    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+    click 2URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       
     flowchart TB
       Function-->URL
       click Function clickByFlow "Add a div"
-      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
+      click URL "http://localhost:9000/empty.html" "Visit mermaid docs" _self
       
   flowchart TB
     1Function--->2URL
     click 1Function clickByFlow "Add a div"
-    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" _self
+    click 2URL "http://localhost:9000/empty.html" "Visit mermaid docs" _self
       
   classDiagram
     class ShapeLink
-    link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+    link ShapeLink "http://localhost:9000/empty.html" "This is a tooltip for a link"
     class ShapeCallback
     callback ShapeCallback "clickByClass" "This is a tooltip for a callback"
       
   classDiagram-v2
     class ShapeLink2
-    link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+    link ShapeLink2 "http://localhost:9000/empty.html" "This is a tooltip for a link"
     class ShapeCallback2
     callback ShapeCallback2 "clickByClass" "This is a tooltip for a callback"
       
@@ -85,7 +85,7 @@ Calling a Callback (look at the console log) :cl2, after cl1, 3d Calling a Callback with args :cl3, after cl1, 3d - click cl1 href "http://localhost:9000/webpackUsage.html" + click cl1 href "http://localhost:9000/empty.html" click cl2 call clickByGantt() click cl3 call clickByGantt("test1", test2, test3) @@ -99,19 +99,19 @@ graph TB FunctionArg-->URL click FunctionArg call clickByFlowArg(ARGUMENT) "Add a div" - click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" + click URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       flowchart TB
         FunctionArg-->URL
         click FunctionArg call clickByFlowArg(ARGUMENT) "Add a div"
-        click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+        click URL "http://localhost:9000/empty.html" "Visit mermaid docs"
       
       classDiagram
       class ShapeLink
-      link ShapeLink "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+      link ShapeLink "http://localhost:9000/empty.html" "This is a tooltip for a link"
       class ShapeCallback
       click ShapeCallback call clickByClass(123) "This is a tooltip for a callback"
       
@@ -119,7 +119,7 @@
       classDiagram-v2
         class ShapeLink2
-        link ShapeLink2 "http://localhost:9000/webpackUsage.html" "This is a tooltip for a link"
+        link ShapeLink2 "http://localhost:9000/empty.html" "This is a tooltip for a link"
         class ShapeCallback2
         click ShapeCallback2 call clickByClass(123) "This is a tooltip for a callback"
       
diff --git a/cypress/platform/click_security_strict.html b/cypress/platform/click_security_strict.html index 64fb2e9c67..26605ddf96 100644 --- a/cypress/platform/click_security_strict.html +++ b/cypress/platform/click_security_strict.html @@ -11,13 +11,13 @@ graph TB Function1-->URL1 click Function1 clickByFlow "Add a div" - click URL1 "http://localhost:9000/webpackUsage.html" "Visit mermaid docs" + click URL1 "http://localhost:9000/empty.html" "Visit mermaid docs"
   graph TB
     1Function-->2URL
     click 1Function clickByFlow "Add a div"
-    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"
+    click 2URL "http://localhost:9000/empty.html" "Visit mermaid docs"
     
@@ -51,7 +51,7 @@
     Calling a Callback (look at the console log) :cl2, after cl1, 3d
     Calling a Callback with args :cl3, after cl1, 3d
 
-    click cl1 href "http://localhost:9000/webpackUsage.html"
+    click cl1 href "http://localhost:9000/empty.html"
     click cl2 call clickByGantt()
     click cl3 call clickByGantt("test1", test2, test3)
 
diff --git a/cypress/platform/empty.html b/cypress/platform/empty.html
new file mode 100644
index 0000000000..2961644d60
--- /dev/null
+++ b/cypress/platform/empty.html
@@ -0,0 +1,10 @@
+
+
+  
+    
+    
+    
+    Empty
+  
+  
+

From d8c7557ae5fb736cde6a9763a25bbe43c83a466e Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Wed, 5 Oct 2022 16:05:27 +0800
Subject: [PATCH 07/11] fix: Docs

---
 docs/n00b-syntaxReference.md | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/docs/n00b-syntaxReference.md b/docs/n00b-syntaxReference.md
index 7edb4c319f..2c9ef72074 100644
--- a/docs/n00b-syntaxReference.md
+++ b/docs/n00b-syntaxReference.md
@@ -26,6 +26,18 @@ erDiagram
           PRODUCT ||--o{ ORDER-ITEM : "ordered in"
 ```
 
+```mermaid
+erDiagram
+          CUSTOMER }|..|{ DELIVERY-ADDRESS : has
+          CUSTOMER ||--o{ ORDER : places
+          CUSTOMER ||--o{ INVOICE : "liable for"
+          DELIVERY-ADDRESS ||--o{ ORDER : receives
+          INVOICE ||--|{ ORDER : covers
+          ORDER ||--|{ ORDER-ITEM : includes
+          PRODUCT-CATEGORY ||--|{ PRODUCT : contains
+          PRODUCT ||--o{ ORDER-ITEM : "ordered in"
+```
+
 The [Getting Started](./n00b-gettingStarted.md) section can also provide some practical examples of mermaid syntax.
 
 ## Diagram Breaking

From c05c98c08239b9a517136ee814b95e27f0aea73c Mon Sep 17 00:00:00 2001
From: Knut Sveidqvist 
Date: Wed, 5 Oct 2022 13:14:05 +0200
Subject: [PATCH 08/11] WIP

---
 cypress/platform/knsv.html                    |  2 +-
 cypress/platform/knsv2.html                   |  9 ++--
 packages/mermaid-mindmap/src/add-diagram.ts   | 17 +++----
 .../mermaid-mindmap/src/mindmapDetector.ts    |  3 --
 packages/mermaid-mindmap/src/registry.ts      | 50 ++++++++-----------
 packages/mermaid-mindmap/tsconfig.json        |  1 +
 packages/mermaid/src/Diagram.ts               |  6 +--
 packages/mermaid/src/config.type.ts           |  1 +
 .../mermaid/src/diagram-api/detectType.ts     | 19 +++----
 packages/mermaid/src/mermaidAPI.ts            | 11 +++-
 tsconfig.json                                 |  2 +-
 vite.config.ts                                |  8 +++
 12 files changed, 65 insertions(+), 64 deletions(-)

diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html
index d4ffa0c0c7..8bd8d7c791 100644
--- a/cypress/platform/knsv.html
+++ b/cypress/platform/knsv.html
@@ -368,7 +368,6 @@
     
- - + + +