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

main
ts 80 lines 3.05 KB
Raw
1 import { providers } from "@alchemy.run/neon/Providers";
2 import * as Website from "@alchemy.run/neon/Website";
3 import { describe, expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as Effect from "effect/Effect";
6 import { bodyContaining, exampleRoot } from "./Fixture.ts";
7
8 const { test } = Test.make({ providers: providers(), dev: true });
9 const constructors = [
10 Website.Vite,
11 Website.Astro,
12 Website.Nextjs,
13 Website.Nuxt,
14 Website.SvelteKit,
15 Website.ReactRouter,
16 Website.SolidStart,
17 Website.TanStackStart,
18 Website.Waku,
19 Website.Octane,
20 Website.Foldkit,
21 Website.Vocs,
22 ];
23
24 describe.sequential(
25 "Neon Website explicit local scope",
26 { tags: ["provider:neon", "provider:neon:website", "local"] },
27 () => {
28 for (const [index, website] of constructors.entries()) {
29 test.provider(
30 `constructor ${index} preserves explicit branch and project without an implicit backend`,
31 (stack) =>
32 Effect.gen(function* () {
33 yield* stack.destroy();
34 const dev = { mode: "external" as const, url: "http://localhost:5173" };
35 const branch = { projectId: "explicit-project", branchId: "explicit-branch" };
36 const project = { projectId: "explicit-project" };
37 const first = yield* stack.deploy(website("Web", { branch, dev }));
38 expect(first.branch).toEqual(branch);
39 expect(first.project).toBeUndefined();
40 expect(first.function).toBeUndefined();
41 expect(first.url).toBe(dev.url);
42 const second = yield* stack.deploy(website("Web", { project, dev }));
43 expect(second.project).toEqual(project);
44 expect(second.branch).toBeUndefined();
45 expect(second.function).toBeUndefined();
46 yield* stack.destroy();
47 }),
48 { timeout: 120_000 },
49 );
50 }
51
52 test.provider(
53 "StaticSite preserves explicit branch and project without an implicit backend",
54 (stack) =>
55 Effect.gen(function* () {
56 yield* stack.destroy();
57 const rootDir = yield* exampleRoot("static");
58 const branch = { projectId: "explicit-project", branchId: "explicit-branch" };
59 const project = { projectId: "explicit-project" };
60 const props = {
61 rootDir,
62 command: "bun run build",
63 outdir: "dist",
64 dev: { command: "bun run dev:site" },
65 };
66 const first = yield* stack.deploy(Website.StaticSite("Web", { ...props, branch }));
67 expect(first.branch).toEqual(branch);
68 expect(first.project).toBeUndefined();
69 expect(first.function).toBeUndefined();
70 yield* bodyContaining(String(first.url), "Static site on Neon");
71 const second = yield* stack.deploy(Website.StaticSite("Web", { ...props, project }));
72 expect(second.project).toEqual(project);
73 expect(second.branch).toBeUndefined();
74 expect(second.function).toBeUndefined();
75 yield* stack.destroy();
76 }),
77 { timeout: 120_000 },
78 );
79 },
80 );