| 1 | import * as Cloudflare from "alchemy/Cloudflare"; |
| 2 | import * as Test from "alchemy/Test/Bun"; |
| 3 | import { expect } from "bun:test"; |
| 4 | import * as Console from "effect/Console"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import Stack from "../alchemy.run.ts"; |
| 7 | |
| 8 | const { test, beforeAll, afterAll, deploy, destroy } = Test.make({ |
| 9 | providers: Cloudflare.providers(), |
| 10 | state: Cloudflare.state(), |
| 11 | }); |
| 12 | |
| 13 | const stack = beforeAll(deploy(Stack).pipe(Effect.tap(Console.log))); |
| 14 | afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack)); |
| 15 | |
| 16 | test( |
| 17 | "serves the TanStack Start Solid app shell", |
| 18 | Effect.gen(function* () { |
| 19 | const { websiteUrl } = yield* stack; |
| 20 | |
| 21 | // `HttpClient.get` resolves successfully even on the fresh-deploy 404, so a |
| 22 | // plain `Effect.retry` never fires — `Test.getWhenReady` fails on the |
| 23 | // cold-start window and retries until the route serves the real app. |
| 24 | const res = yield* Test.getWhenReady(websiteUrl); |
| 25 | expect(res.status).toBe(200); |
| 26 | const html = yield* res.text; |
| 27 | expect(html).toContain("TanStack Start Solid"); |
| 28 | expect(html).toContain( |
| 29 | "Hello from TanStack Start Solid on Cloudflare.Website.Vite", |
| 30 | ); |
| 31 | }), |
| 32 | { timeout: 180_000 }, |
| 33 | ); |