| 1 | import { exec } from "@/Util/exec.ts"; |
| 2 | import { nodeLoaderArgs } from "@/Util/Node.ts"; |
| 3 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 4 | import { describe, expect, it } from "alchemy-test"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { ChildProcess } from "effect/process"; |
| 7 | import { fileURLToPath } from "node:url"; |
| 8 | |
| 9 | describe( |
| 10 | "optional frontend-frameworks peer", |
| 11 | { tags: ["unit", "local"] }, |
| 12 | () => { |
| 13 | it.effect( |
| 14 | "imports providers without the peer and reports missing website dependencies as defects", |
| 15 | () => |
| 16 | Effect.gen(function* () { |
| 17 | const fixture = fileURLToPath( |
| 18 | new URL( |
| 19 | "./fixtures/optional-frontend-frameworks.fixture.ts", |
| 20 | import.meta.url, |
| 21 | ), |
| 22 | ); |
| 23 | const { exitCode, stdout, stderr } = yield* exec( |
| 24 | ChildProcess.make("node", [...nodeLoaderArgs(fixture), fixture], { |
| 25 | stdout: "pipe", |
| 26 | stderr: "pipe", |
| 27 | killSignal: "SIGKILL", |
| 28 | }), |
| 29 | ); |
| 30 | expect({ exitCode, stderr }).toEqual({ exitCode: 0, stderr: "" }); |
| 31 | expect(JSON.parse(stdout)).toEqual({ |
| 32 | providers: ["Prisma", "Neon", "Fly", "Hetzner", "Railway"], |
| 33 | providerImportAttempts: 0, |
| 34 | loaderImportAttempts: 1, |
| 35 | defect: true, |
| 36 | error: { |
| 37 | _tag: "FrameworkServerError", |
| 38 | framework: "@alchemy.run/frontend-frameworks/core", |
| 39 | message: expect.stringContaining( |
| 40 | "Install @alchemy.run/frontend-frameworks", |
| 41 | ), |
| 42 | cause: |
| 43 | "Cannot find package '@alchemy.run/frontend-frameworks/core'", |
| 44 | }, |
| 45 | }); |
| 46 | }).pipe( |
| 47 | Effect.timeout("30 seconds"), |
| 48 | Effect.scoped, |
| 49 | Effect.provide(NodeServices.layer), |
| 50 | ), |
| 51 | { timeout: 40_000 }, |
| 52 | ); |
| 53 | }, |
| 54 | ); |