feat: server entry and web shell with design tokens
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7f33169487
commit
05eee4cd40
@@ -0,0 +1,36 @@
|
||||
import { afterAll, beforeAll, expect, test } from "bun:test";
|
||||
import { resolve } from "node:path";
|
||||
import { loadConfig } from "@stc/core";
|
||||
import { startServer } from "../src/main";
|
||||
|
||||
let s: Awaited<ReturnType<typeof startServer>>;
|
||||
let base: string;
|
||||
beforeAll(async () => {
|
||||
const config = loadConfig({
|
||||
STC_PORT: "0", STC_DATABASE_URL: "sqlite://:memory:", STC_SECRET: "t",
|
||||
STC_COURSE_DIRS: resolve(import.meta.dir, "../../../fixtures/courses"),
|
||||
});
|
||||
s = await startServer(config, []);
|
||||
base = s.server.url.toString().replace(/\/$/, "");
|
||||
});
|
||||
afterAll(() => s.stop());
|
||||
|
||||
test("health reports the fixture course", async () => {
|
||||
expect(await (await fetch(`${base}/api/health`)).json()).toEqual({ ok: true, courses: 1, db: "sqlite" });
|
||||
});
|
||||
|
||||
test("SPA paths return the HTML shell", async () => {
|
||||
const r = await fetch(`${base}/some/spa/path`);
|
||||
expect(r.status).toBe(200);
|
||||
expect(await r.text()).toContain('<div id="root">');
|
||||
});
|
||||
|
||||
test("unknown API paths are 404, not the SPA", async () => {
|
||||
expect((await fetch(`${base}/api/nope`)).status).toBe(404);
|
||||
});
|
||||
|
||||
test("media honours Range", async () => {
|
||||
const r = await fetch(`${base}/api/media/sample/media/clip.mp4`, { headers: { Range: "bytes=0-9" } });
|
||||
expect(r.status).toBe(206);
|
||||
expect((await r.arrayBuffer()).byteLength).toBe(10);
|
||||
});
|
||||
Reference in New Issue
Block a user