API: generate /api/state documentation from UI types (#31530)
This commit is contained in:
parent
bacca990ee
commit
542a01fa20
42 changed files with 8786 additions and 3351 deletions
28
tests/state-api.spec.ts
Normal file
28
tests/state-api.spec.ts
Normal 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([]);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue