| 1 | import * as Alchemy from "alchemy"; |
| 2 | import * as Cloudflare from "alchemy/Cloudflare"; |
| 3 | import * as Test from "alchemy/Test/Bun"; |
| 4 | import { expect } from "bun:test"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { frameworks } from "../frameworks.ts"; |
| 7 | import Stack from "../alchemy.run.ts"; |
| 8 | |
| 9 | const { test, beforeAll, afterAll, deploy, destroy } = Test.make({ |
| 10 | providers: Cloudflare.providers(), |
| 11 | profile: process.env.ALCHEMY_PROFILE, |
| 12 | }); |
| 13 | const 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 | ); |
| 20 | afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack)); |
| 21 | |
| 22 | for (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 | } |