2023-07-07 17:21:18 +05:30
|
|
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
2020-04-04 16:38:30 +01:00
|
|
|
|
|
|
|
describe('User journey diagram', () => {
|
|
|
|
it('Simple test', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`journey
|
|
|
|
title Adding journey diagram functionality to mermaid
|
|
|
|
section Order from website
|
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a user journey chart', () => {
|
|
|
|
imgSnapshotTest(
|
|
|
|
`
|
|
|
|
journey
|
2020-04-28 08:28:16 +01:00
|
|
|
title My working day
|
|
|
|
section Go to work
|
|
|
|
Make tea: 5: Me
|
|
|
|
Go upstairs: 3: Me
|
|
|
|
Do work: 1: Me, Cat
|
|
|
|
section Go home
|
|
|
|
Go downstairs: 5: Me
|
|
|
|
Sit down: 3: Me
|
2020-04-04 16:38:30 +01:00
|
|
|
`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
});
|
2020-08-25 17:05:01 +02:00
|
|
|
|
|
|
|
it('should render a user journey diagram when useMaxWidth is true (default)', () => {
|
|
|
|
renderGraph(
|
|
|
|
`journey
|
2021-04-25 10:59:01 +02:00
|
|
|
title E-Commerce
|
2020-08-25 17:05:01 +02:00
|
|
|
section Order from website
|
2021-04-25 10:59:01 +02:00
|
|
|
Add to cart: 5: Me
|
|
|
|
section Checkout from website
|
|
|
|
Add payment details: 5: Me
|
2020-08-25 17:05:01 +02:00
|
|
|
`,
|
|
|
|
{ journey: { useMaxWidth: true } }
|
|
|
|
);
|
2021-11-18 19:17:00 +01:00
|
|
|
cy.get('svg').should((svg) => {
|
|
|
|
expect(svg).to.have.attr('width', '100%');
|
|
|
|
expect(svg).to.have.attr('height');
|
2022-08-28 11:25:09 +02:00
|
|
|
// const height = parseFloat(svg.attr('height'));
|
|
|
|
// expect(height).to.eq(565);
|
2021-11-18 19:17:00 +01:00
|
|
|
const style = svg.attr('style');
|
|
|
|
expect(style).to.match(/^max-width: [\d.]+px;$/);
|
|
|
|
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join(''));
|
|
|
|
expect(maxWidthValue).to.eq(700);
|
|
|
|
});
|
2020-08-25 17:05:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a user journey diagram when useMaxWidth is false', () => {
|
2021-04-25 12:27:51 +02:00
|
|
|
imgSnapshotTest(
|
2020-08-25 17:05:01 +02:00
|
|
|
`journey
|
2021-04-25 10:59:01 +02:00
|
|
|
title E-Commerce
|
2020-08-25 17:05:01 +02:00
|
|
|
section Order from website
|
2021-04-25 10:59:01 +02:00
|
|
|
Add to cart: 5: Me
|
|
|
|
section Checkout from website
|
|
|
|
Add payment details: 5: Me
|
2020-08-25 17:05:01 +02:00
|
|
|
`,
|
|
|
|
{ journey: { useMaxWidth: false } }
|
|
|
|
);
|
|
|
|
});
|
2020-04-04 16:38:30 +01:00
|
|
|
});
|