diff --git a/cypress/helpers/util.js b/cypress/helpers/util.js index 143fc7ed7..a3f92defd 100644 --- a/cypress/helpers/util.js +++ b/cypress/helpers/util.js @@ -26,3 +26,9 @@ export const imgSnapshotTest = (graphStr, options, api) => { cy.get('svg'); cy.percySnapshot(); }; + +export const renderGraph = (graphStr, options, api) => { + const url = mermaidUrl(graphStr, options, api); + + cy.visit(url); +}; diff --git a/cypress/integration/other/configuration.spec.js b/cypress/integration/other/configuration.spec.js new file mode 100644 index 000000000..c2f1533b2 --- /dev/null +++ b/cypress/integration/other/configuration.spec.js @@ -0,0 +1,100 @@ +import { renderGraph } from '../../helpers/util'; +/* eslint-env jest */ +describe('Configuration', () => { + describe('arrowMarkerAbsolute', () => { + it('should handle default value false of arrowMarkerAbsolute', () => { + renderGraph( + `graph TD + A[Christmas] -->|Get money| B(Go shopping) + B --> C{Let me think} + C -->|One| D[Laptop] + C -->|Two| E[iPhone] + C -->|Three| F[fa:fa-car Car] + `, + { } + ); + + // Check the marker-end property to make sure it is properly set to + // start with # + cy.get('.edgePath path').first().should('have.attr', 'marker-end') + .should('exist') + .and('include', 'url(#'); + }); + it('should handle default value false of arrowMarkerAbsolute', () => { + renderGraph( + `graph TD + A[Christmas] -->|Get money| B(Go shopping) + B --> C{Let me think} + C -->|One| D[Laptop] + C -->|Two| E[iPhone] + C -->|Three| F[fa:fa-car Car] + `, + { } + ); + + // Check the marker-end property to make sure it is properly set to + // start with # + cy.get('.edgePath path').first().should('have.attr', 'marker-end') + .should('exist') + .and('include', 'url(#'); + }); + it('should handle arrowMarkerAbsolute excplicitly set to false', () => { + renderGraph( + `graph TD + A[Christmas] -->|Get money| B(Go shopping) + B --> C{Let me think} + C -->|One| D[Laptop] + C -->|Two| E[iPhone] + C -->|Three| F[fa:fa-car Car] + `, + { + arrowMarkerAbsolute: false + } + ); + + // Check the marker-end property to make sure it is properly set to + // start with # + cy.get('.edgePath path').first().should('have.attr', 'marker-end') + .should('exist') + .and('include', 'url(#'); + }); + it('should handle arrowMarkerAbsolute excplicitly set to "false" as false', () => { + renderGraph( + `graph TD + A[Christmas] -->|Get money| B(Go shopping) + B --> C{Let me think} + C -->|One| D[Laptop] + C -->|Two| E[iPhone] + C -->|Three| F[fa:fa-car Car] + `, + { + arrowMarkerAbsolute: "false" + } + ); + + // Check the marker-end property to make sure it is properly set to + // start with # + cy.get('.edgePath path').first().should('have.attr', 'marker-end') + .should('exist') + .and('include', 'url(#'); + }); + it('should handle arrowMarkerAbsolute set to true', () => { + renderGraph( + `graph TD + A[Christmas] -->|Get money| B(Go shopping) + B --> C{Let me think} + C -->|One| D[Laptop] + C -->|Two| E[iPhone] + C -->|Three| F[fa:fa-car Car] + `, + { + arrowMarkerAbsolute: true + } + ); + + cy.get('.edgePath path').first().should('have.attr', 'marker-end') + .should('exist') + .and('include', 'url(http://localhost'); + }); + }); +}); diff --git a/cypress/platform/e2e.html b/cypress/platform/e2e.html index 4384fd0ec..010b11cb2 100644 --- a/cypress/platform/e2e.html +++ b/cypress/platform/e2e.html @@ -4,9 +4,8 @@