25 lines
1.1 KiB
C++
25 lines
1.1 KiB
C++
// 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");
|
|
}
|