From a318ea3692f19dba3aa5b20aa2fed2d57bbc75b2 Mon Sep 17 00:00:00 2001 From: Shahir Ahmed Date: Fri, 21 Feb 2025 16:15:24 -0500 Subject: [PATCH] removes cy.then and magic value Co-authored-by: Pranav Mishra --- cypress/integration/rendering/journey.spec.js | 10 ++++------ .../src/diagrams/user-journey/journeyRenderer.ts | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cypress/integration/rendering/journey.spec.js b/cypress/integration/rendering/journey.spec.js index a30b65b84..a7e280ab2 100644 --- a/cypress/integration/rendering/journey.spec.js +++ b/cypress/integration/rendering/journey.spec.js @@ -103,9 +103,8 @@ section Checkout from website }); it('should maintain sufficient space between legend and diagram when legend labels are longer', () => { - cy.then(() => { - renderGraph( - `journey + renderGraph( + `journey title Web hook life cycle section Darkoob Make preBuilt:5: Darkoob user @@ -119,9 +118,8 @@ section Checkout from website check for inputs : 5 : DarkoobAPI run the prebuilt job : 5 : DarkoobAPI `, - { journey: { useMaxWidth: true } } - ); - }); + { journey: { useMaxWidth: true } } + ); let LabelEndX, diagramStartX; diff --git a/packages/mermaid/src/diagrams/user-journey/journeyRenderer.ts b/packages/mermaid/src/diagrams/user-journey/journeyRenderer.ts index a9dee0546..06c6cdeea 100644 --- a/packages/mermaid/src/diagrams/user-journey/journeyRenderer.ts +++ b/packages/mermaid/src/diagrams/user-journey/journeyRenderer.ts @@ -44,7 +44,7 @@ function drawActorLegend(diagram) { const textElement = svgDraw.drawText(diagram, labelData); const textLength = textElement.node().getBBox().width; - if (textLength > maxWidth) { + if (textLength > maxWidth && textLength > conf?.leftMargin) { maxWidth = textLength; } yPos += 20; @@ -90,7 +90,7 @@ export const draw = function (text, id, version, diagObj) { }); drawActorLegend(diagram); - leftMargin = conf.leftMargin + maxWidth - 22.328125; + leftMargin = conf.leftMargin + maxWidth; bounds.insert(0, 0, leftMargin, Object.keys(actors).length * 50); drawTasks(diagram, tasks, 0);