Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6262 - Fixed faces positioning in journey diagram #6263

Draft
wants to merge 33 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1e2a1b6
Added alert and capped face's height stay max 300
monicanguyen25 Feb 7, 2025
7a4c74e
Added cypress test for journey alert (task>5)
monicanguyen25 Feb 7, 2025
018358a
Added constraint to accept only string and 0-5 values
monicanguyen25 Feb 12, 2025
aeb0604
Added test cases and removed clamping for cy value
monicanguyen25 Feb 13, 2025
231a8a0
revsied testing for user-journey task score validation
udvale Feb 14, 2025
76d5014
fixed some changes on test (deleted an unused import)
udvale Feb 14, 2025
690bd9c
Fixed typo
monicanguyen25 Feb 14, 2025
221474e
Merge branch 'mermaid-js:develop' into bug/6262_faces-position-in-jou…
monicanguyen25 Feb 14, 2025
2f4aea5
Merge branch 'mermaid-js:develop' into bug/6262_faces-position-in-jou…
monicanguyen25 Feb 18, 2025
dad10da
Merge branch 'develop' of https://github.com/Shahir-47/mermaid into b…
udvale Feb 18, 2025
b95d929
Merge branch 'bug/6262_faces-position-in-journey-diagram' of https://…
udvale Feb 18, 2025
be5de99
added score constraint in user journey diagram documentation
udvale Feb 18, 2025
792ce16
Added documentation for input constraint
udvale Feb 18, 2025
51d0429
attempt to fix linting issue
udvale Feb 18, 2025
10505ac
Merge branch 'develop' of https://github.com/Shahir-47/mermaid into b…
udvale Feb 19, 2025
c3115ad
docs: update references to @types/node version in UnknownDiagramError…
udvale Feb 19, 2025
ca3263e
Added alert and capped face's height stay max 300
monicanguyen25 Feb 7, 2025
fc63f6e
Added cypress test for journey alert (task>5)
monicanguyen25 Feb 7, 2025
38af98f
Added constraint to accept only string and 0-5 values
monicanguyen25 Feb 12, 2025
cbaf6c2
Added test cases and removed clamping for cy value
monicanguyen25 Feb 13, 2025
563e165
revsied testing for user-journey task score validation
udvale Feb 14, 2025
656123a
fixed some changes on test (deleted an unused import)
udvale Feb 14, 2025
a9dcbd9
Fixed typo
monicanguyen25 Feb 14, 2025
c7b4214
added score constraint in user journey diagram documentation
udvale Feb 18, 2025
af1b954
Added documentation for input constraint
udvale Feb 18, 2025
c67854c
Merge branch 'bug/6262_faces-position-in-journey-diagram' of https://…
udvale Feb 19, 2025
61ab53f
Merge branch 'develop' into bug/6262_faces-position-in-journey-diagram
Shahir-47 Feb 20, 2025
09df269
Update UnknownDiagramError documentation to reflect changes in node t…
Shahir-47 Feb 20, 2025
b8011bd
Added input constraint for task score in journey diagram documentation.
udvale Feb 21, 2025
cc87802
Merge branch 'bug/6262_faces-position-in-journey-diagram' of https://…
udvale Feb 21, 2025
885e61f
Revert changes in simple tests part of journey.spec.js
udvale Feb 26, 2025
e66ce3c
Refactor tests to replace time-based waits with event-based waits
udvale Feb 26, 2025
94a01e8
Merge branch 'develop' into bug/6262_faces-position-in-journey-diagram
udvale Mar 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions cypress/integration/rendering/journey.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,108 @@ section Checkout from website
);
});
});

describe('User journey diagram task score behavior validation', () => {
it('should throw an error if the task score is non-integer', () => {
let errorCaught = false;

cy.once('uncaught:exception', () => {
errorCaught = true;
return false;
});

renderGraph(`
journey
accTitle: simple journey demo
accDescr: 2 main sections: work and home, each with just a few tasks

section Go to work
Make tea: Hello: Me
Go upstairs: 3: Me
section Go home
Go downstairs: 5: Me
Sit down: 2: Me
`);

cy.get('svg')
.should('exist')
.then(() => {
expect(errorCaught, 'Error should be thrown for a non-integer score').to.equal(true);
});
});

it('should throw an error if the task score is less than 0', () => {
let errorCaught = false;

cy.once('uncaught:exception', () => {
errorCaught = true;
return false;
});

renderGraph(`
journey
section Go to work
Make tea: -10: Me
Go upstairs: 3: Me
section Go home
Go downstairs: 5: Me
Sit down: 2: Me
`);

cy.get('svg')
.should('exist')
.then(() => {
expect(errorCaught, 'Error should be thrown for a non-integer score').to.equal(true);
});
});

it('should throw an error if the task score is greater than 5', () => {
let errorCaught = false;

cy.once('uncaught:exception', () => {
errorCaught = true;
return false;
});

renderGraph(`
journey
section Go to work
Make tea: 23: Me
Go upstairs: 3: Me
section Go home
Go downstairs: 5: Me
Sit down: 2: Me
`);

cy.get('svg')
.should('exist')
.then(() => {
expect(errorCaught, 'Error should be thrown for a non-integer score').to.equal(true);
});
});

it('should NOT throw an error if the task score is valid (e.g., 4)', () => {
let errorCaught = false;

cy.once('uncaught:exception', () => {
errorCaught = true;
return false;
});

renderGraph(`
journey
section Go to work
Make tea: 4: Me
Go upstairs: 3: Me
section Go home
Go downstairs: 5: Me
Sit down: 2: Me
`);

cy.get('svg')
.should('exist')
.then(() => {
expect(errorCaught, 'Error should be thrown for a non-integer score').to.equal(false);
});
});
});
2 changes: 2 additions & 0 deletions docs/syntax/userJourney.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Each user journey is split into sections, these describe the part of the task
the user is trying to complete.

Tasks syntax is `Task name: <score>: <comma separated list of actors>`

**Input Constraint for Task Score:** The score must be an integer between **0** and **5**.
5 changes: 5 additions & 0 deletions packages/mermaid/src/diagrams/user-journey/svgDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export const drawTask = function (elem, task, conf) {
.attr('stroke-dasharray', '4 2')
.attr('stroke', '#666');

// Check if the score exceeds the max limit and show alert
if (!Number.isInteger(task.score) || task.score > 5 || task.score < 0) {
throw new Error('Score must be an integer between 0 and 5');
}

drawFace(g, {
cx: center,
cy: 300 + (5 - task.score) * 30,
Expand Down
2 changes: 2 additions & 0 deletions packages/mermaid/src/docs/syntax/userJourney.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ Each user journey is split into sections, these describe the part of the task
the user is trying to complete.

Tasks syntax is `Task name: <score>: <comma separated list of actors>`

**Input Constraint for Task Score:** The score must be an integer between **0** and **5**.
Loading