1import * as Alchemy from "alchemy";
2import * as Cloudflare from "alchemy/Cloudflare";
3import * as Test from "alchemy/Test/Bun";
4import { expect } from "bun:test";
5import * as Effect from "effect/Effect";
6import { frameworks } from "../frameworks.ts";
7import Stack from "../alchemy.run.ts";
8
9const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
10 providers: Cloudflare.providers(),
11 profile: process.env.ALCHEMY_PROFILE,
12});
13const stack = beforeAll(
14 Effect.sync(Test.defaultStage).pipe(
15 Effect.flatMap((stage) => Alchemy.destroy({ stack: Stack, stage })),
16 Effect.andThen(deploy(Stack)),
17 ),
18 { timeout: 120_000 },
19);
20afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
21
22for (const { name, marker } of frameworks) {
23 test(
24 `${name}: the deployed Gateway serves its private Website`,
25 Effect.gen(function* () {
26 const { gatewayUrl } = (yield* stack)[name]!;
27 expect(gatewayUrl).toBeString();
28 const response = yield* Test.getWhenReady(String(gatewayUrl), {
29 times: 8,
30 });
31 expect(response.status).toBe(200);
32 expect(yield* response.text).toContain(marker);
33 }).pipe(Effect.timeout("60 seconds")),
34 { timeout: 65_000 },
35 );
36}