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

main
ts 105 lines 3.42 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
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: GCP.providers(), dev: true });
10
11 /**
12 * SolidStart 2's dev SSR does not run under Bun (`srvx/node` writes
13 * `[object Object]`). Body assertions stay gated; identity (localhost,
14 * no cloud rows) is asserted unconditionally. Set
15 * `ALCHEMY_TEST_SOLIDSTART_DEV_SSR=1` to run the body assertions on a
16 * Node-hosted sidecar.
17 */
18 const runDevSsr = process.env.ALCHEMY_TEST_SOLIDSTART_DEV_SSR === "1";
19
20 const fixtureDir = pathe.resolve(import.meta.dirname, "../../AWS/Website/fixtures/solidstart-app");
21 const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp");
22 const fixtureEntries = [".gitignore", "package.json", "vite.config.ts", "src", "public"];
23
24 describe(
25 "GCP.Website.SolidStart local",
26 { tags: ["provider:gcp", "provider:gcp:website", "local"] },
27 () => {
28 test.provider(
29 "dev runs the framework server with no cloud resources",
30 (stack) =>
31 Effect.gen(function* () {
32 yield* stack.destroy();
33
34 const rootDir = yield* cloneFixture(fixtureDir, {
35 prefix: "alchemy-solidstart-gcp-local-",
36 tempRoot,
37 entries: fixtureEntries,
38 });
39
40 const deployed = yield* stack.deploy(
41 Effect.gen(function* () {
42 const site = yield* GCP.Website.SolidStart("Web", {
43 rootDir,
44 });
45 return { site };
46 }),
47 );
48
49 const url = deployed.site.url;
50 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/);
51 expect(deployed.site.service).toBeUndefined();
52
53 yield* stack.destroy();
54 }),
55 {
56 tags: ["provider:gcp", "provider:gcp:website", "live"],
57 timeout: 120_000,
58 },
59 );
60
61 test.provider.skipIf(!runDevSsr)(
62 "dev serves SSR home and API routes",
63 (stack) =>
64 Effect.gen(function* () {
65 yield* stack.destroy();
66
67 const rootDir = yield* cloneFixture(fixtureDir, {
68 prefix: "alchemy-solidstart-gcp-local-ssr-",
69 tempRoot,
70 entries: fixtureEntries,
71 });
72
73 const deployed = yield* stack.deploy(
74 Effect.gen(function* () {
75 const site = yield* GCP.Website.SolidStart("Web", {
76 rootDir,
77 });
78 return { site };
79 }),
80 );
81
82 const url = deployed.site.url;
83 const origin = String(url).replace(/\/+$/, "");
84 yield* expectUrlContains(`${origin}/`, "SOLIDSTART_AWS_PAGE_MARKER", {
85 timeout: "90 seconds",
86 label: "dev home page",
87 });
88 yield* expectUrlContains(
89 `${origin}/api/hello?echo=roundtrip`,
90 "SOLIDSTART_AWS_API_MARKER",
91 { label: "api route (dev)" },
92 );
93 yield* expectUrlContains(`${origin}/prerendered`, "SOLIDSTART_AWS_PRERENDERED_MARKER", {
94 label: "extra route (dev)",
95 });
96
97 yield* stack.destroy();
98 }),
99 {
100 tags: ["provider:gcp", "provider:gcp:website", "live"],
101 timeout: 120_000,
102 },
103 );
104 },
105 );