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:
@@ -1,4 +1,4 @@
|
||||
// Route: POST /validate/user (all-failures validation error)
|
||||
// Route: /validate/user (all-failures validation, JSON and HTML form)
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
@@ -17,5 +17,19 @@ int main() {
|
||||
check(contains(bad.body, "username"), "username failure listed");
|
||||
check(contains(bad.body, "email"), "missing email listed");
|
||||
check(contains(bad.body, "age"), "bad age listed");
|
||||
|
||||
auto page = f.client->get("/validate/user");
|
||||
check(page.status == 200, "form page is 200");
|
||||
check(contains(page.body, "name=\"username\""), "username input");
|
||||
auto html = f.client->request(
|
||||
molo::example::fw::Method::Post, "/validate/user",
|
||||
"username=ad&email=x&age=200",
|
||||
{{"Content-Type", "application/x-www-form-urlencoded"},
|
||||
{"Accept", "text/html"}});
|
||||
check(html.status == 422, "browser post is 422");
|
||||
check(contains(html.body, "Please fix 3 field(s)"), "all three listed");
|
||||
check(contains(html.body, "must be at least 3 characters"), "username text");
|
||||
check(contains(html.body, "must be between 0 and 150"), "age text");
|
||||
check(!contains(html.body, "validation_error"), "no raw JSON in the page");
|
||||
return finish("validate/user");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user