// Route: GET /agent/optimize and /agent/optimize/status (page, script, call table) #include #include "support/GoogleRig.hpp" using namespace molo::example::test; int main() { setenv("GOOGLE_CLOUD_PROJECT", "test-proj", 1); GoogleRig rig(false); Fixture f(rig.client); auto page = f.client->get("/agent/optimize"); check(page.status == 200, "page status 200 without a credential"); check(contains(page.headers.get("Content-Type"), "text/html"), "html"); check(contains(page.body, "width=device-width"), "responsive viewport"); check(contains(page.body, "id=\"o-action\""), "action dropdown (no wide button group)"); check(contains(page.body, "/embedded/agent_optimize.js"), "script linked"); auto js = f.client->get("/embedded/agent_optimize.js"); check(js.status == 200 && contains(js.body, "/agent/optimize/"), "script served from the bundle"); auto st = f.client->get("/agent/optimize/status"); check(st.status == 200, "status 200 without a credential"); check(contains(st.headers.get("Content-Type"), "json"), "status is json"); check(contains(st.body, "\"configured\":false"), "reports no credential"); check(contains(st.body, "\"project_set\":true"), "reports the project is set, never its value"); check(!contains(st.body, "test-proj"), "project id never echoed"); check(contains(st.body, "aiplatform.projects.locations.evaluateInstances"), "call table listed"); check(contains(st.body, "cloudtrace.projects.traces.list"), "trace read listed"); check(contains(st.body, "\"max_sim_turns\":12"), "caps listed"); check(f.client->post("/agent/optimize").status == 405, "post to the page is 405"); check(f.client->post("/agent/optimize/status").status == 405, "post to status is 405"); check(rig.mock->send_count() == 0, "side effect: GET routes make no Google call"); return finish("agent/optimize/page"); }