fix: recognize class-attached investigation diagram nodes
This commit is contained in:
@@ -70,6 +70,15 @@ describe("investigation SVG post-processing", () => {
|
||||
});
|
||||
|
||||
describe("investigation diagram presentation", () => {
|
||||
it("applies recorded states to bare class-attached declarations and ignores partial IDs", () => {
|
||||
const styled = styleInvestigationDiagram({ title: "核查", mermaid: "flowchart TD\nQUERY:::tjAction --> REVIEW:::tjHuman",
|
||||
node_refs: [{ node_id: "QUERY", label: "核查", status: "running", evidence_refs: [], action_refs: [] },
|
||||
{ node_id: "REVIEW", label: "复核", status: "waiting_human", evidence_refs: [], action_refs: [] },
|
||||
{ node_id: "QUER", label: "无效引用", status: "completed", evidence_refs: [], action_refs: [] }] }, true);
|
||||
expect(styled).toContain("class QUERY tjRunning;");
|
||||
expect(styled).toContain("class REVIEW tjWaitingHuman;");
|
||||
expect(styled).not.toContain("class QUER ");
|
||||
});
|
||||
it("retains source relationships and only styles declared business references", () => {
|
||||
const source = 'flowchart TD\nA["核查"] --> B;\nB -->|资料不足| C["记录缺口"]';
|
||||
const styled = styleInvestigationDiagram({
|
||||
|
||||
@@ -166,7 +166,7 @@ export function paintInvestigationDiagramStates(root: Element, diagram: Investig
|
||||
export function styleInvestigationDiagram(diagram: InvestigationDiagram, running = false) {
|
||||
const assignments = diagram.node_refs.flatMap((node) => {
|
||||
const escaped = node.node_id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const inSource = new RegExp(`\\b${escaped}(?=\\s*(?:[\\[({@;]|--|==|-\\.|$))`, "m").test(
|
||||
const inSource = new RegExp(`(?:^|[^A-Za-z0-9_-])${escaped}(?=\\s*(?:[\\[({@;]|:::|--|==|-\\.|$))`, "m").test(
|
||||
diagram.mermaid
|
||||
);
|
||||
if (!inSource) return [];
|
||||
|
||||
Reference in New Issue
Block a user