@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 105 lines 4.04 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
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 FileSystem from "effect/FileSystem";
6 import * as Path from "effect/Path";
7 import * as pathe from "pathe";
8 import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
9 import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
10
11 // `dev: true` runs local providers behind the RPC sidecar proxy by default,
12 // matching the process topology of the real `alchemy dev` command.
13 const { test } = Test.make({ providers: AWS.providers(), dev: true });
14
15 const fixtureDir = pathe.resolve(import.meta.dirname, "fixtures", "octane-app");
16
17 // Clone under the alchemy package so `octane`/`@octanejs/*`/`vite` resolve
18 // from the workspace's hoisted node_modules (the fixture has no
19 // node_modules).
20 const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp");
21
22 const fixtureEntries = [
23 ".gitignore",
24 "package.json",
25 "octane.config.ts",
26 "vite.config.ts",
27 "index.html",
28 "src",
29 "public",
30 ];
31
32 describe(
33 "AWS.Website.Octane local",
34 { tags: ["provider:aws", "provider:aws:website", "local"] },
35 () => {
36 test.provider(
37 "dev runs Octane's own dev server with no cloud resources",
38 (stack) =>
39 Effect.gen(function* () {
40 const fs = yield* FileSystem.FileSystem;
41 const path = yield* Path.Path;
42
43 yield* stack.destroy();
44
45 const rootDir = yield* cloneFixture(fixtureDir, {
46 prefix: "alchemy-octane-aws-local-",
47 tempRoot,
48 entries: fixtureEntries,
49 });
50
51 const deployed = yield* stack.deploy(
52 Effect.gen(function* () {
53 const site = yield* AWS.Website.Octane("OctaneSite", { rootDir });
54 return { site };
55 }),
56 );
57
58 // The site is the framework's own dev server: a localhost URL and
59 // no cloud rows at all (proof no AWS call ran).
60 const url = deployed.site.url! as string;
61 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1|\[[0-9a-fA-F:]+\])/);
62 expect(deployed.site.distribution).toBeUndefined();
63 expect(deployed.site.server).toBeUndefined();
64 expect(deployed.site.bucket).toBeUndefined();
65
66 // SSR page served by Octane's Vite dev server (native HMR
67 // toolchain). NOTE: Octane's dev middleware supplies no platform
68 // bindings — the plain dev server is the whole story here.
69 yield* expectUrlContains(`${url}/`, "OCTANE_AWS_PAGE_MARKER", {
70 timeout: "120 seconds",
71 label: "dev SSR home page",
72 });
73 // Server API route through the dev server.
74 yield* expectUrlContains(`${url}/api/hello?echo=dev`, "OCTANE_AWS_API_MARKER", {
75 label: "API route (dev)",
76 });
77 yield* expectUrlContains(`${url}/api/hello?echo=dev`, "dev", {
78 label: "API route query echo (dev)",
79 });
80
81 // ── HMR: edit the page component in place. The stack is NOT
82 // re-applied — Octane's Vite dev server must hot-update the module
83 // and serve the new marker through the same URL ──────────────────
84 const appPath = path.join(rootDir, "src/App.tsx");
85 const app = yield* fs.readFileString(appPath);
86 yield* fs.writeFileString(
87 appPath,
88 app.replace("OCTANE_AWS_PAGE_MARKER", "OCTANE_AWS_PAGE_MARKER_V2"),
89 );
90 yield* expectUrlContains(`${url}/`, "OCTANE_AWS_PAGE_MARKER_V2", {
91 timeout: "90 seconds",
92 label: "SSR page after HMR edit",
93 });
94 // The API route (octane.config.ts server route) survived the
95 // client-module hot update.
96 yield* expectUrlContains(`${url}/api/hello?echo=post-hmr`, "OCTANE_AWS_API_MARKER", {
97 label: "API route after HMR edit",
98 });
99
100 yield* stack.destroy();
101 }),
102 { timeout: 600_000 },
103 );
104 },
105 );