`;
+ * rendered wherever the matrix or graph is shown, when the policy declares
+ * tests. Failing assertions are also flagged in the editor.
+ */
+export function TestsPanel({ report }: { report: TestReport }) {
+ const { failing } = testCounts(report);
+ return (
+
+ {failing > 0 && (
+
+ Tailscale rejects a policy whose tests fail. Fix the policy or the
+ assertion flagged in the editor.
+
+ )}
+
+
+ );
+}
diff --git a/web/src/snapshot/ImportTailnet.test.tsx b/web/src/snapshot/ImportTailnet.test.tsx
index c436503..e0e808d 100644
--- a/web/src/snapshot/ImportTailnet.test.tsx
+++ b/web/src/snapshot/ImportTailnet.test.tsx
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { parse as parseJsonc } from "jsonc-parser";
import { render } from "../test/render";
import { useStore } from "../state/store";
-import { ImportTailnetButton } from "./ImportTailnet";
+import { ImportTailnetButton } from "./ImportTailnetButton";
const apiOutput = JSON.stringify({
devices: [
diff --git a/web/src/snapshot/ImportTailnet.tsx b/web/src/snapshot/ImportTailnetButton.tsx
similarity index 100%
rename from web/src/snapshot/ImportTailnet.tsx
rename to web/src/snapshot/ImportTailnetButton.tsx
diff --git a/web/src/snapshot/SnapshotPanel.tsx b/web/src/snapshot/SnapshotPanel.tsx
index d842908..86fe96e 100644
--- a/web/src/snapshot/SnapshotPanel.tsx
+++ b/web/src/snapshot/SnapshotPanel.tsx
@@ -7,7 +7,7 @@ import { usePaneMax } from "../app/usePaneMax";
import { usePanelCollapse } from "../app/usePanelCollapse";
import { LeftTabs } from "../app/LeftTabs";
import { SnapshotJson } from "./SnapshotJson";
-import { ImportTailnetButton } from "./ImportTailnet";
+import { ImportTailnetButton } from "./ImportTailnetButton";
import { DevicesSection, ExternalSection, ServicesSection, UsersSection } from "./Sections";
import { GroupsHostsEditor } from "./GroupsHostsEditor";
diff --git a/web/src/styles/tutorials.css b/web/src/styles/tutorials.css
index 07e1684..5c15a60 100644
--- a/web/src/styles/tutorials.css
+++ b/web/src/styles/tutorials.css
@@ -329,3 +329,16 @@ th.rowhead.clickable:hover {
.tour-note { bottom: 76px; }
.tour-note span { display: none; }
}
+
+/* Policy-tests panel in the analysis strip; reuses the .grading list. */
+.tests-panel {
+ padding: 6px 12px;
+}
+.tests-reject {
+ margin: 0 0 6px;
+ color: var(--danger);
+}
+.tests-failing {
+ color: var(--danger);
+ font-weight: 600;
+}
diff --git a/web/src/tutorials/GradingChecklist.tsx b/web/src/tutorials/GradingChecklist.tsx
index 324a936..e8e5683 100644
--- a/web/src/tutorials/GradingChecklist.tsx
+++ b/web/src/tutorials/GradingChecklist.tsx
@@ -1,4 +1,5 @@
-import type { TestGroup, TestReport } from "../engine/types";
+import type { TestReport } from "../engine/types";
+import { TestGroupList, testCounts, testGroups } from "../matrix/TestsPanel";
/** Live pass/fail of the lesson's `tests` / `sshTests` assertions. */
export function GradingChecklist({
@@ -10,9 +11,7 @@ export function GradingChecklist({
complete: boolean;
graded: boolean;
}) {
- const groups: [string, TestGroup][] = [];
- if (report?.acl) groups.push(["Reachability", report.acl]);
- if (report?.ssh) groups.push(["SSH", report.ssh]);
+ const groups = testGroups(report);
if (groups.length === 0) {
return (
@@ -24,11 +23,7 @@ export function GradingChecklist({
);
}
- const total = groups.reduce((n, [, g]) => n + g.cases.length, 0);
- const passed = groups.reduce(
- (n, [, g]) => n + g.cases.filter((c) => c.pass).length,
- 0,
- );
+ const { total, passed } = testCounts(report);
return (
@@ -37,27 +32,7 @@ export function GradingChecklist({
{complete ? "✓ Lesson complete" : `${passed} / ${total} checks passing`}
- {groups.map(([name, g]) => (
-
- {groups.length > 1 &&
{name}
}
-
- {g.cases.map((c, i) => (
- -
- {c.pass ? "✓" : "✗"}
-
- {c.label} — {c.expect}
-
- {c.detail && {c.detail}}
-
- ))}
-
- {g.rawFailures?.map((f, i) => (
-
- {f}
-
- ))}
-
- ))}
+
);
}