Fallback invalid CommandBoard API ports (#39)

Co-authored-by: Codex Microtask Operator <codex-microtask@example.com>
This commit is contained in:
Autowebassat-blip 2026-06-14 07:57:43 +02:00 committed by GitHub
parent e89c10cc80
commit 3afda8c147
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import type { Server } from "node:http";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { createCommandBoardServer } from "./index.js";
import { createCommandBoardServer, readPort } from "./index.js";
let server: Server;
let baseUrl: string;
@ -22,6 +22,13 @@ afterAll(async () => {
});
describe("CommandBoard API contracts", () => {
it("falls back when PORT is invalid", () => {
expect(readPort("not-a-port", 4010)).toBe(4010);
expect(readPort("0", 4010)).toBe(4010);
expect(readPort("65536", 4010)).toBe(4010);
expect(readPort("4020", 4010)).toBe(4020);
});
it("exposes root API index", async () => {
const response = await fetch(`${baseUrl}/`);
const body = await response.json() as { ok: boolean; service: string; endpoints: string[] };