The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Fly from "@alchemy.run/fly"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as machines from "@distilled.cloud/fly-io/machines"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { MinimumLogLevel } from "effect/References"; |
| 7 | import * as Schedule from "effect/Schedule"; |
| 8 | import * as pathe from "pathe"; |
| 9 | import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts"; |
| 10 | import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts"; |
| 11 | |
| 12 | const { test } = Test.make({ providers: Fly.providers() }); |
| 13 | |
| 14 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 15 | |
| 16 | const fixtureDir = pathe.resolve(import.meta.dirname, "../../AWS/Website/fixtures/solidstart-app"); |
| 17 | const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp"); |
| 18 | const fixtureEntries = [".gitignore", "package.json", "vite.config.ts", "src", "public"]; |
| 19 | |
| 20 | const waitUntilGone = (appName: string) => |
| 21 | machines.getApp({ app_name: appName }).pipe( |
| 22 | Effect.as("found" as const), |
| 23 | Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)), |
| 24 | Effect.repeat({ |
| 25 | schedule: Schedule.spaced("1 second"), |
| 26 | until: (status) => status === "gone", |
| 27 | times: 10, |
| 28 | }), |
| 29 | ); |
| 30 | |
| 31 | test.provider( |
| 32 | "SolidStart: deploy, GET /, destroy, gone", |
| 33 | (stack) => |
| 34 | Effect.gen(function* () { |
| 35 | yield* stack.destroy(); |
| 36 | |
| 37 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 38 | prefix: "alchemy-solidstart-fly-", |
| 39 | tempRoot, |
| 40 | entries: fixtureEntries, |
| 41 | }); |
| 42 | |
| 43 | const deployed = yield* stack.deploy( |
| 44 | Effect.gen(function* () { |
| 45 | const site = yield* Fly.Website.SolidStart("Web", { |
| 46 | rootDir, |
| 47 | memo: { |
| 48 | include: ["src/**", "public/**", "package.json", "vite.config.ts"], |
| 49 | }, |
| 50 | }); |
| 51 | return { site }; |
| 52 | }), |
| 53 | ); |
| 54 | |
| 55 | const url = deployed.site.url; |
| 56 | expect(url).toBeDefined(); |
| 57 | expect(url).toMatch(/^https:\/\//); |
| 58 | expect(deployed.site.service).toBeDefined(); |
| 59 | expect(deployed.site.app).toBeDefined(); |
| 60 | |
| 61 | yield* expectUrlContains(`${url!}/health`, "ok", { |
| 62 | timeout: "60 seconds", |
| 63 | label: "health", |
| 64 | }); |
| 65 | yield* expectUrlContains(`${url!}/`, "SOLIDSTART_AWS_PAGE_MARKER", { |
| 66 | timeout: "180 seconds", |
| 67 | label: "home page", |
| 68 | }); |
| 69 | yield* expectUrlContains(`${url!}/api/hello?echo=roundtrip`, "SOLIDSTART_AWS_API_MARKER", { |
| 70 | timeout: "30 seconds", |
| 71 | label: "api route", |
| 72 | }); |
| 73 | |
| 74 | const appName = deployed.site.app!.appName; |
| 75 | yield* stack.destroy(); |
| 76 | const gone = yield* waitUntilGone(appName); |
| 77 | expect(gone).toEqual("gone"); |
| 78 | }).pipe(logLevel), |
| 79 | { |
| 80 | tags: ["provider:fly", "provider:fly:machine", "provider:fly:website", "live"], |
| 81 | timeout: 360000, |
| 82 | }, |
| 83 | ); |