diff --git a/src/StatusRegistry.ts b/src/StatusRegistry.ts index 0555ff81c4..625aeb05d3 100644 --- a/src/StatusRegistry.ts +++ b/src/StatusRegistry.ts @@ -305,10 +305,16 @@ export class StatusRegistry { const edges: string[] = []; uniqueStatuses.forEach((status, index) => { nodes.push(`${index + 1}[${status.name}]`); + + // Check the next status: const nextStatus = this.getNextStatus(status); - // TODO What if (nextStatus.type === StatusType.EMPTY) const nextStatusIndex = uniqueStatuses.findIndex((status) => status.symbol === nextStatus.symbol); - edges.push(`${index + 1} --> ${nextStatusIndex + 1}`); + const nextStatusIsKnown = nextStatusIndex !== -1; + const nextStatusIsNotInternal = nextStatus.type !== StatusType.EMPTY; + + if (nextStatusIsKnown && nextStatusIsNotInternal) { + edges.push(`${index + 1} --> ${nextStatusIndex + 1}`); + } }); return ` diff --git a/tests/DocumentationSamples/DocsSamplesForStatuses.test.DefaultStatuses_custom-statuses.approved.mermaid.md b/tests/DocumentationSamples/DocsSamplesForStatuses.test.DefaultStatuses_custom-statuses.approved.mermaid.md index 25158ba460..d7f767c1c8 100644 --- a/tests/DocumentationSamples/DocsSamplesForStatuses.test.DefaultStatuses_custom-statuses.approved.mermaid.md +++ b/tests/DocumentationSamples/DocsSamplesForStatuses.test.DefaultStatuses_custom-statuses.approved.mermaid.md @@ -3,6 +3,5 @@ flowchart LR 1[In Progress] 2[Cancelled] -1 --> 0 -2 --> 0 + ``` diff --git a/tests/StatusRegistry.test.ts b/tests/StatusRegistry.test.ts index 1323c443b1..9c4f72cf24 100644 --- a/tests/StatusRegistry.test.ts +++ b/tests/StatusRegistry.test.ts @@ -188,6 +188,30 @@ describe('StatusRegistry', () => { `); }); + it('should not include unknown nextStatusSymbols in mermaid diagrams', () => { + // Arrange + const statusRegistry = new StatusRegistry(); + statusRegistry.clearStatuses(); + statusRegistry.add(new StatusConfiguration(' ', 'Todo', '/', false, StatusType.TODO)); + // Leave '/' as not registered + const originalNumberOfStatuses = statusRegistry.registeredStatuses.length; + + // Act + const mermaidText = statusRegistry.mermaidDiagram(); + + // Assert + expect(statusRegistry.registeredStatuses.length).toEqual(originalNumberOfStatuses); + expect(mermaidText).toMatchInlineSnapshot(` + " + \`\`\`mermaid + flowchart LR + 1[Todo] + + \`\`\` + " + `); + }); + describe('toggling', () => { it('should allow task to toggle through standard transitions', () => { // Arrange