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

main
ts 66 lines 2.84 KB
Raw
1 import { providers } from "@alchemy.run/neon/Providers";
2 import { WebsiteArtifact } from "@alchemy.run/neon/Website/Artifact";
3 import { deployWebsite } from "@alchemy.run/neon/Website/FrameworkSite";
4 import { expect } from "@alchemy.run/test";
5 import * as Test from "@alchemy.run/test/Alchemy";
6 import * as Effect from "effect/Effect";
7 import * as FileSystem from "effect/FileSystem";
8 import * as Path from "effect/Path";
9 import { exampleRoot } from "./Fixture.ts";
10
11 const { test } = Test.make({ providers: providers() });
12
13 test.provider(
14 "website fixtures isolate sources, build output and dependency caches",
15 (stack) =>
16 Effect.gen(function* () {
17 yield* stack.destroy();
18 const fs = yield* FileSystem.FileSystem;
19 const path = yield* Path.Path;
20 const roots = yield* Effect.gen(function* () {
21 const first = yield* exampleRoot("vite");
22 const second = yield* exampleRoot("vite");
23 expect(first).not.toBe(second);
24 expect(path.basename(path.dirname(first))).toBe("examples");
25 const asset = "public/example.json";
26 const original = yield* fs.readFileString(path.join(second, asset));
27 yield* fs.writeFileString(path.join(first, asset), "changed");
28 expect(yield* fs.readFileString(path.join(second, asset))).toBe(original);
29 yield* fs.makeDirectory(path.join(first, "node_modules/.vite"));
30 yield* fs.writeFileString(path.join(first, "node_modules/.vite/marker"), "private");
31 expect(yield* fs.exists(path.join(second, "node_modules/.vite/marker"))).toBe(false);
32 expect(yield* fs.exists(path.resolve(first, "../../tsconfig.base.json"))).toBe(true);
33 expect(yield* fs.realPath(path.join(first, "node_modules/vite"))).toBe(
34 yield* fs.realPath(path.join(second, "node_modules/vite")),
35 );
36 expect(yield* fs.exists(path.join(first, "dist"))).toBe(false);
37 return [first, second];
38 }).pipe(Effect.scoped);
39 for (const root of roots) expect(yield* fs.exists(root)).toBe(false);
40 yield* stack.destroy();
41 }),
42 { tags: ["provider:neon", "provider:neon:website", "live"] },
43 );
44
45 test.provider(
46 "owned backend provisioning depends on artifact validation",
47 (stack) =>
48 Effect.gen(function* () {
49 yield* stack.destroy();
50 const plan = yield* stack.plan(
51 Effect.gen(function* () {
52 const artifact = yield* WebsiteArtifact("Artifact", {
53 root: ".",
54 distDir: "dist",
55 static: {},
56 });
57 return yield* deployWebsite({}, artifact);
58 }),
59 );
60 expect(plan.resources.Artifact?.downstream).toContain("Project");
61 expect(plan.resources.Project?.action).toBe("create");
62 expect(plan.resources.Function?.action).toBe("create");
63 yield* stack.destroy();
64 }),
65 { tags: ["provider:neon", "provider:neon:website", "live"], timeout: 120_000 },
66 );