58 lines
1.6 KiB
JavaScript
58 lines
1.6 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 = {
|
|
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.authSession.getState()).toBe("unauthenticated");
|
|
expect(adapters.cache.read(["missing"])).toEqual({
|
|
ok: true,
|
|
value: undefined,
|
|
});
|
|
await expect(adapters.releaseInfo.getCurrent()).resolves.toMatchObject({
|
|
releaseId: "release-a",
|
|
});
|
|
});
|
|
|
|
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.authSession.getState()).toBe("integration-failed");
|
|
});
|
|
});
|