Ui serving
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m55s
CI / Windows Release Package (push) Successful in 3m21s

This commit is contained in:
Aiden
2026-05-12 13:25:34 +10:00
parent bc690e2a87
commit b44504500a
7 changed files with 118 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
#include "HttpControlServer.h"
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
@@ -61,6 +63,32 @@ void TestStateEndpointUsesCallback()
ExpectEquals(response.body, "{\"ok\":true}", "state endpoint returns callback JSON");
}
void TestRootServesUiIndex()
{
using namespace RenderCadenceCompositor;
const std::filesystem::path root = std::filesystem::temp_directory_path() / "render-cadence-compositor-ui-test";
std::filesystem::create_directories(root);
{
std::ofstream output(root / "index.html", std::ios::binary);
output << "<!doctype html><div id=\"root\"></div>";
}
HttpControlServer server;
HttpControlServer::HttpRequest request;
request.method = "GET";
request.path = "/";
server.SetRootsForTest(root, std::filesystem::path());
const HttpControlServer::HttpResponse response = server.RouteRequestForTest(request);
ExpectEquals(response.status, "200 OK", "root endpoint serves UI index");
ExpectEquals(response.contentType, "text/html", "UI index content type is html");
Expect(response.body.find("root") != std::string::npos, "UI index body is returned");
std::filesystem::remove_all(root);
}
void TestKnownPostEndpointReturnsActionError()
{
using namespace RenderCadenceCompositor;
@@ -96,6 +124,7 @@ int main()
{
TestParsesHttpRequest();
TestStateEndpointUsesCallback();
TestRootServesUiIndex();
TestKnownPostEndpointReturnsActionError();
TestUnknownEndpointReturns404();