API: generate /api/state documentation from UI types (#32431)

Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
andig 2026-08-03 13:06:37 +02:00 • committed by GitHub
parent c7c744f54e
commit c3f3384bfc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 8757 additions and 3347 deletions

28
tests/state-api.spec.ts Normal file
View file

@ -0,0 +1,28 @@
import { test, expect } from "@playwright/test";
import { start, stop, baseUrl } from "./evcc";
import { validateState } from "../scripts/state-schema/validate";
test.use({ baseURL: baseUrl() });
const CONFIG = "cmd/demo.yaml";
test.beforeAll(async () => {
await start(CONFIG);
});
test.afterAll(async () => {
await stop();
});
test("/api/state matches the openapi State schema", async ({ request }) => {
// loadpoint values appear over the first update cycles, poll until stable
await expect
.poll(
async () => {
const res = await request.get("/api/state");
const { errors, undocumented } = validateState(await res.json());
return [...errors, ...undocumented];
},
{ timeout: 30000 }
)
.toEqual([]);
});