Compare commits
	
		
			29 Commits
		
	
	
		
			@mermaid-j
			...
			sidv/e2eCI
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					8acc6c1c53 | ||
| 
						 | 
					be1656b136 | ||
| 
						 | 
					33c5ba02e6 | ||
| 
						 | 
					1015516416 | ||
| 
						 | 
					d475696534 | ||
| 
						 | 
					f1634216c4 | ||
| 
						 | 
					2777ed24f2 | ||
| 
						 | 
					579536a151 | ||
| 
						 | 
					2c4443ec71 | ||
| 
						 | 
					638607da00 | ||
| 
						 | 
					f3e1479c77 | ||
| 
						 | 
					bc5b9d3937 | ||
| 
						 | 
					976585401c | ||
| 
						 | 
					6694bca803 | ||
| 
						 | 
					2a7dc427ae | ||
| 
						 | 
					a3d8f1f8e4 | ||
| 
						 | 
					688d671d2e | ||
| 
						 | 
					b14b23a6af | ||
| 
						 | 
					aa949b4ff6 | ||
| 
						 | 
					e792bf5239 | ||
| 
						 | 
					a0d3b8c1fe | ||
| 
						 | 
					a86f831b3e | ||
| 
						 | 
					1c794ce619 | ||
| 
						 | 
					86cab46cf0 | ||
| 
						 | 
					e6e02a9b70 | ||
| 
						 | 
					f3a209badc | ||
| 
						 | 
					69e84b6731 | ||
| 
						 | 
					58dca0afe3 | ||
| 
						 | 
					af1a7bea1f | 
							
								
								
									
										30
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						@@ -3,7 +3,7 @@ name: E2E
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
 | 
			
		||||
permissions:
 | 
			
		||||
  contents: read
 | 
			
		||||
  contents: write
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
@@ -28,15 +28,28 @@ jobs:
 | 
			
		||||
          cache: pnpm
 | 
			
		||||
          node-version: ${{ matrix.node-version }}
 | 
			
		||||
 | 
			
		||||
      # Experiment with this step if we cannot check-in the snapshots to the repo.
 | 
			
		||||
      # - name: Cache snapshots
 | 
			
		||||
      #   id: cache-snapshot
 | 
			
		||||
      #   uses: actions/cache@v3
 | 
			
		||||
      #   with:
 | 
			
		||||
      #     # npm cache files are stored in `~/.npm` on Linux/macOS
 | 
			
		||||
      #     path: ./cypress/snapshots
 | 
			
		||||
      #     key: ${{ runner.os }}-build-${env.GITHUB_REF}
 | 
			
		||||
      #     restore-keys: |
 | 
			
		||||
      #       ${{ runner.os }}-build-develop
 | 
			
		||||
 | 
			
		||||
      # Install NPM dependencies, cache them correctly
 | 
			
		||||
      # and run all Cypress tests
 | 
			
		||||
      - name: Cypress run
 | 
			
		||||
        id: cypress
 | 
			
		||||
        uses: cypress-io/github-action@v4
 | 
			
		||||
        # If CYPRESS_RECORD_KEY is set, run in parallel on all containers
 | 
			
		||||
        # Otherwise (e.g. if running from fork), we run on a single container only
 | 
			
		||||
        if: ${{ ( env.CYPRESS_RECORD_KEY != '' ) || ( matrix.containers == 1 ) }}
 | 
			
		||||
        with:
 | 
			
		||||
          start: pnpm run dev
 | 
			
		||||
          browser: chrome
 | 
			
		||||
          wait-on: 'http://localhost:9000'
 | 
			
		||||
          # Disable recording if we don't have an API key
 | 
			
		||||
          # e.g. if this action was run from a fork
 | 
			
		||||
