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 FileSystem from "effect/FileSystem";
6import * as Path from "effect/Path";
7import * as pathe from "pathe";
8import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
9import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
10
11const { test } = Test.make({ providers: Railway.providers(), dev: true });
12
13const fixtureDir = pathe.resolve(
14 import.meta.dirname,
15 "../../AWS/Website/fixtures/octane-app",
16);
17const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp");
18const fixtureEntries = [
19 ".gitignore",
20 "package.json",
21 "octane.config.ts",
22 "vite.config.ts",
23 "index.html",
24 "src",
25 "public",
26];
27
28describe(
29 "Railway.Website.Octane local",
30 { tags: ["provider:railway", "provider:railway:website", "local"] },
31 () => {
32 test.provider(
33 "dev runs the framework server with no cloud resources",
34 (stack) =>
35 Effect.gen(function* () {
36 yield* stack.destroy();
37
38 const rootDir = yield* cloneFixture(fixtureDir, {
39 prefix: "alchemy-octane-railway-local-",
40 tempRoot,
41 entries: fixtureEntries,
42 });
43
44 const fs = yield* FileSystem.FileSystem;
45 const pathMod = yield* Path.Path;
46 const configPath = pathMod.join(rootDir, "octane.config.ts");
47 const raw = yield* fs.readFileString(configPath);
48 expect(raw).not.toContain("adapter:");
49 expect(raw).not.toContain("@alchemy.run/frontend-frameworks");
50
51 const deployed = yield* stack.deploy(
52 Effect.gen(function* () {
53 const site = yield* Railway.Website.Octane("Web", {
54 rootDir,
55 });
56 return { site };
57 }),
58 );
59
60 const url = deployed.site.url;
61 expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/);
62 expect(deployed.site.service).toBeUndefined();
63 expect(deployed.site.project).toBeUndefined();
64
65 yield* expectUrlContains(`${url}/`, "OCTANE_AWS_PAGE_MARKER", {
66 timeout: "90 seconds",
67 label: "dev home page",
68 });
69 yield* expectUrlContains(
70 `${url}/api/hello?echo=roundtrip`,
71 "OCTANE_AWS_API_MARKER",
72 { label: "api route (dev)" },
73 );
74
75 yield* stack.destroy();
76 }),
77 { timeout: 120_000 },
78 );
79 },
80);