#2315 Fix for broken tests

This commit is contained in:
Knut Sveidqvist 2021-09-18 10:05:53 +02:00
parent 0fcabfae05
commit 432267c811
3 changed files with 40 additions and 38 deletions

View File

@ -33,7 +33,7 @@ export const addActor = function (id, name, description, type) {
description: description.text, description: description.text,
wrap: (description.wrap === undefined && autoWrap()) || !!description.wrap, wrap: (description.wrap === undefined && autoWrap()) || !!description.wrap,
prevActor: prevActor, prevActor: prevActor,
type: type || 'participant' type: type || 'participant',
}; };
if (prevActor && actors[prevActor]) { if (prevActor && actors[prevActor]) {
actors[prevActor].nextActor = id; actors[prevActor].nextActor = id;

View File

@ -1501,7 +1501,7 @@ participant Alice`;
expect(bounds.startx).toBe(0); expect(bounds.startx).toBe(0);
expect(bounds.starty).toBe(0); expect(bounds.starty).toBe(0);
expect(bounds.stopx).toBe(conf.width); expect(bounds.stopx).toBe(conf.width);
expect(bounds.stopy).toBe(models.lastActor().y + models.lastActor().height); expect(bounds.stopy).toBe(models.lastActor().y + models.lastActor().height + conf.boxMargin);
}); });
}); });
}); });
@ -1550,7 +1550,7 @@ participant Alice
expect(bounds.startx).toBe(0); expect(bounds.startx).toBe(0);
expect(bounds.startx).toBe(0); expect(bounds.startx).toBe(0);
expect(bounds.starty).toBe(0); expect(bounds.starty).toBe(0);
expect(bounds.stopy).toBe(models.lastActor().y + models.lastActor().height); expect(bounds.stopy).toBe(models.lastActor().y + models.lastActor().height + mermaid.sequence.boxMargin);
}); });
it('it should handle one actor, when logLevel is 3', function() { it('it should handle one actor, when logLevel is 3', function() {
const str = ` const str = `
@ -1568,6 +1568,6 @@ participant Alice
expect(bounds.startx).toBe(0); expect(bounds.startx).toBe(0);
expect(bounds.startx).toBe(0); expect(bounds.startx).toBe(0);
expect(bounds.starty).toBe(0); expect(bounds.starty).toBe(0);
expect(bounds.stopy).toBe(models.lastActor().y + models.lastActor().height); expect(bounds.stopy).toBe(models.lastActor().y + models.lastActor().height + mermaid.sequence.boxMargin);
}); });
}); });

View File

@ -183,12 +183,11 @@ export const drawLabel = function (elem, txtObject) {
let actorCnt = -1; let actorCnt = -1;
export const fixLifeLineHeights = (diagram, bounds) => { export const fixLifeLineHeights = (diagram, bounds) => {
console.log('fixLifeLineHeights', diagram, bounds); if (!diagram.selectAll) return;
diagram diagram
.selectAll(".actor-line") .selectAll('.actor-line')
.attr("class", "200") // .attr('class', '200')
.attr("y2", bounds-55) // .attr('y2', bounds - 55);
}; };
/** /**
@ -236,19 +235,22 @@ const drawActorTypeParticipant = function (elem, actor, conf) {
conf conf
); );
let height = actor.height;
if (rectElem.node) {
const bounds = rectElem.node().getBBox(); const bounds = rectElem.node().getBBox();
actor.height = bounds.height; actor.height = bounds.height;
console.log('Height = ',bounds.height) height = bounds.height;
return bounds.height; }
return height;
}; };
const drawActorTypeActor = function (elem, actor, conf) { const drawActorTypeActor = function (elem, actor, conf) {
const center = actor.x + actor.width / 2; const center = actor.x + actor.width / 2;
if (actor.y === 0) { if (actor.y === 0) {
actorCnt++; actorCnt++;
elem.append('line') elem
.append('line')
.attr('id', 'actor' + actorCnt) .attr('id', 'actor' + actorCnt)
.attr('x1', center) .attr('x1', center)
.attr('y1', 80) .attr('y1', 80)
@ -272,44 +274,44 @@ const drawActorTypeActor = function (elem, actor, conf) {
rect.ry = 3; rect.ry = 3;
// drawRect(actElem, rect); // drawRect(actElem, rect);
actElem.append('line') actElem
.append('line')
.attr('id', 'actor-man-torso' + actorCnt) .attr('id', 'actor-man-torso' + actorCnt)
.attr('x1', center) .attr('x1', center)
.attr('y1', actor.y+25) .attr('y1', actor.y + 25)
.attr('x2', center) .attr('x2', center)
.attr('y2', actor.y+45); .attr('y2', actor.y + 45);
actElem.append('line') actElem
.append('line')
.attr('id', 'actor-man-arms' + actorCnt) .attr('id', 'actor-man-arms' + actorCnt)
.attr('x1', center-18) .attr('x1', center - 18)
.attr('y1', actor.y + 33) .attr('y1', actor.y + 33)
.attr('x2', center+18) .attr('x2', center + 18)
.attr('y2', actor.y + 33); .attr('y2', actor.y + 33);
actElem.append('line') actElem
.attr('x1', center-18) .append('line')
.attr('x1', center - 18)
.attr('y1', actor.y + 60) .attr('y1', actor.y + 60)
.attr('x2', center) .attr('x2', center)
.attr('y2', actor.y + 45); .attr('y2', actor.y + 45);
actElem.append('line') actElem
.append('line')
.attr('x1', center) .attr('x1', center)
.attr('y1', actor.y + 45) .attr('y1', actor.y + 45)
.attr('x2', center+16) .attr('x2', center + 16)
.attr('y2', actor.y + 60); .attr('y2', actor.y + 60);
const circle = actElem.append('circle'); const circle = actElem.append('circle');
circle.attr('cx', actor.x + actor.width/2); circle.attr('cx', actor.x + actor.width / 2);
circle.attr('cy', actor.y+10); circle.attr('cy', actor.y + 10);
circle.attr('r', 15); circle.attr('r', 15);
circle.attr('width', actor.width); circle.attr('width', actor.width);
circle.attr('height', actor.height); circle.attr('height', actor.height);
// circle.attr('rx', rectData.rx);
// circle.attr('ry', rectData.ry);
const bounds = actElem.node().getBBox(); const bounds = actElem.node().getBBox();
actor.height = bounds.height; actor.height = bounds.height;
_drawTextCandidateFunc(conf)( _drawTextCandidateFunc(conf)(
actor.description, actor.description,
actElem, actElem,
@ -325,7 +327,7 @@ const drawActorTypeActor = function (elem, actor, conf) {
}; };
export const drawActor = function (elem, actor, conf) { export const drawActor = function (elem, actor, conf) {
switch(actor.type) { switch (actor.type) {
case 'actor': case 'actor':
return drawActorTypeActor(elem, actor, conf); return drawActorTypeActor(elem, actor, conf);
case 'participant': case 'participant':