Added E2E testing for spacing

This adds E2E testing for spacing and provides more appropriate comments for the changes made to `index.js`
This commit is contained in:
rowanfr 2024-02-28 17:12:20 -06:00
parent 5935e277e6
commit 3602191f69
2 changed files with 24 additions and 2 deletions

View File

@ -760,6 +760,28 @@ A ~~~ B
);
});
it('3258: Should render subgraphs with main graph nodeSpacing and rankSpacing', () => {
imgSnapshotTest(
`---
title: Subgraph nodeSpacing and rankSpacing example
---
flowchart LR
X --> Y
subgraph X
direction LR
A
C
end
subgraph Y
direction LR
B
D
end
`,
{ flowchart: { nodeSpacing: 1, rankSpacing: 1 } }
);
});
describe('Markdown strings flowchart (#4220)', () => {
describe('html labels', () => {
it('With styling and classes', () => {

View File

@ -54,8 +54,8 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
if (node && node.clusterNode) {
// const children = graph.children(v);
log.info('Cluster identified', v, node.width, graph.node(v));
// node.graph.setGraph applies the graph configurations such as nodeSpacing to subgraphs as without this the default values would be used
// We override the `rankdir` variable to allow for the subgraph's direction to override the graphs direction in the subgraph
// `node.graph.setGraph` applies the graph configurations such as nodeSpacing to subgraphs as without this the default values would be used
// We override only the `ranksep` and `nodesep` configurations to allow for setting subgraph spacing while avoiding overriding other properties
const { ranksep, nodesep } = graph.graph();
node.graph.setGraph({
...node.graph.graph(),