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