Ui serving
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user