diff --git a/.commitlintrc.json b/.commitlintrc.json deleted file mode 100644 index c30e5a970b..0000000000 --- a/.commitlintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["@commitlint/config-conventional"] -} diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ceff724bb4..dceb314c8e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -14,7 +14,7 @@ module.exports = { }, tsconfigRootDir: __dirname, sourceType: 'module', - ecmaVersion: 2020, + ecmaVersion: 2022, allowAutomaticSingleRunInference: true, project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], parser: '@typescript-eslint/parser', @@ -23,7 +23,7 @@ module.exports = { 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:json/recommended', - 'plugin:markdown/recommended', + 'plugin:markdown/recommended-legacy', 'plugin:@cspell/recommended', 'prettier', ], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0ab766079..bf54772bce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,13 +37,13 @@ jobs: run: pnpm run build - name: Upload Mermaid Build as Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: mermaid-build path: packages/mermaid/dist - name: Upload Mermaid Mindmap Build as Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: mermaid-mindmap-build path: packages/mermaid-mindmap/dist diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f8c50f47fa..764ec598cb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,7 +33,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: config-file: ./.github/codeql/codeql-config.yml languages: ${{ matrix.language }} @@ -45,7 +45,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -59,4 +59,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 4e75197790..0d4a01360d 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -17,4 +17,4 @@ jobs: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: 'Dependency Review' - uses: actions/dependency-review-action@v3 + uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 81e58f6aad..6477c9eb5c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -17,9 +17,19 @@ permissions: contents: read env: - # For PRs and MergeQueues, the target commit is used, and for push events, github.event.previous is used. - targetHash: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || (github.event.before == '0000000000000000000000000000000000000000' && 'develop' || github.event.before) }} - + # For PRs and MergeQueues, the target commit is used, and for push events to non-develop branches, github.event.previous is used if available. Otherwise, 'develop' is used. + targetHash: >- + ${{ + github.event.pull_request.base.sha || + github.event.merge_group.base_sha || + ( + ( + (github.event_name == 'push' && github.ref == 'refs/heads/develop') || + github.event.before == '0000000000000000000000000000000000000000' + ) && 'develop' + ) || + github.event.before + }} jobs: cache: runs-on: ubuntu-latest @@ -96,7 +106,7 @@ jobs: # These cached snapshots are downloaded, providing the reference snapshots. - name: Cache snapshots id: cache-snapshot - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: ./cypress/snapshots key: ${{ runner.os }}-snapshots-${{ env.targetHash }} @@ -138,7 +148,7 @@ jobs: CYPRESS_COMMIT: ${{ github.sha }} - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 # Run step only pushes to develop and pull_requests if: ${{ steps.cypress.conclusion == 'success' && (github.event_name == 'pull_request' || github.ref == 'refs/heads/develop')}} with: @@ -175,7 +185,7 @@ jobs: - name: Save snapshots cache id: cache-upload if: ${{ github.event_name == 'push' && needs.e2e.result != 'failure' }} - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: ./snapshots key: ${{ runner.os }}-snapshots-${{ github.event.after }} diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index 59d25b7c54..bf54d7df28 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v4 - name: Restore lychee cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .lycheecache key: cache-lychee-${{ github.sha }} diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index b2fc1cc26e..0965903467 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -22,7 +22,7 @@ jobs: pull-requests: write # write permission is required to label PRs steps: - name: Label PR - uses: release-drafter/release-drafter@v5 + uses: release-drafter/release-drafter@v6 with: config-name: pr-labeler.yml disable-autolabeler: false diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 6efd90c7f7..fb70a90ecd 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -37,13 +37,13 @@ jobs: run: pnpm install --frozen-lockfile - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v4 - name: Run Build run: pnpm --filter mermaid run docs:build:vitepress - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v3 with: path: packages/mermaid/src/vitepress/.vitepress/dist @@ -56,4 +56,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml index 8e9c0da99e..657bc767a3 100644 --- a/.github/workflows/release-draft.yml +++ b/.github/workflows/release-draft.yml @@ -16,7 +16,7 @@ jobs: pull-requests: read # required to read PR titles/labels steps: - name: Draft Release - uses: release-drafter/release-drafter@v5 + uses: release-drafter/release-drafter@v6 with: disable-autolabeler: true env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7160ecc5fe..a4bd264e05 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts --coverage - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 # Run step only pushes to develop and pull_requests if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' }} with: diff --git a/.github/workflows/update-browserlist.yml b/.github/workflows/update-browserlist.yml index f4fa2a982f..9aac3d7b3b 100644 --- a/.github/workflows/update-browserlist.yml +++ b/.github/workflows/update-browserlist.yml @@ -19,7 +19,7 @@ jobs: message: 'chore: update browsers list' push: false - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: branch: update-browserslist title: Update Browserslist diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index 59f6536e22..0000000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# . "$(dirname "$0")/_/husky.sh" - -# npx --no-install commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit index a9e30b9bec..ad85fc42c2 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -pnpm run pre-commit +NODE_OPTIONS="--max_old_space_size=8192" pnpm run pre-commit diff --git a/.prettierrc.json b/.prettierrc.json index 4f0588f9cf..28aa6e7660 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,5 +3,6 @@ "printWidth": 100, "singleQuote": true, "useTabs": false, - "tabWidth": 2 + "tabWidth": 2, + "trailingComma": "es5" } diff --git a/cypress/integration/other/configuration.spec.js b/cypress/integration/other/configuration.spec.js index 23338271f5..544eab40fb 100644 --- a/cypress/integration/other/configuration.spec.js +++ b/cypress/integration/other/configuration.spec.js @@ -118,11 +118,53 @@ describe('Configuration', () => { it('should not taint the initial configuration when using multiple directives', () => { const url = 'http://localhost:9000/regression/issue-1874.html'; cy.visit(url); - - cy.get('svg'); + cy.window().should('have.property', 'rendered', true); + cy.get('svg').should('be.visible'); cy.matchImageSnapshot( 'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives' ); }); }); + + describe('suppressErrorRendering', () => { + beforeEach(() => { + cy.on('uncaught:exception', (err, runnable) => { + return !err.message.includes('Parse error on line'); + }); + }); + + it('should not render error diagram if suppressErrorRendering is set', () => { + const url = 'http://localhost:9000/suppressError.html?suppressErrorRendering=true'; + cy.visit(url); + cy.window().should('have.property', 'rendered', true); + cy.get('#test') + .find('svg') + .should(($svg) => { + // all failing diagrams should not appear! + expect($svg).to.have.length(2); + // none of the diagrams should be error diagrams + expect($svg).to.not.contain('Syntax error'); + }); + cy.matchImageSnapshot( + 'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set' + ); + }); + + it('should render error diagram if suppressErrorRendering is not set', () => { + const url = 'http://localhost:9000/suppressError.html'; + cy.visit(url); + cy.window().should('have.property', 'rendered', true); + cy.get('#test') + .find('svg') + .should(($svg) => { + // all five diagrams should be rendered + expect($svg).to.have.length(5); + // some of the diagrams should be error diagrams + expect($svg).to.contain('Syntax error'); + }); + cy.matchImageSnapshot( + 'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set' + ); + }); + }); }); diff --git a/cypress/integration/rendering/flowchart-elk.spec.js b/cypress/integration/rendering/flowchart-elk.spec.js index 221806b073..e931025e91 100644 --- a/cypress/integration/rendering/flowchart-elk.spec.js +++ b/cypress/integration/rendering/flowchart-elk.spec.js @@ -844,3 +844,42 @@ end }); }); }); + +describe('Title and arrow styling #4813', () => { + it('should render a flowchart with title', () => { + const titleString = 'Test Title'; + renderGraph( + `--- + title: ${titleString} + --- + flowchart LR + A-->B + A-->C`, + { flowchart: { defaultRenderer: 'elk' } } + ); + cy.get('svg').should((svg) => { + const title = svg[0].querySelector('text'); + expect(title.textContent).to.contain(titleString); + }); + }); + + it('Render with stylized arrows', () => { + renderGraph( + ` + flowchart LR + A-->B + B-.-oC + C==xD + D ~~~ A`, + { flowchart: { defaultRenderer: 'elk' } } + ); + cy.get('svg').should((svg) => { + const edges = svg[0].querySelectorAll('.edges path'); + console.log(edges); + expect(edges[0]).to.have.attr('pattern', 'solid'); + expect(edges[1]).to.have.attr('pattern', 'dotted'); + expect(edges[2]).to.have.css('stroke-width', '3.5px'); + expect(edges[3]).to.have.css('stroke-width', '1.5px'); + }); + }); +}); diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index 857d395be7..3eb2a0432a 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -760,6 +760,51 @@ A ~~~ B ); }); + it('3258: Should render subgraphs with main graph nodeSpacing and rankSpacing', () => { + imgSnapshotTest( + `--- + title: Subgraph nodeSpacing and rankSpacing example + --- + flowchart LR + X --> Y + subgraph X + direction LR + A + C + end + subgraph Y + B + D + end + `, + { flowchart: { nodeSpacing: 1, rankSpacing: 1 } } + ); + }); + + it('3258: Should render subgraphs with large nodeSpacing and rankSpacing', () => { + imgSnapshotTest( + `--- + title: Subgraph nodeSpacing and rankSpacing example + config: + flowchart: + nodeSpacing: 250 + rankSpacing: 250 + --- + flowchart LR + X --> Y + subgraph X + direction LR + A + C + end + subgraph Y + B + D + end + ` + ); + }); + describe('Markdown strings flowchart (#4220)', () => { describe('html labels', () => { it('With styling and classes', () => { @@ -904,6 +949,18 @@ end ); }); }); + + it('should not auto wrap when markdownAutoWrap is false', () => { + imgSnapshotTest( + `flowchart TD + angular_velocity["\`**angular_velocity** + *angular_displacement / duration* + [rad/s, 1/s] + {vector}\`"] + frequency["frequency\n(1 / period_duration)\n[Hz, 1/s]"]`, + { markdownAutoWrap: false } + ); + }); }); describe('Subgraph title margins', () => { it('Should render subgraphs with title margins set (LR)', () => { diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 7566110082..a0c2dbcb9e 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -101,12 +101,12 @@ describe('Gantt diagram', () => { title Adding GANTT diagram to mermaid excludes weekdays 2014-01-10 todayMarker off - + section team's critical event deadline A :milestone, crit, deadlineA, 2024-02-01, 0 deadline B :milestone, crit, deadlineB, 2024-02-15, 0 boss on leave :bossaway, 2024-01-28, 2024-02-11 - + section new intern onboarding :onboarding, 2024-01-02, 1w literature review :litreview, 2024-01-02, 10d @@ -573,7 +573,28 @@ describe('Gantt diagram', () => { ` ); }); - + it('should render a gantt diagram exculding friday and saturday', () => { + imgSnapshotTest( + `gantt + title A Gantt Diagram + dateFormat YYYY-MM-DD + excludes weekends + weekend friday + section Section1 + A task :a1, 2024-02-28, 10d` + ); + }); + it('should render a gantt diagram exculding saturday and sunday', () => { + imgSnapshotTest( + `gantt + title A Gantt Diagram + dateFormat YYYY-MM-DD + excludes weekends + weekend saturday + section Section1 + A task :a1, 2024-02-28, 10d` + ); + }); it('should render when compact is true', () => { imgSnapshotTest( ` diff --git a/cypress/integration/rendering/gitGraph.spec.js b/cypress/integration/rendering/gitGraph.spec.js index 2184fecf88..4e8f7fdcac 100644 --- a/cypress/integration/rendering/gitGraph.spec.js +++ b/cypress/integration/rendering/gitGraph.spec.js @@ -1013,4 +1013,450 @@ gitGraph TB: { gitGraph: { parallelCommits: true } } ); }); + describe('Git-Graph Bottom-to-Top Orientation Tests', () => { + it('50: should render a simple gitgraph with commit on main branch | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "1" + commit id: "2" + commit id: "3" + `, + {} + ); + }); + it('51: should render a simple gitgraph with commit on main branch with Id | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "One" + commit id: "Two" + commit id: "Three" + `, + {} + ); + }); + it('52: should render a simple gitgraph with different commitTypes on main branch | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "Normal Commit" + commit id: "Reverse Commit" type: REVERSE + commit id: "Highlight Commit" type: HIGHLIGHT + `, + {} + ); + }); + it('53: should render a simple gitgraph with tags commitTypes on main branch | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "Normal Commit with tag" tag: "v1.0.0" + commit id: "Reverse Commit with tag" type: REVERSE tag: "RC_1" + commit id: "Highlight Commit" type: HIGHLIGHT tag: "8.8.4" + `, + {} + ); + }); + it('54: should render a simple gitgraph with two branches | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "1" + commit id: "2" + branch develop + checkout develop + commit id: "3" + commit id: "4" + checkout main + commit id: "5" + commit id: "6" + `, + {} + ); + }); + it('55: should render a simple gitgraph with two branches and merge commit | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "1" + commit id: "2" + branch develop + checkout develop + commit id: "3" + commit id: "4" + checkout main + merge develop + commit id: "5" + commit id: "6" + `, + {} + ); + }); + it('56: should render a simple gitgraph with three branches and tagged merge commit | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "1" + commit id: "2" + branch nice_feature + checkout nice_feature + commit id: "3" + checkout main + commit id: "4" + checkout nice_feature + branch very_nice_feature + checkout very_nice_feature + commit id: "5" + checkout main + commit id: "6" + checkout nice_feature + commit id: "7" + checkout main + merge nice_feature id: "12345" tag: "my merge commit" + checkout very_nice_feature + commit id: "8" + checkout main + commit id: "9" + `, + {} + ); + }); + it('57: should render a simple gitgraph with more than 8 branches & overriding variables | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': { + 'gitBranchLabel0': '#ffffff', + 'gitBranchLabel1': '#ffffff', + 'gitBranchLabel2': '#ffffff', + 'gitBranchLabel3': '#ffffff', + 'gitBranchLabel4': '#ffffff', + 'gitBranchLabel5': '#ffffff', + 'gitBranchLabel6': '#ffffff', + 'gitBranchLabel7': '#ffffff', + } } }%% + gitGraph BT: + checkout main + branch branch1 + branch branch2 + branch branch3 + branch branch4 + branch branch5 + branch branch6 + branch branch7 + branch branch8 + branch branch9 + checkout branch1 + commit id: "1" + `, + {} + ); + }); + it('58: should render a simple gitgraph with rotated labels | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'gitGraph': { + 'rotateCommitLabel': true + } } }%% + gitGraph BT: + commit id: "75f7219e83b321cd3fdde7dcf83bc7c1000a6828" + commit id: "0db4784daf82736dec4569e0dc92980d328c1f2e" + commit id: "7067e9973f9eaa6cd4a4b723c506d1eab598e83e" + commit id: "66972321ad6c199013b5b31f03b3a86fa3f9817d" + `, + {} + ); + }); + it('59: should render a simple gitgraph with horizontal labels | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'gitGraph': { + 'rotateCommitLabel': false + } } }%% + gitGraph BT: + commit id: "Alpha" + commit id: "Beta" + commit id: "Gamma" + commit id: "Delta" + `, + {} + ); + }); + it('60: should render a simple gitgraph with cherry pick commit | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + ` + gitGraph BT: + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + commit id:"ONE" + checkout develop + commit id:"B" + checkout main + commit id:"TWO" + cherry-pick id:"A" + commit id:"THREE" + checkout develop + commit id:"C" + `, + {} + ); + }); + it('61: should render a gitgraph with cherry pick commit with custom tag | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + ` + gitGraph BT: + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + commit id:"ONE" + checkout develop + commit id:"B" + checkout main + commit id:"TWO" + cherry-pick id:"A" tag: "snapshot" + commit id:"THREE" + checkout develop + commit id:"C" + `, + {} + ); + }); + it('62: should render a gitgraph with cherry pick commit with no tag | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + ` + gitGraph BT: + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + commit id:"ONE" + checkout develop + commit id:"B" + checkout main + commit id:"TWO" + cherry-pick id:"A" tag: "" + commit id:"THREE" + checkout develop + commit id:"C" + `, + {} + ); + }); + it('63: should render a simple gitgraph with two cherry pick commit | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + ` + gitGraph BT: + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + commit id:"ONE" + checkout develop + commit id:"B" + branch featureA + commit id:"FIX" + commit id: "FIX-2" + checkout main + commit id:"TWO" + cherry-pick id:"A" + commit id:"THREE" + cherry-pick id:"FIX" + checkout develop + commit id:"C" + merge featureA + `, + {} + ); + }); + it('64: should render commits for more than 8 branches | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + ` + gitGraph BT: + checkout main + %% Make sure to manually set the ID of all commits, for consistent visual tests + commit id: "1-abcdefg" + checkout main + branch branch1 + commit id: "2-abcdefg" + checkout main + merge branch1 + branch branch2 + commit id: "3-abcdefg" + checkout main + merge branch2 + branch branch3 + commit id: "4-abcdefg" + checkout main + merge branch3 + branch branch4 + commit id: "5-abcdefg" + checkout main + merge branch4 + branch branch5 + commit id: "6-abcdefg" + checkout main + merge branch5 + branch branch6 + commit id: "7-abcdefg" + checkout main + merge branch6 + branch branch7 + commit id: "8-abcdefg" + checkout main + merge branch7 + branch branch8 + commit id: "9-abcdefg" + checkout main + merge branch8 + branch branch9 + commit id: "10-abcdefg" + `, + {} + ); + }); + it('65: should render a simple gitgraph with three branches,custom merge commit id,tag,type | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id: "1" + commit id: "2" + branch nice_feature + checkout nice_feature + commit id: "3" + checkout main + commit id: "4" + checkout nice_feature + branch very_nice_feature + checkout very_nice_feature + commit id: "5" + checkout main + commit id: "6" + checkout nice_feature + commit id: "7" + checkout main + merge nice_feature id: "customID" tag: "customTag" type: REVERSE + checkout very_nice_feature + commit id: "8" + checkout main + commit id: "9" + `, + {} + ); + }); + it('66: should render a simple gitgraph with a title | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `--- + title: simple gitGraph + --- + gitGraph BT: + commit id: "1-abcdefg" + `, + {} + ); + }); + it('67: should render a simple gitgraph overlapping commits | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id:"s1" + commit id:"s2" + branch branch1 + commit id:"s3" + commit id:"s4" + checkout main + commit id:"s5" + checkout branch1 + commit id:"s6" + commit id:"s7" + merge main + `, + {} + ); + }); + it('68: should render a simple gitgraph with two branches from same commit | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id:"1-abcdefg" + commit id:"2-abcdefg" + branch feature-001 + commit id:"3-abcdefg" + commit id:"4-abcdefg" + checkout main + branch feature-002 + commit id:"5-abcdefg" + checkout feature-001 + merge feature-002 + `, + {} + ); + }); + it('69: should render GitGraph with branch that is not used immediately | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id:"1-abcdefg" + branch x + checkout main + commit id:"2-abcdefg" + checkout x + commit id:"3-abcdefg" + checkout main + merge x + `, + {} + ); + }); + it('70: should render GitGraph with branch and sub-branch neither of which used immediately | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id:"1-abcdefg" + branch x + checkout main + commit id:"2-abcdefg" + checkout x + commit id:"3-abcdefg" + checkout main + merge x + checkout x + branch y + checkout x + commit id:"4-abcdefg" + checkout y + commit id:"5-abcdefg" + checkout x + merge y + `, + {} + ); + }); + it('71: should render GitGraph with parallel commits | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + commit id:"1-abcdefg" + commit id:"2-abcdefg" + branch develop + commit id:"3-abcdefg" + commit id:"4-abcdefg" + checkout main + branch feature + commit id:"5-abcdefg" + commit id:"6-abcdefg" + checkout main + commit id:"7-abcdefg" + commit id:"8-abcdefg" + `, + { gitGraph: { parallelCommits: true } } + ); + }); + it('72: should render GitGraph with unconnected branches and parallel commits | Vertical Branch - Bottom-to-top', () => { + imgSnapshotTest( + `gitGraph BT: + branch dev + branch v2 + branch feat + commit id:"1-abcdefg" + commit id:"2-abcdefg" + checkout main + commit id:"3-abcdefg" + checkout dev + commit id:"4-abcdefg" + checkout v2 + commit id:"5-abcdefg" + checkout main + commit id:"6-abcdefg" + `, + { gitGraph: { parallelCommits: true } } + ); + }); + }); }); diff --git a/cypress/integration/rendering/sequencediagram.spec.js b/cypress/integration/rendering/sequencediagram.spec.js index 306b6c79f0..1285a0832d 100644 --- a/cypress/integration/rendering/sequencediagram.spec.js +++ b/cypress/integration/rendering/sequencediagram.spec.js @@ -375,7 +375,7 @@ context('Sequence diagram', () => { {} ); }); - it('should have actor-top and actor-bottom classes on top and bottom actor box and symbol', () => { + it('should have actor-top and actor-bottom classes on top and bottom actor box and symbol and actor-box and actor-man classes for text tags', () => { imgSnapshotTest( ` sequenceDiagram @@ -394,6 +394,9 @@ context('Sequence diagram', () => { cy.get('.actor-man').should('have.class', 'actor-bottom'); cy.get('.actor.actor-bottom').should('not.have.class', 'actor-top'); cy.get('.actor-man.actor-bottom').should('not.have.class', 'actor-top'); + + cy.get('text.actor-box').should('include.text', 'Alice'); + cy.get('text.actor-man').should('include.text', 'Bob'); }); it('should render long notes left of actor', () => { imgSnapshotTest( @@ -807,7 +810,10 @@ context('Sequence diagram', () => { note left of Alice: config: mirrorActors=true
directive: mirrorActors=false Bob->>Alice: Short as well `, - { logLevel: 0, sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' } } + { + logLevel: 0, + sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' }, + } ); }); }); @@ -858,7 +864,10 @@ context('Sequence diagram', () => { a->>j: Hello John, how are you? j-->>a: Great! `, - { logLevel: 0, sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' } } + { + logLevel: 0, + sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' }, + } ); }); it('should support actor links and properties when not mirrored EXPERIMENTAL: USE WITH CAUTION', () => { diff --git a/cypress/platform/ashish2.html b/cypress/platform/ashish2.html index 76fbd36f7e..bb0aba27ed 100644 --- a/cypress/platform/ashish2.html +++ b/cypress/platform/ashish2.html @@ -4,7 +4,7 @@ + diff --git a/cypress/platform/click_security_other.html b/cypress/platform/click_security_other.html index 7dc75ea884..11fd806ec5 100644 --- a/cypress/platform/click_security_other.html +++ b/cypress/platform/click_security_other.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/click_security_sandbox.html b/cypress/platform/click_security_sandbox.html index 2e03bceeb6..50e3dfb3e4 100644 --- a/cypress/platform/click_security_sandbox.html +++ b/cypress/platform/click_security_sandbox.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/click_security_strict.html b/cypress/platform/click_security_strict.html index c4ac4bd684..c2a3f84cd0 100644 --- a/cypress/platform/click_security_strict.html +++ b/cypress/platform/click_security_strict.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/css1.html b/cypress/platform/css1.html index 9e070da254..2853a93581 100644 --- a/cypress/platform/css1.html +++ b/cypress/platform/css1.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/current.html b/cypress/platform/current.html index 35b8ce3bcf..f08fac0ad1 100644 --- a/cypress/platform/current.html +++ b/cypress/platform/current.html @@ -4,7 +4,7 @@ + diff --git a/cypress/platform/ghsa3.html b/cypress/platform/ghsa3.html index 2170a808e5..5c11457f6b 100644 --- a/cypress/platform/ghsa3.html +++ b/cypress/platform/ghsa3.html @@ -4,7 +4,7 @@ + diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html index 512333c010..edecb55572 100644 --- a/cypress/platform/knsv.html +++ b/cypress/platform/knsv.html @@ -4,7 +4,7 @@ Example mermaid.initialize({ theme: 'base', themeVariables: {}, - startOnLoad: true, + startOnLoad: false, }); + await mermaid.run(); + if (window.Cypress) { + window.rendered = true; + } diff --git a/cypress/platform/render-after-error.html b/cypress/platform/render-after-error.html index 2334158c2b..4347df3c16 100644 --- a/cypress/platform/render-after-error.html +++ b/cypress/platform/render-after-error.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/rerender.html b/cypress/platform/rerender.html index d9dbc4a5e7..0cd5aeaacc 100644 --- a/cypress/platform/rerender.html +++ b/cypress/platform/rerender.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/showcase_base.html b/cypress/platform/showcase_base.html index 32a2ae72a1..54e3108d3c 100644 --- a/cypress/platform/showcase_base.html +++ b/cypress/platform/showcase_base.html @@ -4,7 +4,7 @@ + diff --git a/cypress/platform/suppressError.html b/cypress/platform/suppressError.html new file mode 100644 index 0000000000..f20f97b598 --- /dev/null +++ b/cypress/platform/suppressError.html @@ -0,0 +1,59 @@ + + + + + + Mermaid Quick Test Page + + + +
+
+  flowchart
+      a[This should be visible]
+    
+
+  flowchart
+    a --< b
+    
+
+  flowchart
+      a[This should be visible]
+    
+
+  ---
+  config:
+    suppressErrorRendering: true # This should not affect anything, as suppressErrorRendering is a secure config
+  ---
+  flowchart
+    a --< b
+    
+
+  ---
+  config:
+    suppressErrorRendering: false # This should not affect anything, as suppressErrorRendering is a secure config
+  ---
+  flowchart
+    a --< b
+    
+
+ + + diff --git a/cypress/platform/vertices.html b/cypress/platform/vertices.html index f4c045b555..ca0e9e8d3e 100644 --- a/cypress/platform/vertices.html +++ b/cypress/platform/vertices.html @@ -1,4 +1,4 @@ - + diff --git a/cypress/platform/viewer.js b/cypress/platform/viewer.js index 39f456c230..482a90646d 100644 --- a/cypress/platform/viewer.js +++ b/cypress/platform/viewer.js @@ -1,4 +1,5 @@ import mermaid from './mermaid.esm.mjs'; +import flowchartELK from './mermaid-flowchart-elk.esm.mjs'; import externalExample from './mermaid-example-diagram.esm.mjs'; import zenUml from './mermaid-zenuml.esm.mjs'; @@ -45,7 +46,7 @@ const contentLoaded = async function () { document.getElementsByTagName('body')[0].appendChild(div); } - await mermaid.registerExternalDiagrams([externalExample, zenUml]); + await mermaid.registerExternalDiagrams([externalExample, zenUml, flowchartELK]); mermaid.initialize(graphObj.mermaid); await mermaid.run(); } diff --git a/cypress/platform/xss10.html b/cypress/platform/xss10.html index 79fa97136e..b28a3c0a8a 100644 --- a/cypress/platform/xss10.html +++ b/cypress/platform/xss10.html @@ -4,7 +4,7 @@ + diff --git a/cypress/platform/xss23-css.html b/cypress/platform/xss23-css.html index c4bc43b6a0..296449b023 100644 --- a/cypress/platform/xss23-css.html +++ b/cypress/platform/xss23-css.html @@ -4,7 +4,7 @@ + diff --git a/demos/c4context.html b/demos/c4context.html index f674054a2f..64ca768e13 100644 --- a/demos/c4context.html +++ b/demos/c4context.html @@ -1,4 +1,4 @@ - + diff --git a/demos/classchart.html b/demos/classchart.html index 3ad8fb100b..f04fa5b5f9 100644 --- a/demos/classchart.html +++ b/demos/classchart.html @@ -1,4 +1,4 @@ - + diff --git a/demos/dataflowchart.html b/demos/dataflowchart.html index 5fbfa29cc5..dd8bca658d 100644 --- a/demos/dataflowchart.html +++ b/demos/dataflowchart.html @@ -1,4 +1,4 @@ - + diff --git a/demos/dev/example.html b/demos/dev/example.html index 4ece7efa8b..27d31e177a 100644 --- a/demos/dev/example.html +++ b/demos/dev/example.html @@ -39,6 +39,8 @@