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 * as GCP from "@alchemy.run/gcp"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts"; |
| 6 | import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts"; |
| 7 | import { prepareNextjsFixture } from "../../Cloudflare/Website/TypeScriptCompat.ts"; |
| 8 | import { |
| 9 | assertSiteGone, |
| 10 | awsFixture, |
| 11 | cloudRunUrl, |
| 12 | liveOptions, |
| 13 | logLevel, |
| 14 | serviceIdentity, |
| 15 | } from "./site.ts"; |
| 16 | |
| 17 | const { test } = Test.make({ providers: GCP.providers() }); |
| 18 | |
| 19 | const fixtureDir = awsFixture("nextjs-app"); |
| 20 | const fixtureEntries = [ |
| 21 | ".gitignore", |
| 22 | "package.json", |
| 23 | "next.config.ts", |
| 24 | "tsconfig.json", |
| 25 | "app", |
| 26 | "public", |
| 27 | ]; |
| 28 | |
| 29 | test.provider( |
| 30 | "Nextjs: deploy, GET page, API and static routes, destroy, gone", |
| 31 | (stack) => |
| 32 | Effect.gen(function* () { |
| 33 | yield* stack.destroy(); |
| 34 | |
| 35 | // Clone outside the repo: an in-workspace clone makes Next treat the |
| 36 | // monorepo as the workspace root and pick up the root's typescript. |
| 37 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 38 | prefix: "alchemy-nextjs-gcp-", |
| 39 | entries: fixtureEntries, |
| 40 | }); |
| 41 | yield* prepareNextjsFixture(rootDir); |
| 42 | |
| 43 | const deployed = yield* stack.deploy( |
| 44 | Effect.gen(function* () { |
| 45 | const site = yield* GCP.Website.Nextjs("Web", { |
| 46 | rootDir, |
| 47 | memo: { |
| 48 | include: ["app/**", "public/**", "package.json", "next.config.ts", "tsconfig.json"], |
| 49 | }, |
| 50 | }); |
| 51 | return { site }; |
| 52 | }), |
| 53 | ); |
| 54 | |
| 55 | const url = deployed.site.url as string; |
| 56 | expect(url).toMatch(cloudRunUrl); |
| 57 | expect(deployed.site.service).toBeDefined(); |
| 58 | const service = serviceIdentity(deployed.site.service!); |
| 59 | |
| 60 | yield* expectUrlContains(`${url}/`, "NEXTJS_AWS_PAGE_MARKER", { |
| 61 | timeout: "180 seconds", |
| 62 | label: "Nextjs /", |
| 63 | }); |
| 64 | yield* expectUrlContains(`${url}/api/hello?echo=roundtrip`, "NEXTJS_AWS_API_MARKER", { |
| 65 | timeout: "30 seconds", |
| 66 | label: "Nextjs /api/hello?echo=roundtrip", |
| 67 | }); |
| 68 | yield* expectUrlContains(`${url}/static`, "NEXTJS_AWS_STATIC_MARKER", { |
| 69 | timeout: "30 seconds", |
| 70 | label: "Nextjs /static", |
| 71 | }); |
| 72 | |
| 73 | yield* stack.destroy(); |
| 74 | yield* assertSiteGone(service); |
| 75 | }).pipe(logLevel), |
| 76 | liveOptions(1_200_000), |
| 77 | ); |