evcc-io/tests/state-api.spec.ts
andig c3f3384bfc
API: generate /api/state documentation from UI types (#32431)
Co-authored-by: Michael Geers <michael@geers.tv>
2026-08-03 11:06:37 +00:00

28 lines
770 B
TypeScript

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([]);
});