1import * as Railway from "@/Railway";
2import * as Test from "@/Test/Alchemy";
3import { describe, expect } from "alchemy-test";
4import * as Effect from "effect/Effect";
5import * as pathe from "pathe";
6import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
7import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
8
9const { test } = Test.make({ providers: Railway.providers(), dev: true });
10
11const fixtureDir = pathe.resolve(
12 import.meta.dirname,
13 "../../Cloudflare/Website/staticsite-fixture",
14);
15const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp");
16
17describe(
18 "Railway.Website.StaticSite local",
19 { tags: ["provider:railway", "provider:railway:website", "local"] },
20 () => {
21 test.provider(
22 "dev builds and serves outdir locally with no cloud resources",
23 (stack) =>
24 Effect.gen(function* () {
25 yield* stack.destroy();
26
27 const cwd = yield* cloneFixture(fixtureDir, {
28 prefix: "alchemy-staticsite-railway-local-",
29 tempRoot,
30 entries: ["src", "build.sh"],
31 });
32
33 const deployed = yield* stack.deploy(
34 Effect.gen(function* () {
35 const site = yield* Railway.Website.StaticSite("Blog", {
36 cwd,
37 command: "bash build.sh",
38 shell: true,
39 outdir: "dist",
40 });
41 return { site };
42 }),
43 );
44
45 const url = deployed.site.url;
46 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/);
47 expect(deployed.site.service).toBeUndefined();
48 expect(deployed.site.project).toBeUndefined();
49
50 yield* expectUrlContains(`${url}/`, "StaticSite fixture v1", {
51 timeout: "90 seconds",
52 label: "dev staticsite index",
53 });
54
55 yield* stack.destroy();
56 }),
57 { timeout: 120_000 },
58 );
59 },
60);