40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
|
|
test.describe("API endpoints", () => {
|
|
test("GET /api/modules returns 25+ modules", async ({ request }) => {
|
|
const res = await request.get("/api/modules");
|
|
expect(res.status()).toBe(200);
|
|
|
|
const data = await res.json();
|
|
expect(data).toHaveProperty("modules");
|
|
const modules = data.modules;
|
|
expect(Array.isArray(modules)).toBe(true);
|
|
expect(modules.length).toBeGreaterThanOrEqual(24);
|
|
|
|
// Each module should have at least id, name, icon
|
|
for (const mod of modules) {
|
|
expect(mod).toHaveProperty("id");
|
|
expect(mod).toHaveProperty("name");
|
|
expect(mod).toHaveProperty("icon");
|
|
}
|
|
});
|
|
|
|
test("GET /.well-known/webauthn returns valid config", async ({ request }) => {
|
|
const res = await request.get("/.well-known/webauthn");
|
|
// Should return 200 with origins or may not exist
|
|
if (res.status() === 200) {
|
|
const data = await res.json();
|
|
expect(data).toHaveProperty("origins");
|
|
expect(Array.isArray(data.origins)).toBe(true);
|
|
} else {
|
|
// If not implemented, should at least not be a 500
|
|
expect(res.status()).toBeLessThan(500);
|
|
}
|
|
});
|
|
|
|
test("unknown API route returns < 500", async ({ request }) => {
|
|
const res = await request.get("/api/nonexistent-route-12345");
|
|
expect(res.status()).toBeLessThan(500);
|
|
});
|
|
});
|