WFDASH-WEBAPP/e2e/agent-api.spec.ts
SJCoetz c4e1c62882 chore: standardize line endings and add full test + config scaffolding
Fix inconsistent line endings across all project files for cross-environment consistency.
Add complete unit test suite covering core utilities, API routes, and server services.
Add Playwright E2E test setup with smoke, auth, and agent API tests.
Update all project configuration files to match standardized formatting.
Fix MCP API error handling to properly propagate HTTP status codes and use correct JSON-RPC error codes.
Add VSCode workspace configuration, extensions, and example MCP config files.
Update .gitignore to exclude new test and build artifacts.
2026-06-11 20:30:02 +02:00

29 lines
1.1 KiB
TypeScript

import { test, expect } from "./_helpers";
const AGENT_KEY = process.env.E2E_AGENT_API_KEY ?? "";
/**
* The agent REST endpoints require a bearer token and a reachable PocketBase.
* The E2E_AGENT_API_KEY must match the AGENT_API_KEY the dev server is using.
* The dev server reads env at boot — if you change it, restart `npm run dev`.
*/
test.describe("agent API auth", () => {
test.skip(
!AGENT_KEY,
"E2E_AGENT_API_KEY not set — skipping agent-API auth specs"
);
test("orders endpoint returns 401 without a bearer token", async ({ request }) => {
const res = await request.get("/api/v1/orders");
expect(res.status()).toBe(401);
});
test("orders endpoint lists when token is valid", async ({ request }) => {
const res = await request.get("/api/v1/orders?perPage=1", {
headers: { authorization: `Bearer ${AGENT_KEY}` },
});
// 200 if PocketBase is reachable, 500 if it isn't — both are valid signals
// that auth passed and we got past the assertAgentAuth guard.
expect([200, 500]).toContain(res.status());
});
});