73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { resolveAuditIssueNodeIds } from "@/views/dashboards/departmentDashboard/modules/self-serve/auditIssueNavigation.js";
|
|
|
|
const readSource = (relativePath) => readFileSync(join(process.cwd(), relativePath), "utf8");
|
|
|
|
describe("self-serve studio audit navigation", () => {
|
|
const graphNodes = [
|
|
{ id: "condition:51" },
|
|
{ id: "condition:52" },
|
|
{ id: "question:12" },
|
|
{ id: "task:9" },
|
|
{ id: "relay:relay-a" },
|
|
];
|
|
|
|
it("resolves condition audit issues to graph node ids", () => {
|
|
expect(
|
|
resolveAuditIssueNodeIds(
|
|
{
|
|
message: "Condition 51 cannot reference itself in an expression.",
|
|
},
|
|
graphNodes
|
|
)
|
|
).toEqual(["condition:51"]);
|
|
});
|
|
|
|
it("resolves all condition nodes in a cycle audit issue", () => {
|
|
expect(
|
|
resolveAuditIssueNodeIds(
|
|
{
|
|
message: "Condition cycle detected: 51 -> 52 -> 51",
|
|
},
|
|
graphNodes
|
|
)
|
|
).toEqual(["condition:51", "condition:52"]);
|
|
});
|
|
|
|
it("uses structured node ids and filters missing graph nodes", () => {
|
|
expect(
|
|
resolveAuditIssueNodeIds(
|
|
{
|
|
message: "Server annotated issue",
|
|
node_ids: ["question:12", "question:999"],
|
|
},
|
|
graphNodes
|
|
)
|
|
).toEqual(["question:12"]);
|
|
});
|
|
|
|
it("resolves relay ids from virtual hardware warnings", () => {
|
|
expect(
|
|
resolveAuditIssueNodeIds(
|
|
{
|
|
message: "Virtual coverage only for relay IDs: relay-a.",
|
|
},
|
|
graphNodes
|
|
)
|
|
).toEqual(["relay:relay-a"]);
|
|
});
|
|
|
|
it("wires audit rows to the graph focus helper", () => {
|
|
const studioSource = readSource(
|
|
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
|
|
);
|
|
|
|
expect(studioSource).toContain('import { resolveAuditIssueNodeIds } from "./auditIssueNavigation.js";');
|
|
expect(studioSource).toContain("target_node_ids: resolveAuditIssueNodeIds(item, flowNodes.value)");
|
|
expect(studioSource).toContain('@click="selectValidationItem(item)"');
|
|
expect(studioSource).toContain("focusDebugNodes(targetNodeIds, true, { clearFilters: true })");
|
|
});
|
|
});
|