t3-code-android-nightly/.repos/alchemy-effect/packages/alchemy/test/Local/TestSidecar.test.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

74 lines
2.3 KiB
TypeScript

import * as Cloudflare from "@/Cloudflare/index.ts";
import { Interaction } from "@/Interaction.ts";
import { RpcProviderProxy } from "@/Local/RpcProviderProxy";
import * as Test from "@/Test/Alchemy";
import { expect } from "alchemy-test";
import * as Effect from "effect/Effect";
/**
* Contract tests for the test harness's sidecar topology (see
* MakeOptions.sidecar in Test/Core.ts): `dev: true` runs local providers
* behind the RPC proxy used by the real `alchemy dev` command BY DEFAULT,
* and `sidecar: false` opts back into the in-process topology.
*
* The dev-mode resource tests (KV/R2/Queue/D1 `*.local.test.ts`) would
* still pass in-process if the default silently stopped installing the
* proxy — the whole point of the topology is that missing main-process
* dependencies only surface under it (#1007). These tests pin the harness
* contract directly so a refactor of Test.make can't quietly demote every
* dev test back to in-process.
*/
const dev = Test.make({
providers: Cloudflare.providers(),
dev: true,
});
const inProcess = Test.make({
providers: Cloudflare.providers(),
dev: true,
sidecar: false,
});
const live = Test.make({
providers: Cloudflare.providers(),
});
dev.test(
"dev: true installs the RpcProviderProxy by default",
Effect.gen(function* () {
const proxy = yield* Effect.serviceOption(RpcProviderProxy);
expect(proxy._tag).toBe("Some");
}),
{ tags: ["provider:cloudflare", "local"] },
);
inProcess.test(
"sidecar: false opts a dev test out of the RpcProviderProxy",
Effect.gen(function* () {
const proxy = yield* Effect.serviceOption(RpcProviderProxy);
expect(proxy._tag).toBe("None");
}),
{ tags: ["provider:cloudflare", "local"] },
);
live.test(
"non-dev tests do not install the RpcProviderProxy",
Effect.gen(function* () {
const proxy = yield* Effect.serviceOption(RpcProviderProxy);
expect(proxy._tag).toBe("None");
}),
{ tags: ["provider:cloudflare", "local"] },
);
live.test(
"test runtimes provide a non-interactive Interaction",
Effect.gen(function* () {
const interaction = yield* Interaction;
const failure = yield* Effect.flip(
interaction.prompt.confirm({ message: "?" }),
);
expect(failure._tag).toBe("NonInteractiveTerminal");
}),
{ tags: ["provider:cloudflare", "local"] },
);