| 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 | awsFixture, |
| 11 | cloudRunUrl, |
| 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 = awsFixture("waku-app"); |
| 21 | const fixtureEntries = [ |
| 22 | ".gitignore", |
| 23 | "package.json", |
| 24 | "tsconfig.json", |
| 25 | "src", |
| 26 | "public", |
| 27 | ]; |
| 28 | |
| 29 | test.provider.skipIf(!dockerAvailable)( |
| 30 | "Waku: deploy, GET page, RSC and SSG routes, destroy, gone", |
| 31 | (stack) => |
| 32 | Effect.gen(function* () { |
| 33 | yield* stack.destroy(); |
| 34 | |
| 35 | const rootDir = yield* cloneFixture(fixtureDir, { |
| 36 | prefix: "alchemy-waku-gcp-", |
| 37 | tempRoot, |
| 38 | entries: fixtureEntries, |
| 39 | }); |
| 40 | |
| 41 | const deployed = yield* stack.deploy( |
| 42 | Effect.gen(function* () { |
| 43 | const site = yield* GCP.Website.Waku("Web", { |
| 44 | rootDir, |
| 45 | memo: { |
| 46 | include: ["src/**", "public/**", "package.json", "tsconfig.json"], |
| 47 | }, |
| 48 | }); |
| 49 | return { site }; |
| 50 | }), |
| 51 | ); |
| 52 | |
| 53 | const url = deployed.site.url as string; |
| 54 | expect(url).toMatch(cloudRunUrl); |
| 55 | expect(deployed.site.service).toBeDefined(); |
| 56 | const service = serviceIdentity(deployed.site.service!); |
| 57 | |
| 58 | yield* expectUrlContains(`${url}/`, "WAKU_AWS_PAGE_MARKER", { |
| 59 | timeout: "180 seconds", |
| 60 | label: "Waku /", |
| 61 | }); |
| 62 | yield* expectUrlContains( |
| 63 | `${url}/echo?echo=roundtrip`, |
| 64 | "WAKU_AWS_API_MARKER", |
| 65 | { |
| 66 | timeout: "30 seconds", |
| 67 | label: "Waku /echo?echo=roundtrip", |
| 68 | }, |
| 69 | ); |
| 70 | yield* expectUrlContains(`${url}/about`, "WAKU_AWS_STATIC_MARKER", { |
| 71 | timeout: "30 seconds", |
| 72 | label: "Waku /about", |
| 73 | }); |
| 74 | |
| 75 | yield* stack.destroy(); |
| 76 | yield* assertSiteGone(service); |
| 77 | }).pipe(logLevel), |
| 78 | liveOptions(900_000), |
| 79 | ); |