| 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 | "../../AWS/Website/fixtures/sveltekit-app", |
| 14 | ); |
| 15 | const tempRoot = pathe.resolve(import.meta.dirname, "../../../.tmp"); |
| 16 | const fixtureEntries = [".gitignore", "package.json", "src", "static"]; |
| 17 | |
| 18 | describe( |
| 19 | "Railway.Website.SvelteKit local", |
| 20 | { tags: ["provider:railway", "provider:railway:website", "local"] }, |
| 21 | () => { |
| 22 | test.provider( |
| 23 | "dev runs the framework server with no cloud resources", |
| 24 | (stack) => |
| 25 | Effect.gen(function* () { |
| 26 | yield* stack.destroy(); |
| 27 | |
| 28 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 29 | prefix: "alchemy-sveltekit-railway-local-", |
| 30 | tempRoot, |
| 31 | entries: fixtureEntries, |
| 32 | }); |
| 33 | |
| 34 | const deployed = yield* stack.deploy( |
| 35 | Effect.gen(function* () { |
| 36 | const site = yield* Railway.Website.SvelteKit("Web", { |
| 37 | rootDir, |
| 38 | }); |
| 39 | return { site }; |
| 40 | }), |
| 41 | ); |
| 42 | |
| 43 | const url = deployed.site.url; |
| 44 | expect(url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+\/?$/); |
| 45 | expect(deployed.site.service).toBeUndefined(); |
| 46 | expect(deployed.site.project).toBeUndefined(); |
| 47 | |
| 48 | yield* expectUrlContains(`${url}/`, "SVELTEKIT_AWS_PAGE_MARKER", { |
| 49 | timeout: "90 seconds", |
| 50 | label: "dev home page", |
| 51 | }); |
| 52 | yield* expectUrlContains( |
| 53 | `${url}/api/hello?echo=roundtrip`, |
| 54 | "SVELTEKIT_AWS_API_MARKER", |
| 55 | { label: "api route (dev)" }, |
| 56 | ); |
| 57 | yield* expectUrlContains( |
| 58 | `${url}/prerendered`, |
| 59 | "SVELTEKIT_AWS_PRERENDERED_MARKER", |
| 60 | { label: "extra route (dev)" }, |
| 61 | ); |
| 62 | |
| 63 | yield* stack.destroy(); |
| 64 | }), |
| 65 | { timeout: 120_000 }, |
| 66 | ); |
| 67 | }, |
| 68 | ); |