1import * as GCP from "@/GCP";
2import * as Test from "@/Test/Alchemy";
3import { expect } from "alchemy-test";
4import * as Effect from "effect/Effect";
5import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
6import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
7import { dockerAvailable } from "../bindingHost.ts";
8import {
9 assertSiteGone,
10 awsFixture,
11 cloudRunUrl,
12 liveOptions,
13 logLevel,
14 serviceIdentity,
15 tempRoot,
16} from "./site.ts";
17
18const { test } = Test.make({ providers: GCP.providers() });
19
20const fixtureDir = awsFixture("react-router-app");
21const fixtureEntries = [
22 ".gitignore",
23 "package.json",
24 "react-router.config.ts",
25 "vite.config.ts",
26 "app",
27 "public",
28];
29
30test.provider.skipIf(!dockerAvailable)(
31 "ReactRouter: deploy, GET page and API route, destroy, gone",
32 (stack) =>
33 Effect.gen(function* () {
34 yield* stack.destroy();
35
36 const rootDir = yield* cloneFixture(fixtureDir, {
37 prefix: "alchemy-react-router-gcp-",
38 tempRoot,
39 entries: fixtureEntries,
40 });
41
42 const deployed = yield* stack.deploy(
43 Effect.gen(function* () {
44 const site = yield* GCP.Website.ReactRouter("Web", {
45 rootDir,
46 memo: {
47 include: [
48 "app/**",
49 "public/**",
50 "package.json",
51 "react-router.config.ts",
52 "vite.config.ts",
53 ],
54 },
55 });
56 return { site };
57 }),
58 );
59
60 const url = deployed.site.url as string;
61 expect(url).toMatch(cloudRunUrl);
62 expect(deployed.site.service).toBeDefined();
63 const service = serviceIdentity(deployed.site.service!);
64
65 yield* expectUrlContains(`${url}/`, "REACT_ROUTER_AWS_PAGE_MARKER", {
66 timeout: "180 seconds",
67 label: "ReactRouter /",
68 });
69 yield* expectUrlContains(
70 `${url}/api/hello?echo=roundtrip`,
71 "REACT_ROUTER_AWS_API_MARKER",
72 {
73 timeout: "30 seconds",
74 label: "ReactRouter /api/hello?echo=roundtrip",
75 },
76 );
77
78 yield* stack.destroy();
79 yield* assertSiteGone(service);
80 }).pipe(logLevel),
81 liveOptions(900_000),
82);