@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 98 lines 3 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as Effect from "effect/Effect";
5 import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
6 import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
7 import {
8 foldkitFixture,
9 foldkitMemo,
10 verifyFoldkitBrowser,
11 verifyFoldkitRendering,
12 } from "../../Website/Foldkit.ts";
13 import {
14 assertSiteGone,
15 cloudRunUrl,
16 cloudflareFixture,
17 type DeployedService,
18 liveOptions,
19 logLevel,
20 serviceIdentity,
21 tempRoot,
22 } from "./site.ts";
23
24 const { test } = Test.make({ providers: GCP.providers() });
25
26 const fixtureDir = cloudflareFixture("foldkit-fixture");
27 const fixtureEntries = ["index.html", "package.json", "vite.config.ts", "src"];
28
29 test.provider(
30 "Foldkit: deploy, GET / and a deep link, destroy, gone",
31 (stack) =>
32 Effect.gen(function* () {
33 yield* stack.destroy();
34
35 const rootDir = yield* cloneFixture(fixtureDir, {
36 prefix: "alchemy-foldkit-gcp-",
37 tempRoot,
38 entries: fixtureEntries,
39 });
40
41 const deployed = yield* stack.deploy(
42 Effect.gen(function* () {
43 const site = yield* GCP.Website.Foldkit("Web", {
44 rootDir,
45 memo: {
46 include: ["index.html", "src/**", "package.json", "vite.config.ts"],
47 },
48 });
49 return { site };
50 }),
51 );
52
53 const url = deployed.site.url as string;
54 expect(url).toMatch(cloudRunUrl);
55 expect(deployed.site.service).toBeDefined();
56 const service = serviceIdentity(deployed.site.service!);
57
58 yield* expectUrlContains(`${url}/`, "Foldkit Fixture", {
59 timeout: "180 seconds",
60 label: "Foldkit /",
61 });
62 yield* expectUrlContains(`${url}/counter/42`, "Foldkit Fixture", {
63 timeout: "30 seconds",
64 label: "Foldkit /counter/42",
65 });
66
67 yield* stack.destroy();
68 yield* assertSiteGone(service);
69 }).pipe(logLevel),
70 liveOptions(900_000),
71 );
72
73 // One Cloud Run service walked through every server-rendered mode: each
74 // redeploy replaces the build, and every route must answer for the new mode.
75 test.provider.skipIf(!!process.env.FAST)(
76 "Foldkit: ssg, ssr and hybrid render every route across redeploys",
77 (stack) =>
78 Effect.gen(function* () {
79 yield* stack.destroy();
80
81 let service: DeployedService | undefined;
82 for (const mode of ["ssg", "ssr", "hybrid"] as const) {
83 const rootDir = yield* foldkitFixture(mode);
84 const site = yield* stack.deploy(
85 GCP.Website.Foldkit("Web", { rootDir, memo: foldkitMemo }),
86 );
87 expect(site.url).toMatch(cloudRunUrl);
88 expect(site.service).toBeDefined();
89 service = serviceIdentity(site.service!);
90 yield* verifyFoldkitRendering(site.url as string, mode);
91 yield* verifyFoldkitBrowser(site.url as string, mode);
92 }
93
94 yield* stack.destroy();
95 yield* assertSiteGone(service!);
96 }).pipe(logLevel),
97 liveOptions(1_800_000),
98 );