1import * as Cloudflare from "alchemy/Cloudflare";
2import * as Test from "alchemy/Test/Bun";
3import { expect } from "bun:test";
4import * as Console from "effect/Console";
5import * as Effect from "effect/Effect";
6import Stack from "../alchemy.run.ts";
7
8const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
9 providers: Cloudflare.providers(),
10 state: Cloudflare.state(),
11});
12
13const stack = beforeAll(deploy(Stack).pipe(Effect.tap(Console.log)));
14afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
15
16test(
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);