mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
feat: add hideUnusedParticipants and some cleanup
This commit is contained in:
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
@@ -38,21 +38,3 @@ jobs:
|
||||
- name: Run Unit Tests
|
||||
run: |
|
||||
yarn test --coverage
|
||||
|
||||
#- name: Upload Test Results
|
||||
# uses: coverallsapp/github-action@v1.0.1
|
||||
# with:
|
||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# parallel: true
|
||||
|
||||
# - name: Run E2E Tests
|
||||
# run: yarn e2e
|
||||
# env:
|
||||
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
|
||||
# CYPRESS_CACHE_FOLDER: .cache/Cypress
|
||||
|
||||
#- name: Post Upload Test Results
|
||||
# uses: coverallsapp/github-action@master
|
||||
# with:
|
||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# parallel-finished: true
|
||||
|
@@ -16,4 +16,3 @@ jobs:
|
||||
tests: "./cypress/integration/**/**.spec.js"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
has-tests-label: true
|
||||
|
17
.github/workflows/e2e
vendored
17
.github/workflows/e2e
vendored
@@ -29,24 +29,7 @@ jobs:
|
||||
- name: Run Build
|
||||
run: yarn build
|
||||
|
||||
# - name: Run e2e Tests
|
||||
# run: |
|
||||
# yarn e2e
|
||||
|
||||
#- name: Upload Test Results
|
||||
# uses: coverallsapp/github-action@v1.0.1
|
||||
# with:
|
||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# parallel: true
|
||||
|
||||
- name: Run E2E Tests
|
||||
run: yarn e2e
|
||||
env:
|
||||
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
|
||||
CYPRESS_CACHE_FOLDER: .cache/Cypress
|
||||
|
||||
#- name: Post Upload Test Results
|
||||
# uses: coverallsapp/github-action@master
|
||||
# with:
|
||||
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# parallel-finished: true
|
||||
|
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
@@ -18,7 +18,7 @@ export const mermaidUrl = (graphStr, options, api) => {
|
||||
return url;
|
||||
};
|
||||
|
||||
export const imgSnapshotTest = (graphStr, _options, api) => {
|
||||
export const imgSnapshotTest = (graphStr, _options, api = false, validation) => {
|
||||
cy.log(_options);
|
||||
const options = Object.assign(_options);
|
||||
if (!options.fontFamily) {
|
||||
@@ -46,8 +46,8 @@ export const imgSnapshotTest = (graphStr, _options, api) => {
|
||||
const url = mermaidUrl(graphStr, options, api);
|
||||
|
||||
cy.visit(url);
|
||||
if (validation) cy.get('svg').should(validation);
|
||||
cy.get('svg');
|
||||
// cy.percySnapshot();
|
||||
// Default name to test title
|
||||
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||
|
||||
|
@@ -110,10 +110,11 @@ describe('Configuration', () => {
|
||||
cy.viewport(1440, 1024);
|
||||
cy.visit(url);
|
||||
|
||||
cy.get('svg');
|
||||
cy.matchImageSnapshot(
|
||||
'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
|
||||
);
|
||||
cy.get('svg').then((svgs) => {
|
||||
svgs[0].matchImageSnapshot(
|
||||
'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -610,6 +610,22 @@ context('Sequence diagram', () => {
|
||||
}
|
||||
);
|
||||
});
|
||||
it("shouldn't display unused participants", () => {
|
||||
//Be aware that the syntax for "properties" is likely to be changed.
|
||||
imgSnapshotTest(
|
||||
`
|
||||
%%{init: { "config": { "hideUnusedParticipants": true }}}%%
|
||||
sequenceDiagram
|
||||
participant a
|
||||
`,
|
||||
{
|
||||
logLevel: 0,
|
||||
sequence: { mirrorActors: false, noteFontSize: 18, noteFontFamily: 'Arial' },
|
||||
},
|
||||
false,
|
||||
(svg) => expect(svg.get('rect')).to.be.empty()
|
||||
);
|
||||
});
|
||||
});
|
||||
context('svg size', () => {
|
||||
it('should render a sequence diagram when useMaxWidth is true (default)', () => {
|
||||
|
21
dist/mermaid.core.js
vendored
21
dist/mermaid.core.js
vendored
@@ -22746,8 +22746,19 @@ var drawMessage = function drawMessage(diagram, msgModel, lineStarty) {
|
||||
}
|
||||
};
|
||||
|
||||
var drawActors = function drawActors(diagram, actors, actorKeys, verticalPos) {
|
||||
// Draw the actors
|
||||
var drawActors = function drawActors(diagram, actors, actorKeys, verticalPos, configuration, messages) {
|
||||
if (configuration.hideUnusedParticipants === true) {
|
||||
var newActors = new Set();
|
||||
messages.forEach(function (message) {
|
||||
newActors.add(message.from);
|
||||
newActors.add(message.to);
|
||||
});
|
||||
actorKeys = actorKeys.filter(function (actorKey) {
|
||||
return newActors.includes(actorKey);
|
||||
});
|
||||
} // Draw the actors
|
||||
|
||||
|
||||
var prevWidth = 0;
|
||||
var prevMargin = 0;
|
||||
var maxHeight = 0;
|
||||
@@ -22894,7 +22905,7 @@ var draw = function draw(text, id) {
|
||||
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].insertComputerIcon(diagram);
|
||||
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].insertDatabaseIcon(diagram);
|
||||
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].insertClockIcon(diagram);
|
||||
drawActors(diagram, actors, actorKeys, 0);
|
||||
drawActors(diagram, actors, actorKeys, 0, conf, messages);
|
||||
var loopWidths = calculateLoopBounds(messages, actors, maxMessageWidthPerActor); // The arrow head definition is attached to the svg once
|
||||
|
||||
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].insertArrowHead(diagram);
|
||||
@@ -23045,7 +23056,7 @@ var draw = function draw(text, id) {
|
||||
if (conf.mirrorActors) {
|
||||
// Draw actors below diagram
|
||||
bounds.bumpVerticalPos(conf.boxMargin * 2);
|
||||
drawActors(diagram, actors, actorKeys, bounds.getVerticalPos());
|
||||
drawActors(diagram, actors, actorKeys, bounds.getVerticalPos(), conf, messages);
|
||||
bounds.bumpVerticalPos(conf.boxMargin);
|
||||
(0,_svgDraw__WEBPACK_IMPORTED_MODULE_3__.fixLifeLineHeights)(diagram, bounds.getVerticalPos());
|
||||
} // only draw popups for the top row of actors.
|
||||
@@ -31655,7 +31666,7 @@ module.exports = require("stylis");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = JSON.parse('{"name":"mermaid","version":"9.0.0","description":"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.","main":"dist/mermaid.core.js","module":"dist/mermaid.esm.min.mjs","exports":{".":{"require":"./dist/mermaid.core.js","import":"./dist/mermaid.esm.min.mjs"},"./*":"./*"},"keywords":["diagram","markdown","flowchart","sequence diagram","gantt","class diagram","git graph"],"scripts":{"build:development":"webpack --mode development --progress --color","build:production":"webpack --mode production --progress --color","build":"concurrently \\"yarn build:development\\" \\"yarn build:production\\"","postbuild":"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md","build:watch":"yarn build:development --watch","release":"yarn build","lint":"eslint ./ --ext js,html","lint:fix":"yarn lint --fix","e2e:depr":"yarn lint && jest e2e --config e2e/jest.config.js","cypress":"cypress run","e2e":"start-server-and-test dev http://localhost:9000/ cypress","e2e-upd":"yarn lint && jest e2e -u --config e2e/jest.config.js","dev":"webpack serve --config ./.webpack/webpack.config.e2e.babel.js","test":"yarn lint && jest src/.*","test:watch":"jest --watch src","prepublishOnly":"yarn build && yarn test","prepare":"husky install && yarn build","pre-commit":"lint-staged"},"repository":{"type":"git","url":"https://github.com/knsv/mermaid"},"author":"Knut Sveidqvist","license":"MIT","standard":{"ignore":["**/parser/*.js","dist/**/*.js","cypress/**/*.js"],"globals":["page"]},"dependencies":{"@braintree/sanitize-url":"^6.0.0","cypress-image-snapshot":"^4.0.1","d3":"^7.0.0","dagre":"^0.8.5","dagre-d3":"^0.6.4","dompurify":"2.3.6","graphlib":"^2.1.8","khroma":"^1.4.1","moment-mini":"^2.24.0","stylis":"^4.0.10"},"devDependencies":{"@babel/core":"^7.14.6","@babel/eslint-parser":"^7.14.7","@babel/preset-env":"^7.14.7","@babel/register":"^7.14.5","@commitlint/cli":"^16.0.0","@commitlint/config-conventional":"^16.0.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","concurrently":"^7.0.0","coveralls":"^3.0.2","css-to-string-loader":"^0.1.3","cypress":"9.5.3","documentation":"13.2.0","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-html":"^6.2.0","eslint-plugin-jest":"^26.0.0","eslint-plugin-jsdoc":"^39.1.0","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","husky":"^7.0.1","identity-obj-proxy":"^3.0.0","jest":"^27.0.6","jison":"^0.4.18","js-base64":"3.7.2","lint-staged":"^12.1.2","moment":"^2.23.0","path-browserify":"^1.0.1","prettier":"^2.3.2","prettier-plugin-jsdoc":"^0.3.30","start-server-and-test":"^1.12.6","terser-webpack-plugin":"^5.2.4","webpack":"^5.53.0","webpack-cli":"^4.7.2","webpack-dev-server":"^4.3.0","webpack-merge":"^5.8.0","webpack-node-externals":"^3.0.0"},"files":["dist"],"sideEffects":["**/*.css","**/*.scss"]}');
|
||||
module.exports = JSON.parse('{"name":"mermaid","version":"9.0.0","description":"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.","main":"dist/mermaid.core.js","module":"dist/mermaid.esm.min.mjs","exports":{".":{"require":"./dist/mermaid.core.js","import":"./dist/mermaid.esm.min.mjs"},"./*":"./*"},"keywords":["diagram","markdown","flowchart","sequence diagram","gantt","class diagram","git graph"],"scripts":{"build:development":"webpack --mode development --progress --color","build:production":"webpack --mode production --progress --color","build":"concurrently \\"yarn build:development\\" \\"yarn build:production\\"","postbuild":"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md","build:watch":"yarn build:development --watch","release":"yarn build","lint":"eslint ./ --ext js,html","lint:fix":"yarn lint --fix","e2e:depr":"yarn lint && jest e2e --config e2e/jest.config.js","cypress":"cypress run","e2e":"start-server-and-test dev http://localhost:9000/ cypress","e2e-upd":"yarn lint && jest e2e -u --config e2e/jest.config.js","dev":"webpack serve --config ./.webpack/webpack.config.e2e.babel.js","test":"yarn lint && jest src/.*","test:watch":"jest --watch src","prepublishOnly":"yarn build && yarn test","prepare":"husky install && yarn build","pre-commit":"lint-staged"},"repository":{"type":"git","url":"https://github.com/knsv/mermaid"},"author":"Knut Sveidqvist","license":"MIT","standard":{"ignore":["**/parser/*.js","dist/**/*.js","cypress/**/*.js"],"globals":["page"]},"dependencies":{"@braintree/sanitize-url":"^6.0.0","d3":"^7.0.0","dagre":"^0.8.5","dagre-d3":"^0.6.4","dompurify":"2.3.6","graphlib":"^2.1.8","khroma":"^1.4.1","moment-mini":"^2.24.0","stylis":"^4.0.10"},"devDependencies":{"@babel/core":"^7.14.6","@babel/eslint-parser":"^7.14.7","@babel/preset-env":"^7.14.7","@babel/register":"^7.14.5","@commitlint/cli":"^16.0.0","@commitlint/config-conventional":"^16.0.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","concurrently":"^7.0.0","coveralls":"^3.0.2","css-to-string-loader":"^0.1.3","cypress":"9.5.3","cypress-image-snapshot":"^4.0.1","documentation":"13.2.0","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-html":"^6.2.0","eslint-plugin-jest":"^26.0.0","eslint-plugin-jsdoc":"^39.1.0","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","husky":"^7.0.1","identity-obj-proxy":"^3.0.0","jest":"^27.0.6","jison":"^0.4.18","js-base64":"3.7.2","lint-staged":"^12.1.2","moment":"^2.23.0","path-browserify":"^1.0.1","prettier":"^2.3.2","prettier-plugin-jsdoc":"^0.3.30","start-server-and-test":"^1.12.6","terser-webpack-plugin":"^5.2.4","webpack":"^5.53.0","webpack-cli":"^4.7.2","webpack-dev-server":"^4.3.0","webpack-merge":"^5.8.0","webpack-node-externals":"^3.0.0"},"files":["dist"],"sideEffects":["**/*.css","**/*.scss"]}');
|
||||
|
||||
/***/ })
|
||||
|
||||
|
2
dist/mermaid.core.js.map
vendored
2
dist/mermaid.core.js.map
vendored
File diff suppressed because one or more lines are too long
3339
dist/mermaid.js
vendored
3339
dist/mermaid.js
vendored
File diff suppressed because it is too large
Load Diff
2
dist/mermaid.js.map
vendored
2
dist/mermaid.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -3,8 +3,6 @@ import { log } from './logger';
|
||||
import theme from './themes';
|
||||
import config from './defaultConfig';
|
||||
|
||||
// debugger;
|
||||
|
||||
export const defaultConfig = Object.freeze(config);
|
||||
|
||||
let siteConfig = assignWithDepth({}, defaultConfig);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { intersection } from './edges';
|
||||
import { setLogLevel, log } from '../logger';
|
||||
import { setLogLevel } from '../logger';
|
||||
|
||||
describe('Graphlib decorations', () => {
|
||||
let node;
|
||||
|
@@ -447,7 +447,23 @@ const drawMessage = function (diagram, msgModel, lineStarty) {
|
||||
}
|
||||
};
|
||||
|
||||
export const drawActors = function (diagram, actors, actorKeys, verticalPos) {
|
||||
export const drawActors = function (
|
||||
diagram,
|
||||
actors,
|
||||
actorKeys,
|
||||
verticalPos,
|
||||
configuration,
|
||||
messages
|
||||
) {
|
||||
if (configuration.hideUnusedParticipants === true) {
|
||||
const newActors = new Set();
|
||||
messages.forEach((message) => {
|
||||
newActors.add(message.from);
|
||||
newActors.add(message.to);
|
||||
});
|
||||
actorKeys = actorKeys.filter((actorKey) => newActors.includes(actorKey));
|
||||
}
|
||||
|
||||
// Draw the actors
|
||||
let prevWidth = 0;
|
||||
let prevMargin = 0;
|
||||
@@ -605,7 +621,7 @@ export const draw = function (text, id) {
|
||||
svgDraw.insertDatabaseIcon(diagram);
|
||||
svgDraw.insertClockIcon(diagram);
|
||||
|
||||
drawActors(diagram, actors, actorKeys, 0);
|
||||
drawActors(diagram, actors, actorKeys, 0, conf, messages);
|
||||
const loopWidths = calculateLoopBounds(messages, actors, maxMessageWidthPerActor);
|
||||
|
||||
// The arrow head definition is attached to the svg once
|
||||
@@ -777,7 +793,7 @@ export const draw = function (text, id) {
|
||||
if (conf.mirrorActors) {
|
||||
// Draw actors below diagram
|
||||
bounds.bumpVerticalPos(conf.boxMargin * 2);
|
||||
drawActors(diagram, actors, actorKeys, bounds.getVerticalPos());
|
||||
drawActors(diagram, actors, actorKeys, bounds.getVerticalPos(), conf, messages);
|
||||
bounds.bumpVerticalPos(conf.boxMargin);
|
||||
fixLifeLineHeights(diagram, bounds.getVerticalPos());
|
||||
}
|
||||
|
Reference in New Issue
Block a user