The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { providers } from "@alchemy.run/neon/Providers"; |
| 2 | import { describe, expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 6 | import * as HttpClient from "effect/http/HttpClient"; |
| 7 | import { browserRoundtrip } from "./Browser.ts"; |
| 8 | import { bodyContaining, exampleRoot } from "./Fixture.ts"; |
| 9 | import { frameworks } from "./Frameworks.ts"; |
| 10 | |
| 11 | const { test } = Test.make({ providers: providers(), dev: true }); |
| 12 | |
| 13 | describe.sequential( |
| 14 | "Neon Website native frameworks", |
| 15 | { tags: ["provider:neon", "provider:neon:website", "local"] }, |
| 16 | () => { |
| 17 | for (const { slug, name, website } of frameworks) { |
| 18 | // Each dev server spawns 1-3 GiB toolchain children; the matrix cannot |
| 19 | // share a 4 GiB budget with a long-lived suite process. |
| 20 | test.provider.skipIf(!!process.env.FAST)( |
| 21 | slug, |
| 22 | (stack) => |
| 23 | Effect.gen(function* () { |
| 24 | yield* stack.destroy(); |
| 25 | const rootDir = yield* exampleRoot(slug); |
| 26 | const site = yield* stack.deploy( |
| 27 | Effect.gen(function* () { |
| 28 | return yield* website("Web", { |
| 29 | rootDir, |
| 30 | env: { GREETING: `Hello from ${name} on Neon!` }, |
| 31 | }); |
| 32 | }), |
| 33 | ); |
| 34 | expect(site.url).toMatch(/^http:\/\/(localhost|127\.0\.0\.1):\d+/); |
| 35 | expect(site.function).toBeUndefined(); |
| 36 | expect(site.project).toBeUndefined(); |
| 37 | expect(site.branch).toBeUndefined(); |
| 38 | expect(site.domain).toBeUndefined(); |
| 39 | yield* bodyContaining(`${site.url}/`, name); |
| 40 | const asset = yield* HttpClient.get(`${site.url}/example.json`); |
| 41 | expect(asset.status).toBe(200); |
| 42 | expect(yield* asset.json).toHaveProperty("framework"); |
| 43 | if (slug === "nextjs") { |
| 44 | const stream = yield* HttpClient.get(`${site.url}/api/stream`); |
| 45 | expect(yield* stream.text).toBe("data: first\n\ndata: second\n\n"); |
| 46 | const image = yield* HttpClient.get(`${site.url}/logo.svg`); |
| 47 | expect(image.headers["content-type"]).toContain("image/svg+xml"); |
| 48 | const redirect = yield* HttpClient.get(`${site.url}/redirect`).pipe( |
| 49 | Effect.provideService(FetchHttpClient.RequestInit, { redirect: "manual" }), |
| 50 | ); |
| 51 | expect(redirect.status).toBe(307); |
| 52 | const location = new URL(redirect.headers.location!); |
| 53 | expect(["localhost", "127.0.0.1"]).toContain(location.hostname); |
| 54 | expect(location.port).toBe(new URL(String(site.url)).port); |
| 55 | expect(location.pathname + location.search).toBe("/?redirected=yes"); |
| 56 | expect((yield* HttpClient.get(`${site.url}/not-a-real-page`)).status).toBe(404); |
| 57 | } |
| 58 | yield* browserRoundtrip(String(site.url), slug); |
| 59 | yield* stack.destroy(); |
| 60 | }), |
| 61 | { timeout: 120_000 }, |
| 62 | ); |
| 63 | } |
| 64 | }, |
| 65 | ); |