@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 97 lines 3.31 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 /**
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 "Fly.Website.SolidStart local",
26 { tags: ["provider:fly", "provider:fly: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-fly-local-",
36 tempRoot,
37 entries: fixtureEntries,
38 });
39
40 const deployed = yield* stack.deploy(
41 Effect.gen(function* () {
42 const site = yield* Fly.Website.SolidStart("Web", { rootDir });
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* stack.destroy();
54 }),
55 { timeout: 120_000 },
56 );
57
58 test.provider.skipIf(!runDevSsr)(
59 "dev serves SSR home and API routes",
60 (stack) =>
61 Effect.gen(function* () {
62 yield* stack.destroy();
63
64 const rootDir = yield* cloneFixture(fixtureDir, {
65 prefix: "alchemy-solidstart-fly-local-ssr-",
66 tempRoot,
67 entries: fixtureEntries,
68 });
69
70 const deployed = yield* stack.deploy(
71 Effect.gen(function* () {
72 const site = yield* Fly.Website.SolidStart("Web", { rootDir });
73 return { site };
74 }),
75 );
76
77 const url = deployed.site.url;
78 const origin = String(url).replace(/\/+$/, "");
79 yield* expectUrlContains(`${origin}/`, "SOLIDSTART_AWS_PAGE_MARKER", {
80 timeout: "90 seconds",
81 label: "dev home page",
82 });
83 yield* expectUrlContains(
84 `${origin}/api/hello?echo=roundtrip`,
85 "SOLIDSTART_AWS_API_MARKER",
86 { label: "api route (dev)" },
87 );
88 yield* expectUrlContains(`${origin}/prerendered`, "SOLIDSTART_AWS_PRERENDERED_MARKER", {
89 label: "extra route (dev)",
90 });
91
92 yield* stack.destroy();
93 }),
94 { timeout: 120_000 },
95 );
96 },
97 );