| 1 | import * as Railway from "@/Railway"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import { describe, expect } from "alchemy-test"; |
| 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: Railway.providers(), dev: true }); |
| 10 | |
| 11 | const fixtureDir = pathe.resolve( |
| 12 | import.meta.dirname, |
| 13 | "../../Cloudflare/Website/foldkit-fixture", |
| 14 | ); |
| 15 | const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp"); |
| 16 | const fixtureEntries = ["index.html", "package.json", "vite.config.ts", "src"]; |
| 17 | |
| 18 | describe( |
| 19 | "Railway.Website.Foldkit local", |
| 20 | { tags: ["provider:railway", "provider:railway:website", "local"] }, |
| 21 | () => { |
| 22 | // foldkit@0.148.2 requires SchemaTransformation.transformOrFail, absent in Effect rc.115. |
| 23 | test.provider.skip( |
| 24 | "dev runs the framework server with no cloud resources", |
| 25 | (stack) => |
| 26 | Effect.gen(function* () { |
| 27 | yield* stack.destroy(); |
| 28 | |
| 29 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 30 | prefix: "alchemy-foldkit-railway-local-", |
| 31 | tempRoot, |
| 32 | entries: fixtureEntries, |
| 33 | }); |
| 34 | |
| 35 | const deployed = yield* stack.deploy( |
| 36 | Effect.gen(function* () { |
| 37 | const site = yield* Railway.Website.Foldkit("Web", { |
| 38 | rootDir, |
| 39 | }); |
| 40 | return { site }; |
| 41 | }), |
| 42 | ); |
| 43 | |
| 44 | const url = deployed.site.url; |
| 45 | expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/); |
| 46 | expect(deployed.site.service).toBeUndefined(); |
| 47 | expect(deployed.site.project).toBeUndefined(); |
| 48 | |
| 49 | yield* expectUrlContains(`${url}/`, "Foldkit Fixture", { |
| 50 | timeout: "90 seconds", |
| 51 | label: "dev home page", |
| 52 | }); |
| 53 | yield* expectUrlContains(`${url}/counter/42`, "Foldkit Fixture", { |
| 54 | label: "spa fallback", |
| 55 | }); |
| 56 | |
| 57 | yield* stack.destroy(); |
| 58 | }), |
| 59 | { timeout: 120_000 }, |
| 60 | ); |
| 61 | }, |
| 62 | ); |