| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import { expect } from "alchemy-test"; |
| 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 { dockerAvailable } from "../bindingHost.ts"; |
| 8 | import { |
| 9 | assertSiteGone, |
| 10 | cloudRunUrl, |
| 11 | cloudflareFixture, |
| 12 | liveOptions, |
| 13 | logLevel, |
| 14 | serviceIdentity, |
| 15 | tempRoot, |
| 16 | } from "./site.ts"; |
| 17 | |
| 18 | const { test } = Test.make({ providers: GCP.providers() }); |
| 19 | |
| 20 | const fixtureDir = cloudflareFixture("foldkit-fixture"); |
| 21 | const fixtureEntries = ["index.html", "package.json", "vite.config.ts", "src"]; |
| 22 | |
| 23 | test.provider.skipIf(!dockerAvailable)( |
| 24 | "Foldkit: deploy, GET / and a deep link, destroy, gone", |
| 25 | (stack) => |
| 26 | Effect.gen(function* () { |
| 27 | yield* stack.destroy(); |
| 28 | |
| 29 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 30 | prefix: "alchemy-foldkit-gcp-", |
| 31 | tempRoot, |
| 32 | entries: fixtureEntries, |
| 33 | }); |
| 34 | |
| 35 | const deployed = yield* stack.deploy( |
| 36 | Effect.gen(function* () { |
| 37 | const site = yield* GCP.Website.Foldkit("Web", { |
| 38 | rootDir, |
| 39 | memo: { |
| 40 | include: [ |
| 41 | "index.html", |
| 42 | "src/**", |
| 43 | "package.json", |
| 44 | "vite.config.ts", |
| 45 | ], |
| 46 | }, |
| 47 | }); |
| 48 | return { site }; |
| 49 | }), |
| 50 | ); |
| 51 | |
| 52 | const url = deployed.site.url as string; |
| 53 | expect(url).toMatch(cloudRunUrl); |
| 54 | expect(deployed.site.service).toBeDefined(); |
| 55 | const service = serviceIdentity(deployed.site.service!); |
| 56 | |
| 57 | yield* expectUrlContains(`${url}/`, "Foldkit Fixture", { |
| 58 | timeout: "180 seconds", |
| 59 | label: "Foldkit /", |
| 60 | }); |
| 61 | yield* expectUrlContains(`${url}/counter/42`, "Foldkit Fixture", { |
| 62 | timeout: "30 seconds", |
| 63 | label: "Foldkit /counter/42", |
| 64 | }); |
| 65 | |
| 66 | yield* stack.destroy(); |
| 67 | yield* assertSiteGone(service); |
| 68 | }).pipe(logLevel), |
| 69 | liveOptions(900_000), |
| 70 | ); |