Merge branch 'feature/hideUnusedParticipants_1210' into develop

This commit is contained in:
ashishj
2022-04-28 17:40:39 +02:00
14 changed files with 41228 additions and 26375 deletions

View File

@@ -41,21 +41,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

View File

@@ -16,4 +16,3 @@ jobs:
tests: "./cypress/integration/**/**.spec.js"
token: ${{ secrets.GITHUB_TOKEN }}
has-tests-label: true

17
.github/workflows/e2e vendored
View File

@@ -32,24 +32,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

View File

@@ -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"
}

View File

@@ -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, '-');

View File

@@ -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'
);
});
});
});
});

View File

@@ -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)', () => {

5343
dist/mermaid.core.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

62160
dist/mermaid.js vendored

File diff suppressed because it is too large Load Diff

2
dist/mermaid.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -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);

View File

@@ -1,5 +1,5 @@
import { intersection } from './edges';
import { setLogLevel, log } from '../logger';
import { setLogLevel } from '../logger';
describe('Graphlib decorations', () => {
let node;

View File

@@ -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
@@ -785,7 +801,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());
}