57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { createRuntimeAdapters } from "../../src/bootstrap/runtime-adapters.js";
|
|
|
|
const runtime = {
|
|
config: {
|
|
APP_ENV: "local",
|
|
API_BASE_URL: "http://localhost:8080",
|
|
TELEMETRY_ENABLED: false,
|
|
AUTH_MODE: "demo",
|
|
},
|
|
};
|
|
const release = /** @type {const} */ ({
|
|
schemaVersion: 1,
|
|
appVersion: "0.1.0",
|
|
buildId: "build-a",
|
|
commitSha: "abc123",
|
|
configSchemaVersion: "1",
|
|
apiContractVersion: "1",
|
|
assetManifestHash: "hash-a",
|
|
releaseId: "release-a",
|
|
builtAt: "2026-07-25T00:00:00Z",
|
|
});
|
|
|
|
describe("runtime adapter composition", () => {
|
|
it("constructs the local demo seam and infrastructure adapters", async () => {
|
|
const adapters = await createRuntimeAdapters({
|
|
runtime:
|
|
/** @type {Parameters<typeof createRuntimeAdapters>[0]["runtime"]} */ (
|
|
runtime
|
|
),
|
|
release,
|
|
host: {},
|
|
});
|
|
|
|
expect(adapters.outputPorts.session.getState()).toBe("unauthenticated");
|
|
await expect(adapters.outputPorts.releaseInfo.getCurrent()).resolves.toMatchObject({
|
|
releaseId: "release-a",
|
|
});
|
|
expect(adapters.infrastructure.queryClient).toBeDefined();
|
|
expect(adapters).not.toHaveProperty("http");
|
|
expect(adapters).not.toHaveProperty("storage");
|
|
});
|
|
|
|
it("fails closed when an external auth owner was not installed", async () => {
|
|
const adapters = await createRuntimeAdapters({
|
|
runtime:
|
|
/** @type {Parameters<typeof createRuntimeAdapters>[0]["runtime"]} */ ({
|
|
config: { ...runtime.config, AUTH_MODE: "external" },
|
|
}),
|
|
release,
|
|
host: {},
|
|
});
|
|
expect(adapters.outputPorts.session.getState()).toBe("integration-failed");
|
|
});
|
|
});
|