@@ -44,3 +57,18 @@ jobs:
 | 
			
		||||
          parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
 | 
			
		||||
        env:
 | 
			
		||||
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
 | 
			
		||||
 | 
			
		||||
      - name: Upload Artifacts
 | 
			
		||||
        uses: actions/upload-artifact@v3
 | 
			
		||||
        if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
 | 
			
		||||
        with:
 | 
			
		||||
          name: error-snapshots
 | 
			
		||||
          path: cypress/snapshots/**/__diff_output__/*
 | 
			
		||||
 | 
			
		||||
      - name: Commit changes
 | 
			
		||||
        uses: EndBug/add-and-commit@v9
 | 
			
		||||
        if: ${{ github.event_name == 'push' }}
 | 
			
		||||
        with:
 | 
			
		||||
          message: 'Update snapshots'
 | 
			
		||||
          add: 'cypress/snapshots/*'
 | 
			
		||||
          pull: '--rebase --autostash'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						@@ -26,7 +26,7 @@ Gemfile.lock
 | 
			
		||||
/.vs
 | 
			
		||||
 | 
			
		||||
cypress/screenshots/
 | 
			
		||||
cypress/snapshots/
 | 
			
		||||
cypress/snapshots-dev/
 | 
			
		||||
 | 
			
		||||
# eslint --cache file
 | 
			
		||||
.eslintcache
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,7 @@
 | 
			
		||||
    "laganeckas",
 | 
			
		||||
    "lintstagedrc",
 | 
			
		||||
    "lucida",
 | 
			
		||||
    "mansalva",
 | 
			
		||||
    "matthieu",
 | 
			
		||||
    "mdbook",
 | 
			
		||||
    "mermerd",
 | 
			
		||||
@@ -76,6 +77,7 @@
 | 
			
		||||
    "shiki",
 | 
			
		||||
    "sidharth",
 | 
			
		||||
    "sphinxcontrib",
 | 
			
		||||
    "ssim",
 | 
			
		||||
    "statediagram",
 | 
			
		||||
    "stylis",
 | 
			
		||||
    "substate",
 | 
			
		||||
 
 | 
			
		||||
@@ -5,9 +5,17 @@ const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin')
 | 
			
		||||
 | 
			
		||||
module.exports = defineConfig({
 | 
			
		||||
  projectId: 'n2sma2',
 | 
			
		||||
  viewportWidth: 1440,
 | 
			
		||||
  viewportHeight: 1024,
 | 
			
		||||
  e2e: {
 | 
			
		||||
    specPattern: 'cypress/integration/**/*.{js,jsx,ts,tsx}',
 | 
			
		||||
    setupNodeEvents(on, config) {
 | 
			
		||||
      on('before:browser:launch', (browser = {}, launchOptions) => {
 | 
			
		||||
        if (browser.name === 'chrome' && browser.isHeadless) {
 | 
			
		||||
          launchOptions.args.push('--window-size=1440,1024', '--force-device-scale-factor=1');
 | 
			
		||||
        }
 | 
			
		||||
        return launchOptions;
 | 
			
		||||
      });
 | 
			
		||||
      addMatchImageSnapshotPlugin(on, config);
 | 
			
		||||
      // copy any needed variables from process.env to config.env
 | 
			
		||||
      config.env.useAppli = process.env.USE_APPLI ? true : false;
 | 
			
		||||
 
 | 
			
		||||
@@ -136,6 +136,5 @@ export const urlSnapshotTest = (url, _options, api = false, validation) => {
 | 
			
		||||
 | 
			
		||||
export const renderGraph = (graphStr, options, api) => {
 | 
			
		||||
  const url = mermaidUrl(graphStr, options, api);
 | 
			
		||||
 | 
			
		||||
  cy.visit(url);
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -117,7 +117,6 @@ describe('Configuration', () => {
 | 
			
		||||
    });
 | 
			
		||||
    it('should not taint the initial configuration when using multiple directives', () => {
 | 
			
		||||
      const url = 'http://localhost:9000/regression/issue-1874.html';
 | 
			
		||||
      cy.viewport(1440, 1024);
 | 
			
		||||
      cy.visit(url);
 | 
			
		||||
 | 
			
		||||
      cy.get('svg');
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,12 @@
 | 
			
		||||
describe('Rerendering', () => {
 | 
			
		||||
  it('should be able to render after an error has occurred', () => {
 | 
			
		||||
    const url = 'http://localhost:9000/render-after-error.html';
 | 
			
		||||
    cy.viewport(1440, 1024);
 | 
			
		||||
    cy.visit(url);
 | 
			
		||||
    cy.get('#graphDiv').should('exist');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should be able to render and rerender a graph via API', () => {
 | 
			
		||||
    const url = 'http://localhost:9000/rerender.html';
 | 
			
		||||
    cy.viewport(1440, 1024);
 | 
			
		||||
    cy.visit(url);
 | 
			
		||||
    cy.get('#graph [id^=flowchart-A]').should('have.text', 'XMas');
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -225,7 +225,10 @@ describe('Gantt diagram', () => {
 | 
			
		||||
      const style = svg.attr('style');
 | 
			
		||||
      expect(style).to.match(/^max-width: [\d.]+px;$/);
 | 
			
		||||
      const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
 | 
			
		||||
      expect(maxWidthValue).to.be.within(984 * 0.95, 984 * 1.05);
 | 
			
		||||
      expect(maxWidthValue).to.be.within(
 | 
			
		||||
        Cypress.config().viewportWidth * 0.95,
 | 
			
		||||
        Cypress.config().viewportWidth * 1.05
 | 
			
		||||
      );
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
@@ -269,7 +272,10 @@ describe('Gantt diagram', () => {
 | 
			
		||||
      const width = parseFloat(svg.attr('width'));
 | 
			
		||||
      // use within because the absolute value can be slightly different depending on the environment ±5%
 | 
			
		||||
      // expect(height).to.be.within(484 * 0.95, 484 * 1.05);
 | 
			
		||||
      expect(width).to.be.within(984 * 0.95, 984 * 1.05);
 | 
			
		||||
      expect(width).to.be.within(
 | 
			
		||||
        Cypress.config().viewportWidth * 0.95,
 | 
			
		||||
        Cypress.config().viewportWidth * 1.05
 | 
			
		||||
      );
 | 
			
		||||
      expect(svg).to.not.have.attr('style');
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,10 @@ describe('Pie Chart', () => {
 | 
			
		||||
      const style = svg.attr('style');
 | 
			
		||||
      expect(style).to.match(/^max-width: [\d.]+px;$/);
 | 
			
		||||
      const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
 | 
			
		||||
      expect(maxWidthValue).to.eq(984);
 | 
			
		||||
      expect(maxWidthValue).to.be.within(
 | 
			
		||||
        Cypress.config().viewportWidth * 0.95,
 | 
			
		||||
        Cypress.config().viewportWidth * 1.05
 | 
			
		||||
      );
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
  it('should render a pie diagram when useMaxWidth is false', () => {
 | 
			
		||||
@@ -68,10 +71,11 @@ describe('Pie Chart', () => {
 | 
			
		||||
      { pie: { useMaxWidth: false } }
 | 
			
		||||
    );
 | 
			
		||||
    cy.get('svg').should((svg) => {
 | 
			
		||||
      // const height = parseFloat(svg.attr('height'));
 | 
			
		||||
      const width = parseFloat(svg.attr('width'));
 | 
			
		||||
      // expect(height).to.eq(450);
 | 
			
		||||
      expect(width).to.eq(984);
 | 
			
		||||
      expect(width).to.be.within(
 | 
			
		||||
        Cypress.config().viewportWidth * 0.95,
 | 
			
		||||
        Cypress.config().viewportWidth * 1.05
 | 
			
		||||
      );
 | 
			
		||||
      expect(svg).to.not.have.attr('style');
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 
 | 
			
		||||
@@ -1,32 +1,8 @@
 | 
			
		||||
<html>
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="utf-8" />
 | 
			
		||||
    <!-- <meta charset="iso-8859-15"/> -->
 | 
			
		||||
    <script src="./viewer.js" type="module"></script>
 | 
			
		||||
    <!-- <link href="https://fonts.googleapis.com/css?family=Mansalva&display=swap" rel="stylesheet" /> -->
 | 
			
		||||
    <link
 | 
			
		||||
      href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
 | 
			
		||||
      rel="stylesheet"
 | 
			
		||||
    />
 | 
			
		||||
    <style>
 | 
			
		||||
      body {
 | 
			
		||||
        /* font-family: 'Mansalva', cursive;*/
 | 
			
		||||
        /* font-family: 'Mansalva', cursive; */
 | 
			
		||||
        /* font-family: 'arial'; */
 | 
			
		||||
        /* font-family: "trebuchet ms", verdana, arial; */
 | 
			
		||||
      }
 | 
			
		||||
      /* div {
 | 
			
		||||
        font-family: 'arial';
 | 
			
		||||
      } */
 | 
			
		||||
      /* .mermaid-main-font {
 | 
			
		||||
        font-family: "trebuchet ms", verdana, arial;
 | 
			
		||||
        font-family: var(--mermaid-font-family);
 | 
			
		||||
      } */
 | 
			
		||||
      /* :root {
 | 
			
		||||
        --mermaid-font-family: '"trebuchet ms", verdana, arial';
 | 
			
		||||
        --mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive;
 | 
			
		||||
        --mermaid-font-family: '"Lucida Console", Monaco, monospace';
 | 
			
		||||
      } */
 | 
			
		||||
      svg {
 | 
			
		||||
        border: 2px solid darkred;
 | 
			
		||||
      }
 | 
			
		||||
@@ -36,21 +12,5 @@
 | 
			
		||||
      }
 | 
			
		||||
    </style>
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <!-- <script src="./mermaid.js"></script> -->
 | 
			
		||||
    <script>
 | 
			
		||||
      // Notice startOnLoad=false
 | 
			
		||||
      // This prevents default handling in mermaid from render before the e2e logic is applied
 | 
			
		||||
      // mermaid.initialize({
 | 
			
		||||
      //   startOnLoad: false,
 | 
			
		||||
      //   useMaxWidth: true,
 | 
			
		||||
      //   // "themeCSS": ":root { --mermaid-font-family: \"trebuchet ms\", verdana, arial;}",
 | 
			
		||||
      //   // fontFamily: '\"trebuchet ms\", verdana, arial;'
 | 
			
		||||
      //   // fontFamily: '"Comic Sans MS", "Comic Sans", cursive'
 | 
			
		||||
      //   // fontFamily: '"Mansalva", cursive',
 | 
			
		||||
      //   // fontFamily: '"Noto Sans SC", sans-serif'
 | 
			
		||||
      //   fontFamily: '"Noto Sans SC", sans-serif'
 | 
			
		||||
      // });
 | 
			
		||||
    </script>
 | 
			
		||||
  </body>
 | 
			
		||||
  <body></body>
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 1.1 KiB  | 
| 
		 After Width: | Height: | Size: 29 KiB  | 
| 
		 After Width: | Height: | Size: 11 KiB  | 
| 
		 After Width: | Height: | Size: 20 KiB  | 
| 
		 After Width: | Height: | Size: 80 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 22 KiB  | 
| 
		 After Width: | Height: | Size: 21 KiB  | 
| 
		 After Width: | Height: | Size: 21 KiB  | 
| 
		 After Width: | Height: | Size: 14 KiB  | 
| 
		 After Width: | Height: | Size: 12 KiB  | 
| 
		 After Width: | Height: | Size: 11 KiB  | 
| 
		 After Width: | Height: | Size: 25 KiB  | 
| 
		 After Width: | Height: | Size: 25 KiB  | 
| 
		 After Width: | Height: | Size: 26 KiB  | 
| 
		 After Width: | Height: | Size: 26 KiB  | 
| 
		 After Width: | Height: | Size: 23 KiB  | 
| 
		 After Width: | Height: | Size: 63 KiB  | 
| 
		 After Width: | Height: | Size: 61 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 26 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 119 KiB  | 
| 
		 After Width: | Height: | Size: 79 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 22 KiB  | 
| 
		 After Width: | Height: | Size: 21 KiB  | 
| 
		 After Width: | Height: | Size: 21 KiB  | 
| 
		 After Width: | Height: | Size: 12 KiB  | 
| 
		 After Width: | Height: | Size: 120 KiB  | 
| 
		 After Width: | Height: | Size: 23 KiB  | 
| 
		 After Width: | Height: | Size: 64 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 61 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 26 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 36 KiB  | 
| 
		 After Width: | Height: | Size: 16 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 16 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 76 KiB  | 
| 
		 After Width: | Height: | Size: 16 KiB  | 
| 
		 After Width: | Height: | Size: 9.5 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 46 KiB  | 
| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 17 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 22 KiB  | 
| 
		 After Width: | Height: | Size: 31 KiB  | 
| 
		 After Width: | Height: | Size: 12 KiB  | 
| 
		 After Width: | Height: | Size: 30 KiB  | 
| 
		 After Width: | Height: | Size: 14 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 12 KiB  | 
| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
		 After Width: | Height: | Size: 29 KiB  | 
| 
		 After Width: | Height: | Size: 13 KiB  | 
| 
		 After Width: | Height: | Size: 9.5 KiB  | 
| 
		 After Width: | Height: | Size: 9.5 KiB  | 
| 
		 After Width: | Height: | Size: 11 KiB  | 
| 
		 After Width: | Height: | Size: 31 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 32 KiB  | 
| 
		 After Width: | Height: | Size: 20 KiB  | 
| 
		 After Width: | Height: | Size: 9.5 KiB  | 
| 
		 After Width: | Height: | Size: 32 KiB  | 
| 
		 After Width: | Height: | Size: 11 KiB  | 
| 
		 After Width: | Height: | Size: 19 KiB  | 
| 
		 After Width: | Height: | Size: 9.5 KiB  | 
| 
		 After Width: | Height: | Size: 70 KiB  | 
| 
		 After Width: | Height: | Size: 9.9 KiB  | 
| 
		 After Width: | Height: | Size: 34 KiB  | 
| 
		 After Width: | Height: | Size: 10 KiB  |