feat(workflow): example stats page with embedded Chart.js, inline form validation errors

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 01:59:27 +02:00
co-authored by Claude Sonnet 5.5
parent 16a0bb0de4
commit 00af65613d
36 changed files with 1274 additions and 138 deletions
+29
View File
@@ -0,0 +1,29 @@
// Route: GET /stats/data (request, connection, and service statistics)
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
f.client->get("/health");
f.client->get("/health");
f.client->get("/no/such/route");
f.client->post("/forms/contact", "name=ada",
"application/x-www-form-urlencoded");
auto res = f.client->get("/stats/data");
check(res.status == 200, "status 200");
check(contains(res.headers.get("Content-Type"), "application/json"), "json");
check(contains(res.body, "\"requests\":4"), "four requests before this one");
check(contains(res.body, "\"errors\":2"), "404 and 422 counted as errors");
check(contains(res.body, "\"404\":1") && contains(res.body, "\"422\":1"),
"status breakdown");
check(contains(res.body, "\"/health\""), "route pattern grouped");
check(contains(res.body, "\"(unmatched)\""), "unmatched bucket");
check(contains(res.body, "\"POST\":1") && contains(res.body, "\"GET\":3"),
"method breakdown");
check(contains(res.body, "\"p95_ms\""), "latency percentiles");
check(contains(res.body, "\"connections\""), "connection block");
check(contains(res.body, "\"series\""), "time series");
check(f.services.stats->total_requests() == 5, "side effect: 5 recorded");
return finish("stats/data");
}
+24
View File
@@ -0,0 +1,24 @@
// Route: GET /stats (Chart.js page; library comes from the embedded bundle)
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
auto page = f.client->get("/stats");
check(page.status == 200, "status 200");
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
check(contains(page.body, "<canvas id=\"c-requests\""), "request chart");
check(contains(page.body, "<canvas id=\"c-conns\""), "connection chart");
check(contains(page.body, "/embedded/chart.umd.min.js"), "chart.js linked");
auto lib = f.client->get("/embedded/chart.umd.min.js");
check(lib.status == 200, "chart.js served");
check(lib.headers.get("X-Asset-Source") == "embedded", "from the bundle");
check(contains(lib.body, "Chart.js v"), "real chart.js build embedded");
auto js = f.client->get("/embedded/stats.js");
check(js.status == 200 && contains(js.body, "/stats/data"), "page script");
check(f.client->request(molo::example::fw::Method::Post, "/stats").status ==
405,
"post is 405");
return finish("stats/page");
}