The best way to control Claude Code, Codex and more from any computer or phone

main
ts 63 lines 2.16 KB
Raw
1 import * as Fly from "@alchemy.run/fly";
2 import { describe, expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as Effect from "effect/Effect";
5 import * as pathe from "pathe";
6 import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
7 import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
8
9 const { test } = Test.make({ providers: Fly.providers(), dev: true });
10
11 const fixtureDir = pathe.resolve(
12 import.meta.dirname,
13 "../../../../../examples/cloudflare-website-vocs",
14 );
15 const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp");
16 const fixtureEntries = ["package.json", "public", "src", "tsconfig.json", "vocs.config.ts"];
17
18 describe(
19 "Fly.Website.Vocs local",
20 { tags: ["provider:fly", "provider:fly:website", "local"] },
21 () => {
22 // Vocs' vite plugin reads `src/pages` from process.cwd() rather than
23 // the project `root`, so alchemy-test (cwd = packages/alchemy) cannot
24 // host the cloned fixture. Cloudflare.Website.Vocs local uses the
25 // Worker source provider instead.
26 test.provider.skipIf(true)(
27 "dev runs the framework server with no cloud resources",
28 (stack) =>
29 Effect.gen(function* () {
30 yield* stack.destroy();
31
32 const rootDir = yield* cloneFixture(fixtureDir, {
33 prefix: "alchemy-vocs-fly-local-",
34 tempRoot,
35 entries: fixtureEntries,
36 });
37
38 const deployed = yield* stack.deploy(
39 Effect.gen(function* () {
40 const site = yield* Fly.Website.Vocs("Web", {
41 rootDir,
42 });
43 return { site };
44 }),
45 );
46
47 const url = deployed.site.url;
48 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/);
49 expect(deployed.site.service).toBeUndefined();
50 expect(deployed.site.app).toBeUndefined();
51 expect(deployed.site.ip).toBeUndefined();
52
53 yield* expectUrlContains(`${url}/`, "Alchemy with Vocs", {
54 timeout: "90 seconds",
55 label: "dev home page",
56 });
57
58 yield* stack.destroy();
59 }),
60 { timeout: 180_000 },
61 );
62 },
63 );