Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | 3x 2x 1x 1x 3x 3x 3x 3x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 4x 4x 4x 4x 3x 3x 3x 1x 1x 1x 4x 3x 4x 9x 4x 3x | "use client";
import { fetchApi } from "@/lib/api";
import { useEffect, useState } from "react";
import {
ShieldCheck,
CheckCircle2,
XCircle,
MinusCircle,
RefreshCw,
ExternalLink,
} from "lucide-react";
import Link from "next/link";
import PageIntro from "@/components/PageIntro";
/* ── Types ─────────────────────────────────────────────────────── */
interface TestResult {
id: string;
category: string;
suite: "DSP" | "DCP" | "EHDS";
name: string;
status: "pass" | "fail" | "skip";
detail: string;
}
interface SuiteResult {
results: TestResult[];
passed: number;
total: number;
skipped?: number;
}
interface TckData {
timestamp: string;
summary: { total: number; passed: number; failed: number; skipped: number };
suites: Record<"DSP" | "DCP" | "EHDS", SuiteResult>;
}
/* ── Badge helpers ─────────────────────────────────────────────── */
function StatusIcon({ status }: { status: string }) {
if (status === "pass")
return (
<CheckCircle2 size={16} className="text-[var(--success-text)] shrink-0" />
);
Eif (status === "fail")
return <XCircle size={16} className="text-[var(--danger-text)] shrink-0" />;
// skip: distinctly *neutral* (blue), not warning-yellow — so users don't
// confuse "intentionally skipped on this deployment" with "test failed".
return (
<MinusCircle
size={16}
className="text-blue-600 dark:text-blue-400 shrink-0"
/>
);
}
function ScoreBadge({
passed,
total,
skipped = 0,
}: {
passed: number;
total: number;
skipped?: number;
}) {
// When all tests are skipped, render a neutral "Skipped" badge instead of
// a red "0/N (0%)" that visually screams failure even though nothing
// actually failed.
Iif (skipped > 0 && skipped === total) {
return (
<span className="text-xs font-mono px-2 py-0.5 rounded border bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300 border-blue-300 dark:border-blue-700">
{skipped} skipped
</span>
);
}
const pct = total > 0 ? Math.round((passed / total) * 100) : 0;
const color =
pct === 100
? "bg-[var(--badge-active-bg)] text-[var(--badge-active-text)] border-[var(--badge-active-border)]"
: pct >= 80
? "bg-[var(--role-hdab-bg)] text-[var(--role-hdab-text)] border-[var(--role-hdab-border)]"
: "bg-[var(--badge-inactive-bg)] text-[var(--badge-inactive-text)] border-[var(--badge-inactive-border)]";
return (
<span className={`text-xs font-mono px-2 py-0.5 rounded border ${color}`}>
{passed}/{total} ({pct}%)
</span>
);
}
/* ── Suite card ────────────────────────────────────────────────── */
const suiteLabels: Record<string, { title: string; description: string }> = {
DSP: {
title: "DSP 2025-1 Protocol",
description:
"Dataspace Protocol — catalog, negotiation, transfer process, schema compliance",
},
DCP: {
title: "DCP v1.0 Identity",
description:
"Decentralized Claims Protocol — DIDs, key pairs, verifiable credentials, issuer service",
},
EHDS: {
title: "EHDS Health Domain",
description:
"European Health Data Space — HealthDCAT-AP, EEHRxF, OMOP CDM, Article 53 enforcement",
},
};
function SuiteCard({
suiteKey,
data,
}: {
suiteKey: "DSP" | "DCP" | "EHDS";
data: SuiteResult;
}) {
const [expanded, setExpanded] = useState(true);
const meta = suiteLabels[suiteKey];
const skipped = data.results.filter((r) => r.status === "skip").length;
// Group by category
const categories = data.results.reduce(
(acc, r) => {
(acc[r.category] ??= []).push(r);
return acc;
},
{} as Record<string, TestResult[]>,
);
return (
<div className="bg-[var(--surface-2)] rounded-lg border border-[var(--border)] overflow-hidden">
<button
onClick={() => setExpanded(!expanded)}
className="w-full flex items-center justify-between px-5 py-4 hover:bg-[var(--surface-2)]/40 transition-colors"
>
<div className="flex items-center gap-3">
<ShieldCheck
size={18}
className="text-blue-800 dark:text-blue-300 shrink-0"
/>
<div className="text-left">
<span className="font-semibold text-[var(--text-primary)]">
{meta.title}
</span>
<span className="block text-xs text-[var(--text-secondary)]">
{meta.description}
</span>
</div>
</div>
<ScoreBadge passed={data.passed} total={data.total} skipped={skipped} />
</button>
{expanded && (
<div className="border-t border-[var(--border)] divide-y divide-[var(--border)]">
{Object.entries(categories).map(([cat, tests]) => (
<div key={cat} className="px-5 py-3">
<h4 className="text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider mb-2">
{cat}
</h4>
<ul className="space-y-1.5">
{tests.map((t) => (
<li key={t.id} className="flex items-start gap-2 text-sm">
<StatusIcon status={t.status} />
<div>
<span className="text-[var(--text-primary)]">
<span className="font-mono text-xs text-[var(--text-secondary)] mr-1.5">
{t.id}
</span>
{t.name}
</span>
<span className="block text-xs text-[var(--text-secondary)] mt-0.5">
{t.detail}
</span>
</div>
</li>
))}
</ul>
</div>
))}
</div>
)}
</div>
);
}
/* ── Page ──────────────────────────────────────────────────────── */
export default function ComplianceTckPage() {
const [data, setData] = useState<TckData | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const load = () => {
setLoading(true);
setError(null);
fetchApi("/api/compliance/tck")
.then((r) => r.json())
.then((d: TckData) => setData(d))
.catch((e) => setError(String(e)))
.finally(() => setLoading(false));
};
useEffect(() => {
load();
}, []);
return (
<div className="min-h-screen bg-[var(--bg)]">
<div className="max-w-4xl mx-auto px-6 py-10">
{/* Header */}
<div className="flex items-center justify-between mb-1">
<PageIntro
title="Protocol Compliance Dashboard"
icon={ShieldCheck}
description="Run the DSP 2025-1 and DCP v1.0 Technology Compatibility Kit against your connectors. This dashboard validates that your EDC-V deployment correctly implements the Dataspace Protocol and Decentralized Claims Protocol."
prevStep={{ href: "/compliance", label: "EHDS Compliance" }}
nextStep={{ href: "/credentials", label: "Verifiable Credentials" }}
infoText="The TCK executes protocol-level tests covering catalog, negotiation, transfer, and identity resolution. Results indicate whether your connectors are interoperable with other EHDS participants."
docLink={{
href: "https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol",
label: "Dataspace Protocol Spec",
external: true,
}}
/>
<button
onClick={load}
disabled={loading}
className="flex items-center gap-1.5 text-sm px-3 py-1.5 rounded bg-[var(--surface-2)] border border-[var(--border)] text-[var(--text-primary)] hover:bg-[var(--surface-2)] disabled:opacity-50 transition-colors"
>
<RefreshCw size={14} className={loading ? "animate-spin" : ""} />
{loading ? "Running…" : "Re-run"}
</button>
</div>
<div className="flex items-center gap-3 mb-8 text-xs text-[var(--text-secondary)]">
<Link
href="/compliance"
className="flex items-center gap-1 hover:text-[var(--text-primary)] transition-colors"
>
<ExternalLink size={12} />
EHDS Approval Checker
</Link>
{data && (
<span>Last run: {new Date(data.timestamp).toLocaleString()}</span>
)}
</div>
{/* Error state */}
{error && (
<div className="bg-[var(--badge-inactive-bg)] border border-[var(--badge-inactive-border)] rounded-lg p-4 mb-6 text-[var(--danger-text)] text-sm">
{error}
</div>
)}
{/* Loading skeleton — cold start only */}
{loading && !data && (
<>
<div className="flex items-center gap-3 mb-6 text-sm text-[var(--text-secondary)]">
<RefreshCw size={16} className="animate-spin" />
<span>
Running 20 protocol probes against the live deployment — this
takes up to a minute on first load…
</span>
</div>
<div className="space-y-4">
{[1, 2, 3].map((i) => (
<div
key={i}
className="h-32 bg-[var(--surface-2)] rounded-lg animate-pulse border border-[var(--border)]"
/>
))}
</div>
</>
)}
{/* Re-run overlay — keeps stale data visible but signals refresh */}
{loading && data && (
<div className="flex items-center gap-2 mb-4 px-3 py-2 rounded-lg bg-[var(--surface-2)] border border-[var(--border)] text-xs text-[var(--text-secondary)]">
<RefreshCw
size={14}
className="animate-spin text-[var(--text-primary)]"
/>
<span>
Re-running probes — current results may be stale until this
completes (typically 30-60 s).
</span>
</div>
)}
{/* Summary bar */}
{data && (
<>
<div className="grid grid-cols-4 gap-4 mb-8">
{[
{
label: "Total",
value: data.summary.total,
color: "text-[var(--text-primary)]",
},
{
label: "Passed",
value: data.summary.passed,
color: "text-[var(--success-text)]",
},
{
label: "Failed",
value: data.summary.failed,
color: "text-[var(--danger-text)]",
},
{
label: "Skipped",
value: data.summary.skipped,
color: "text-[var(--warning-text)]",
},
].map((s) => (
<div
key={s.label}
className="bg-[var(--surface-2)] border border-[var(--border)] rounded-lg px-4 py-3 text-center"
>
<div className={`text-2xl font-bold ${s.color}`}>
{s.value}
</div>
<div className="text-xs text-[var(--text-secondary)] mt-0.5">
{s.label}
</div>
</div>
))}
</div>
{/* Skip explainer — appears when DSP/DCP suites can't reach the
EDC services (typical for Azure deployments where multi-port
ACA ingress isn't configured; the local Docker stack has them
all green). */}
{data.summary.skipped > 0 && (
<div className="mb-6 px-4 py-3 rounded-lg border border-blue-300 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/20 text-sm text-[var(--text-primary)]">
<p className="font-medium mb-1">
{data.summary.skipped} test
{data.summary.skipped === 1 ? "" : "s"} skipped — EDC services
not provisioned in this environment
</p>
<p className="text-xs text-[var(--text-secondary)] leading-relaxed">
The Azure Container Apps deployment doesn't currently
host the EDC controlplane / IdentityHub / IssuerService
(single-port ingress vs EDC's 4-port architecture — see
ADR-012 follow-up). For full DSP/DCP validation, run the local
Docker stack:{" "}
<code className="font-mono text-[11px] bg-[var(--surface-2)] px-1 py-0.5 rounded">
docker compose -f docker-compose.yml -f
docker-compose.jad.yml up -d
</code>
.{" "}
<a
href="https://github.com/ma3u/MinimumViableHealthDataspacev2/issues/25"
target="_blank"
rel="noopener noreferrer"
className="text-blue-700 dark:text-blue-300 underline hover:no-underline"
>
Tracking issue #25 ↗
</a>
</p>
</div>
)}
{/* Suite cards */}
<div className="space-y-4">
{(["DSP", "DCP", "EHDS"] as const).map((key) => (
<SuiteCard key={key} suiteKey={key} data={data.suites[key]} />
))}
</div>
</>
)}
</div>
</div>
);
}
|